summaryrefslogtreecommitdiffstats
path: root/src/libnetdata/bitmap64.h
blob: 425f3fd209eed1b981366b40bfda66729620744b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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