bitmap64.h 724 B

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