29cc22e07884aedc2b907a3d583bc53bea4649c2
2 * SPDX-License-Identifier: MIT
4 * Copyright (C) 2020 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
9 #ifndef _LTTNG_BITMAP_H
10 #define _LTTNG_BITMAP_H
12 #include <urcu/compiler.h>
13 #include <urcu/system.h>
14 #include <urcu/uatomic.h>
17 static inline void lttng_bitmap_index(unsigned int index
, unsigned int *word
,
20 *word
= index
/ CAA_BITS_PER_LONG
;
21 *bit
= index
% CAA_BITS_PER_LONG
;
24 static inline void lttng_bitmap_set_bit(unsigned int index
, unsigned long *p
)
26 unsigned int word
, bit
;
29 lttng_bitmap_index(index
, &word
, &bit
);
31 uatomic_or(p
+ word
, val
);
34 static inline void lttng_bitmap_clear_bit(unsigned int index
, unsigned long *p
)
36 unsigned int word
, bit
;
39 lttng_bitmap_index(index
, &word
, &bit
);
41 uatomic_and(p
+ word
, val
);
44 static inline bool lttng_bitmap_test_bit(unsigned int index
, unsigned long *p
)
46 unsigned int word
, bit
;
48 lttng_bitmap_index(index
, &word
, &bit
);
49 return (CMM_LOAD_SHARED(p
[word
]) >> bit
) & 0x1;
52 #endif /* _LTTNG_BITMAP_H */
This page took 0.04306 seconds and 4 git commands to generate.