summaryrefslogtreecommitdiffstats
path: root/src/libnetdata/bitmap/bitmap64.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-11-09 08:36:07 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-11-25 11:21:20 +0000
commiteae52fdaa9298e00f14b0b6256400d200db9c373 (patch)
treea3040a19bd024295ded05370853647bab9d7c225 /src/libnetdata/bitmap/bitmap64.h
parentAdding upstream version 1.47.5. (diff)
downloadnetdata-upstream/2.0.3.tar.xz
netdata-upstream/2.0.3.zip
Adding upstream version 2.0.3.upstream/2.0.3
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/libnetdata/bitmap/bitmap64.h')
-rw-r--r--src/libnetdata/bitmap/bitmap64.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/libnetdata/bitmap/bitmap64.h b/src/libnetdata/bitmap/bitmap64.h
new file mode 100644
index 000000000..425f3fd20
--- /dev/null
+++ b/src/libnetdata/bitmap/bitmap64.h
@@ -0,0 +1,35 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+
+#ifndef NETDATA_BITMAP64_H
+#define NETDATA_BITMAP64_H
+
+#include <stdbool.h>
+#include <stdint.h>
+#include <assert.h>
+
+typedef uint64_t bitmap64_t;
+
+#define BITMAP64_INITIALIZER 0
+
+static inline void bitmap64_set(bitmap64_t *bitmap, int position)
+{
+ assert(position >= 0 && position < 64);
+
+ *bitmap |= (1ULL << position);
+}
+
+static inline void bitmap64_clear(bitmap64_t *bitmap, int position)
+{
+ assert(position >= 0 && position < 64);
+
+ *bitmap &= ~(1ULL << position);
+}
+
+static inline bool bitmap64_get(const bitmap64_t *bitmap, int position)
+{
+ assert(position >= 0 && position < 64);
+
+ return (*bitmap & (1ULL << position));
+}
+
+#endif // NETDATA_BITMAP64_H