| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | |
| 3 | #ifndef NETDATA_BITMAP64_H |
| 4 | #define NETDATA_BITMAP64_H |
| 5 | |
| 6 | #include <stdbool.h> |
| 7 | #include <stdint.h> |
| 8 | #include <assert.h> |
| 9 | |
| 10 | typedef uint64_t bitmap64_t; |
| 11 | |
| 12 | #define BITMAP64_INITIALIZER 0 |
| 13 | |
| 14 | static inline void bitmap64_set(bitmap64_t *bitmap, int position) |
| 15 | { |
| 16 | assert(position >= 0 && position < 64); |
| 17 | |
| 18 | *bitmap |= (1ULL << position); |
| 19 | } |
| 20 | |
| 21 | static inline void bitmap64_clear(bitmap64_t *bitmap, int position) |
| 22 | { |
| 23 | assert(position >= 0 && position < 64); |
| 24 | |
| 25 | *bitmap &= ~(1ULL << position); |
| 26 | } |
| 27 | |
| 28 | static inline bool bitmap64_get(const bitmap64_t *bitmap, int position) |
| 29 | { |
| 30 | assert(position >= 0 && position < 64); |
| 31 | |
| 32 | return (*bitmap & (1ULL << position)); |
| 33 | } |
| 34 | |
| 35 | #endif // NETDATA_BITMAP64_H |