Changeset View
Standalone View
sys/sys/bitset.h
Show First 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | |||||||||
#define __bitset_mask(_s, n) \ | #define __bitset_mask(_s, n) \ | ||||||||
(1UL << (__constexpr_cond(__bitset_words((_s)) == 1) ? \ | (1UL << (__constexpr_cond(__bitset_words((_s)) == 1) ? \ | ||||||||
(__size_t)(n) : ((n) % _BITSET_BITS))) | (__size_t)(n) : ((n) % _BITSET_BITS))) | ||||||||
#define __bitset_word(_s, n) \ | #define __bitset_word(_s, n) \ | ||||||||
(__constexpr_cond(__bitset_words((_s)) == 1) ? \ | (__constexpr_cond(__bitset_words((_s)) == 1) ? \ | ||||||||
0 : ((n) / _BITSET_BITS)) | 0 : ((n) / _BITSET_BITS)) | ||||||||
#define BIT_CLR(_s, n, p) \ | #define __BIT_CLR(_s, n, p) \ | ||||||||
((p)->__bits[__bitset_word(_s, n)] &= ~__bitset_mask((_s), (n))) | ((p)->__bits[__bitset_word(_s, n)] &= ~__bitset_mask((_s), (n))) | ||||||||
#define BIT_COPY(_s, f, t) (void)(*(t) = *(f)) | #define __BIT_COPY(_s, f, t) (void)(*(t) = *(f)) | ||||||||
#define BIT_ISSET(_s, n, p) \ | #define __BIT_ISSET(_s, n, p) \ | ||||||||
((((p)->__bits[__bitset_word(_s, n)] & __bitset_mask((_s), (n))) != 0)) | ((((p)->__bits[__bitset_word(_s, n)] & __bitset_mask((_s), (n))) != 0)) | ||||||||
#define BIT_SET(_s, n, p) \ | #define __BIT_SET(_s, n, p) \ | ||||||||
((p)->__bits[__bitset_word(_s, n)] |= __bitset_mask((_s), (n))) | ((p)->__bits[__bitset_word(_s, n)] |= __bitset_mask((_s), (n))) | ||||||||
#define BIT_ZERO(_s, p) do { \ | #define __BIT_ZERO(_s, p) do { \ | ||||||||
__size_t __i; \ | __size_t __i; \ | ||||||||
for (__i = 0; __i < __bitset_words((_s)); __i++) \ | for (__i = 0; __i < __bitset_words((_s)); __i++) \ | ||||||||
(p)->__bits[__i] = 0L; \ | (p)->__bits[__i] = 0L; \ | ||||||||
} while (0) | } while (0) | ||||||||
#define BIT_FILL(_s, p) do { \ | #define __BIT_FILL(_s, p) do { \ | ||||||||
__size_t __i; \ | __size_t __i; \ | ||||||||
for (__i = 0; __i < __bitset_words((_s)); __i++) \ | for (__i = 0; __i < __bitset_words((_s)); __i++) \ | ||||||||
(p)->__bits[__i] = -1L; \ | (p)->__bits[__i] = -1L; \ | ||||||||
} while (0) | } while (0) | ||||||||
#define BIT_SETOF(_s, n, p) do { \ | #define __BIT_SETOF(_s, n, p) do { \ | ||||||||
BIT_ZERO(_s, p); \ | __BIT_ZERO(_s, p); \ | ||||||||
(p)->__bits[__bitset_word(_s, n)] = __bitset_mask((_s), (n)); \ | (p)->__bits[__bitset_word(_s, n)] = __bitset_mask((_s), (n)); \ | ||||||||
} while (0) | } while (0) | ||||||||
/* Is p empty. */ | /* Is p empty. */ | ||||||||
#define BIT_EMPTY(_s, p) __extension__ ({ \ | #define __BIT_EMPTY(_s, p) __extension__ ({ \ | ||||||||
__size_t __i; \ | __size_t __i; \ | ||||||||
for (__i = 0; __i < __bitset_words((_s)); __i++) \ | for (__i = 0; __i < __bitset_words((_s)); __i++) \ | ||||||||
if ((p)->__bits[__i]) \ | if ((p)->__bits[__i]) \ | ||||||||
break; \ | break; \ | ||||||||
__i == __bitset_words((_s)); \ | __i == __bitset_words((_s)); \ | ||||||||
}) | }) | ||||||||
/* Is p full set. */ | /* Is p full set. */ | ||||||||
#define BIT_ISFULLSET(_s, p) __extension__ ({ \ | #define __BIT_ISFULLSET(_s, p) __extension__ ({ \ | ||||||||
__size_t __i; \ | __size_t __i; \ | ||||||||
for (__i = 0; __i < __bitset_words((_s)); __i++) \ | for (__i = 0; __i < __bitset_words((_s)); __i++) \ | ||||||||
if ((p)->__bits[__i] != (long)-1) \ | if ((p)->__bits[__i] != (long)-1) \ | ||||||||
break; \ | break; \ | ||||||||
__i == __bitset_words((_s)); \ | __i == __bitset_words((_s)); \ | ||||||||
}) | }) | ||||||||
/* Is c a subset of p. */ | /* Is c a subset of p. */ | ||||||||
#define BIT_SUBSET(_s, p, c) __extension__ ({ \ | #define __BIT_SUBSET(_s, p, c) __extension__ ({ \ | ||||||||
__size_t __i; \ | __size_t __i; \ | ||||||||
for (__i = 0; __i < __bitset_words((_s)); __i++) \ | for (__i = 0; __i < __bitset_words((_s)); __i++) \ | ||||||||
if (((c)->__bits[__i] & \ | if (((c)->__bits[__i] & \ | ||||||||
(p)->__bits[__i]) != \ | (p)->__bits[__i]) != \ | ||||||||
(c)->__bits[__i]) \ | (c)->__bits[__i]) \ | ||||||||
break; \ | break; \ | ||||||||
__i == __bitset_words((_s)); \ | __i == __bitset_words((_s)); \ | ||||||||
}) | }) | ||||||||
/* Are there any common bits between b & c? */ | /* Are there any common bits between b & c? */ | ||||||||
#define BIT_OVERLAP(_s, p, c) __extension__ ({ \ | #define __BIT_OVERLAP(_s, p, c) __extension__ ({ \ | ||||||||
__size_t __i; \ | __size_t __i; \ | ||||||||
for (__i = 0; __i < __bitset_words((_s)); __i++) \ | for (__i = 0; __i < __bitset_words((_s)); __i++) \ | ||||||||
if (((c)->__bits[__i] & \ | if (((c)->__bits[__i] & \ | ||||||||
(p)->__bits[__i]) != 0) \ | (p)->__bits[__i]) != 0) \ | ||||||||
break; \ | break; \ | ||||||||
__i != __bitset_words((_s)); \ | __i != __bitset_words((_s)); \ | ||||||||
}) | }) | ||||||||
/* Compare two sets, returns 0 if equal 1 otherwise. */ | /* Compare two sets, returns 0 if equal 1 otherwise. */ | ||||||||
#define BIT_CMP(_s, p, c) __extension__ ({ \ | #define __BIT_CMP(_s, p, c) __extension__ ({ \ | ||||||||
__size_t __i; \ | __size_t __i; \ | ||||||||
for (__i = 0; __i < __bitset_words((_s)); __i++) \ | for (__i = 0; __i < __bitset_words((_s)); __i++) \ | ||||||||
if (((c)->__bits[__i] != \ | if (((c)->__bits[__i] != \ | ||||||||
(p)->__bits[__i])) \ | (p)->__bits[__i])) \ | ||||||||
break; \ | break; \ | ||||||||
__i != __bitset_words((_s)); \ | __i != __bitset_words((_s)); \ | ||||||||
}) | }) | ||||||||
#define BIT_OR(_s, d, s) do { \ | #define __BIT_OR(_s, d, s) do { \ | ||||||||
__size_t __i; \ | __size_t __i; \ | ||||||||
for (__i = 0; __i < __bitset_words((_s)); __i++) \ | for (__i = 0; __i < __bitset_words((_s)); __i++) \ | ||||||||
(d)->__bits[__i] |= (s)->__bits[__i]; \ | (d)->__bits[__i] |= (s)->__bits[__i]; \ | ||||||||
} while (0) | } while (0) | ||||||||
#define BIT_OR2(_s, d, s1, s2) do { \ | #define __BIT_OR2(_s, d, s1, s2) do { \ | ||||||||
__size_t __i; \ | __size_t __i; \ | ||||||||
for (__i = 0; __i < __bitset_words((_s)); __i++) \ | for (__i = 0; __i < __bitset_words((_s)); __i++) \ | ||||||||
(d)->__bits[__i] = (s1)->__bits[__i] | (s2)->__bits[__i];\ | (d)->__bits[__i] = (s1)->__bits[__i] | (s2)->__bits[__i];\ | ||||||||
} while (0) | } while (0) | ||||||||
#define BIT_AND(_s, d, s) do { \ | #define __BIT_AND(_s, d, s) do { \ | ||||||||
__size_t __i; \ | __size_t __i; \ | ||||||||
for (__i = 0; __i < __bitset_words((_s)); __i++) \ | for (__i = 0; __i < __bitset_words((_s)); __i++) \ | ||||||||
(d)->__bits[__i] &= (s)->__bits[__i]; \ | (d)->__bits[__i] &= (s)->__bits[__i]; \ | ||||||||
} while (0) | } while (0) | ||||||||
#define BIT_AND2(_s, d, s1, s2) do { \ | #define __BIT_AND2(_s, d, s1, s2) do { \ | ||||||||
__size_t __i; \ | __size_t __i; \ | ||||||||
for (__i = 0; __i < __bitset_words((_s)); __i++) \ | for (__i = 0; __i < __bitset_words((_s)); __i++) \ | ||||||||
(d)->__bits[__i] = (s1)->__bits[__i] & (s2)->__bits[__i];\ | (d)->__bits[__i] = (s1)->__bits[__i] & (s2)->__bits[__i];\ | ||||||||
} while (0) | } while (0) | ||||||||
#define BIT_ANDNOT(_s, d, s) do { \ | #define __BIT_ANDNOT(_s, d, s) do { \ | ||||||||
__size_t __i; \ | __size_t __i; \ | ||||||||
for (__i = 0; __i < __bitset_words((_s)); __i++) \ | for (__i = 0; __i < __bitset_words((_s)); __i++) \ | ||||||||
(d)->__bits[__i] &= ~(s)->__bits[__i]; \ | (d)->__bits[__i] &= ~(s)->__bits[__i]; \ | ||||||||
} while (0) | } while (0) | ||||||||
#define BIT_ANDNOT2(_s, d, s1, s2) do { \ | #define __BIT_ANDNOT2(_s, d, s1, s2) do { \ | ||||||||
__size_t __i; \ | __size_t __i; \ | ||||||||
for (__i = 0; __i < __bitset_words((_s)); __i++) \ | for (__i = 0; __i < __bitset_words((_s)); __i++) \ | ||||||||
(d)->__bits[__i] = (s1)->__bits[__i] & ~(s2)->__bits[__i];\ | (d)->__bits[__i] = (s1)->__bits[__i] & ~(s2)->__bits[__i];\ | ||||||||
} while (0) | } while (0) | ||||||||
#define BIT_XOR(_s, d, s) do { \ | #define __BIT_XOR(_s, d, s) do { \ | ||||||||
__size_t __i; \ | __size_t __i; \ | ||||||||
for (__i = 0; __i < __bitset_words((_s)); __i++) \ | for (__i = 0; __i < __bitset_words((_s)); __i++) \ | ||||||||
(d)->__bits[__i] ^= (s)->__bits[__i]; \ | (d)->__bits[__i] ^= (s)->__bits[__i]; \ | ||||||||
} while (0) | } while (0) | ||||||||
#define BIT_XOR2(_s, d, s1, s2) do { \ | #define __BIT_XOR2(_s, d, s1, s2) do { \ | ||||||||
__size_t __i; \ | __size_t __i; \ | ||||||||
for (__i = 0; __i < __bitset_words((_s)); __i++) \ | for (__i = 0; __i < __bitset_words((_s)); __i++) \ | ||||||||
(d)->__bits[__i] = (s1)->__bits[__i] ^ (s2)->__bits[__i];\ | (d)->__bits[__i] = (s1)->__bits[__i] ^ (s2)->__bits[__i];\ | ||||||||
} while (0) | } while (0) | ||||||||
/* | /* | ||||||||
* Note, the atomic(9) API is not consistent between clear/set and | * Note, the atomic(9) API is not consistent between clear/set and | ||||||||
* testandclear/testandset in whether the value argument is a mask | * testandclear/testandset in whether the value argument is a mask | ||||||||
* or a bit index. | * or a bit index. | ||||||||
*/ | */ | ||||||||
#define BIT_CLR_ATOMIC(_s, n, p) \ | #define __BIT_CLR_ATOMIC(_s, n, p) \ | ||||||||
atomic_clear_long(&(p)->__bits[__bitset_word(_s, n)], \ | atomic_clear_long(&(p)->__bits[__bitset_word(_s, n)], \ | ||||||||
__bitset_mask((_s), n)) | __bitset_mask((_s), n)) | ||||||||
#define BIT_SET_ATOMIC(_s, n, p) \ | #define __BIT_SET_ATOMIC(_s, n, p) \ | ||||||||
atomic_set_long(&(p)->__bits[__bitset_word(_s, n)], \ | atomic_set_long(&(p)->__bits[__bitset_word(_s, n)], \ | ||||||||
__bitset_mask((_s), n)) | __bitset_mask((_s), n)) | ||||||||
#define BIT_SET_ATOMIC_ACQ(_s, n, p) \ | #define __BIT_SET_ATOMIC_ACQ(_s, n, p) \ | ||||||||
atomic_set_acq_long(&(p)->__bits[__bitset_word(_s, n)], \ | atomic_set_acq_long(&(p)->__bits[__bitset_word(_s, n)], \ | ||||||||
__bitset_mask((_s), n)) | __bitset_mask((_s), n)) | ||||||||
#define BIT_TEST_CLR_ATOMIC(_s, n, p) \ | #define __BIT_TEST_CLR_ATOMIC(_s, n, p) \ | ||||||||
(atomic_testandclear_long( \ | (atomic_testandclear_long( \ | ||||||||
&(p)->__bits[__bitset_word((_s), (n))], (n)) != 0) | &(p)->__bits[__bitset_word((_s), (n))], (n)) != 0) | ||||||||
#define BIT_TEST_SET_ATOMIC(_s, n, p) \ | #define __BIT_TEST_SET_ATOMIC(_s, n, p) \ | ||||||||
(atomic_testandset_long( \ | (atomic_testandset_long( \ | ||||||||
&(p)->__bits[__bitset_word((_s), (n))], (n)) != 0) | &(p)->__bits[__bitset_word((_s), (n))], (n)) != 0) | ||||||||
/* Convenience functions catering special cases. */ | /* Convenience functions catering special cases. */ | ||||||||
#define BIT_AND_ATOMIC(_s, d, s) do { \ | #define __BIT_AND_ATOMIC(_s, d, s) do { \ | ||||||||
__size_t __i; \ | __size_t __i; \ | ||||||||
for (__i = 0; __i < __bitset_words((_s)); __i++) \ | for (__i = 0; __i < __bitset_words((_s)); __i++) \ | ||||||||
atomic_clear_long(&(d)->__bits[__i], \ | atomic_clear_long(&(d)->__bits[__i], \ | ||||||||
~(s)->__bits[__i]); \ | ~(s)->__bits[__i]); \ | ||||||||
} while (0) | } while (0) | ||||||||
#define BIT_OR_ATOMIC(_s, d, s) do { \ | #define __BIT_OR_ATOMIC(_s, d, s) do { \ | ||||||||
__size_t __i; \ | __size_t __i; \ | ||||||||
for (__i = 0; __i < __bitset_words((_s)); __i++) \ | for (__i = 0; __i < __bitset_words((_s)); __i++) \ | ||||||||
atomic_set_long(&(d)->__bits[__i], \ | atomic_set_long(&(d)->__bits[__i], \ | ||||||||
(s)->__bits[__i]); \ | (s)->__bits[__i]); \ | ||||||||
} while (0) | } while (0) | ||||||||
#define BIT_COPY_STORE_REL(_s, f, t) do { \ | #define __BIT_COPY_STORE_REL(_s, f, t) do { \ | ||||||||
__size_t __i; \ | __size_t __i; \ | ||||||||
for (__i = 0; __i < __bitset_words((_s)); __i++) \ | for (__i = 0; __i < __bitset_words((_s)); __i++) \ | ||||||||
atomic_store_rel_long(&(t)->__bits[__i], \ | atomic_store_rel_long(&(t)->__bits[__i], \ | ||||||||
(f)->__bits[__i]); \ | (f)->__bits[__i]); \ | ||||||||
} while (0) | } while (0) | ||||||||
/* | /* | ||||||||
* Note that `start` and the returned value from BIT_FFS_AT are | * Note that `start` and the returned value from __BIT_FFS_AT are | ||||||||
* 1-based bit indices. | * 1-based bit indices. | ||||||||
*/ | */ | ||||||||
#define BIT_FFS_AT(_s, p, start) __extension__ ({ \ | #define __BIT_FFS_AT(_s, p, start) __extension__ ({ \ | ||||||||
__size_t __i; \ | __size_t __i; \ | ||||||||
long __bit, __mask; \ | long __bit, __mask; \ | ||||||||
\ | \ | ||||||||
__mask = ~0UL << ((start) % _BITSET_BITS); \ | __mask = ~0UL << ((start) % _BITSET_BITS); \ | ||||||||
__bit = 0; \ | __bit = 0; \ | ||||||||
for (__i = __bitset_word((_s), (start)); \ | for (__i = __bitset_word((_s), (start)); \ | ||||||||
__i < __bitset_words((_s)); \ | __i < __bitset_words((_s)); \ | ||||||||
__i++) { \ | __i++) { \ | ||||||||
if (((p)->__bits[__i] & __mask) != 0) { \ | if (((p)->__bits[__i] & __mask) != 0) { \ | ||||||||
__bit = ffsl((p)->__bits[__i] & __mask); \ | __bit = ffsl((p)->__bits[__i] & __mask); \ | ||||||||
__bit += __i * _BITSET_BITS; \ | __bit += __i * _BITSET_BITS; \ | ||||||||
break; \ | break; \ | ||||||||
} \ | } \ | ||||||||
__mask = ~0UL; \ | __mask = ~0UL; \ | ||||||||
} \ | } \ | ||||||||
__bit; \ | __bit; \ | ||||||||
}) | }) | ||||||||
#define BIT_FFS(_s, p) BIT_FFS_AT((_s), (p), 0) | #define __BIT_FFS(_s, p) __BIT_FFS_AT((_s), (p), 0) | ||||||||
#define BIT_FLS(_s, p) __extension__ ({ \ | #define __BIT_FLS(_s, p) __extension__ ({ \ | ||||||||
__size_t __i; \ | __size_t __i; \ | ||||||||
long __bit; \ | long __bit; \ | ||||||||
\ | \ | ||||||||
__bit = 0; \ | __bit = 0; \ | ||||||||
for (__i = __bitset_words((_s)); __i > 0; __i--) { \ | for (__i = __bitset_words((_s)); __i > 0; __i--) { \ | ||||||||
if ((p)->__bits[__i - 1] != 0) { \ | if ((p)->__bits[__i - 1] != 0) { \ | ||||||||
__bit = flsl((p)->__bits[__i - 1]); \ | __bit = flsl((p)->__bits[__i - 1]); \ | ||||||||
__bit += (__i - 1) * _BITSET_BITS; \ | __bit += (__i - 1) * _BITSET_BITS; \ | ||||||||
break; \ | break; \ | ||||||||
} \ | } \ | ||||||||
} \ | } \ | ||||||||
__bit; \ | __bit; \ | ||||||||
}) | }) | ||||||||
#define BIT_COUNT(_s, p) __extension__ ({ \ | #define __BIT_COUNT(_s, p) __extension__ ({ \ | ||||||||
__size_t __i; \ | __size_t __i; \ | ||||||||
long __count; \ | long __count; \ | ||||||||
\ | \ | ||||||||
__count = 0; \ | __count = 0; \ | ||||||||
for (__i = 0; __i < __bitset_words((_s)); __i++) \ | for (__i = 0; __i < __bitset_words((_s)); __i++) \ | ||||||||
__count += __bitcountl((p)->__bits[__i]); \ | __count += __bitcountl((p)->__bits[__i]); \ | ||||||||
__count; \ | __count; \ | ||||||||
}) | }) | ||||||||
#define _BIT_FOREACH_ADVANCE(_s, i, p, op) __extension__ ({ \ | #define __BIT_FOREACH_ADVANCE(_s, i, p, op) __extension__ ({ \ | ||||||||
int __found; \ | int __found; \ | ||||||||
for (;;) { \ | for (;;) { \ | ||||||||
if (__bits != 0) { \ | if (__bits != 0) { \ | ||||||||
int __bit = ffsl(__bits) - 1; \ | int __bit = ffsl(__bits) - 1; \ | ||||||||
__bits &= ~(1ul << __bit); \ | __bits &= ~(1ul << __bit); \ | ||||||||
(i) = __i * _BITSET_BITS + __bit; \ | (i) = __i * _BITSET_BITS + __bit; \ | ||||||||
__found = 1; \ | __found = 1; \ | ||||||||
break; \ | break; \ | ||||||||
} \ | } \ | ||||||||
if (++__i == __bitset_words(_s)) { \ | if (++__i == __bitset_words(_s)) { \ | ||||||||
__found = 0; \ | __found = 0; \ | ||||||||
break; \ | break; \ | ||||||||
} \ | } \ | ||||||||
__bits = op((p)->__bits[__i]); \ | __bits = op((p)->__bits[__i]); \ | ||||||||
} \ | } \ | ||||||||
__found != 0; \ | __found != 0; \ | ||||||||
}) | }) | ||||||||
/* | /* | ||||||||
* Non-destructively loop over all set or clear bits in the set. | * Non-destructively loop over all set or clear bits in the set. | ||||||||
*/ | */ | ||||||||
#define _BIT_FOREACH(_s, i, p, op) \ | #define __BIT_FOREACH(_s, i, p, op) \ | ||||||||
for (long __i = -1, __bits = 0; \ | for (long __i = -1, __bits = 0; \ | ||||||||
_BIT_FOREACH_ADVANCE(_s, i, p, op); ) | __BIT_FOREACH_ADVANCE(_s, i, p, op); ) | ||||||||
#define BIT_FOREACH_ISSET(_s, i, p) _BIT_FOREACH(_s, i, p, ) | #define __BIT_FOREACH_ISSET(_s, i, p) __BIT_FOREACH(_s, i, p, ) | ||||||||
#define BIT_FOREACH_ISCLR(_s, i, p) _BIT_FOREACH(_s, i, p, ~) | #define __BIT_FOREACH_ISCLR(_s, i, p) __BIT_FOREACH(_s, i, p, ~) | ||||||||
#define BITSET_T_INITIALIZER(x) \ | #define BITSET_T_INITIALIZER(x) \ | ||||||||
{ .__bits = { x } } | { .__bits = { x } } | ||||||||
#define BITSET_FSET(n) \ | #define BITSET_FSET(n) \ | ||||||||
[ 0 ... ((n) - 1) ] = (-1L) | [ 0 ... ((n) - 1) ] = (-1L) | ||||||||
#define BITSET_SIZE(_s) (__bitset_words((_s)) * sizeof(long)) | #define BITSET_SIZE(_s) (__bitset_words((_s)) * sizeof(long)) | ||||||||
/* | /* | ||||||||
* Dynamically allocate a bitset. | * Dynamically allocate a bitset. | ||||||||
*/ | */ | ||||||||
#define BITSET_ALLOC(_s, mt, mf) malloc(BITSET_SIZE((_s)), mt, (mf)) | #define BITSET_ALLOC(_s, mt, mf) malloc(BITSET_SIZE((_s)), mt, (mf)) | ||||||||
kib: Shouldn't these symbols (BITSET_XXX) hidden as well? | |||||||||
seAuthorUnsubmitted Done Inline ActionsI was not sure whether those are conflicting, but did expect only the BIT_* to be an issue. se: I was not sure whether those are conflicting, but did expect only the BIT_* to be an issue.
If… | |||||||||
kibUnsubmitted Not Done Inline ActionsThe problem there is any user' namespace pollution. It is somewhat strange to fix some, but leave other. kib: The problem there is any user' namespace pollution. It is somewhat strange to fix some, but… | |||||||||
#ifdef _KERNEL | |||||||||
kibUnsubmitted Not Done Inline ActionsYou may do #if defined(_KERNEL) || defined(_WANT_FREEBSD_BIT) there, and then #define _WANT_FREEBSD_BIT in consumers allows to avoid manual redefinition of BIT_ for src/. kib: You may do `#if defined(_KERNEL) || defined(_WANT_FREEBSD_BIT)` there, and then #define… | |||||||||
seAuthorUnsubmitted Done Inline ActionsYes, good idea - I'll wait for further comments and then upload another patch-set. se: Yes, good idea - I'll wait for further comments and then upload another patch-set. | |||||||||
#define BIT_AND __BIT_AND | |||||||||
Not Done Inline ActionsWouldn't it be easier for compiler to check the correctness if BIT_ macros were functional, i.e. not just redefine symbols, but define them as argument-passing macros? #define BIT_AND(_s, d, s) __BIT_AND(_s, d, s) is what I mean. kib: Wouldn't it be easier for compiler to check the correctness if BIT_ macros were functional, i.e. | |||||||||
Done Inline Actions
Sure, I'd been hoping to get away with the non-functional definitions - next patch will have arguments added. se: > Wouldn't it be easier for compiler to check the correctness if BIT_ macros were functional, i. | |||||||||
#define BIT_AND2 __BIT_AND2 | |||||||||
#define BIT_ANDNOT __BIT_ANDNOT | |||||||||
#define BIT_ANDNOT2 __BIT_ANDNOT2 | |||||||||
#define BIT_AND_ATOMIC __BIT_AND_ATOMIC | |||||||||
#define BIT_CLR __BIT_CLR | |||||||||
#define BIT_CLR_ATOMIC __BIT_CLR_ATOMIC | |||||||||
#define BIT_CMP __BIT_CMP | |||||||||
#define BIT_COPY __BIT_COPY | |||||||||
#define BIT_COPY_STORE_REL __BIT_COPY_STORE_REL | |||||||||
#define BIT_COUNT __BIT_COUNT | |||||||||
#define BIT_EMPTY __BIT_EMPTY | |||||||||
#define BIT_FFS __BIT_FFS | |||||||||
#define BIT_FFS_AT __BIT_FFS_AT | |||||||||
#define BIT_FILL __BIT_FILL | |||||||||
#define BIT_FLS __BIT_FLS | |||||||||
#define BIT_FOREACH_ADVANCE __BIT_FOREACH_ADVANCE | |||||||||
#define BIT_FOREACH_ISCLR __BIT_FOREACH_ISCLR | |||||||||
#define BIT_FOREACH_ISSET __BIT_FOREACH_ISSET | |||||||||
#define BIT_ISFULLSET __BIT_ISFULLSET | |||||||||
#define BIT_ISSET __BIT_ISSET | |||||||||
#define BIT_OR __BIT_OR | |||||||||
#define BIT_OR2 __BIT_OR2 | |||||||||
#define BIT_OR_ATOMIC __BIT_OR_ATOMIC | |||||||||
#define BIT_OVERLAP __BIT_OVERLAP | |||||||||
#define BIT_SET __BIT_SET | |||||||||
#define BIT_SETOF __BIT_SETOF | |||||||||
#define BIT_SET_ATOMI __BIT_SET_ATOMIC | |||||||||
Done Inline Actions
markj: | |||||||||
#define BIT_SET_ATOMIC_ACQ __BIT_SET_ATOMIC_ACQ | |||||||||
#define BIT_SUBSET __BIT_SUBSET | |||||||||
#define BIT_TEST_CLR_ATOMIC __BIT_TEST_CLR_ATOMIC | |||||||||
#define BIT_TEST_SET_ATOMIC __BIT_TEST_SET_ATOMIC | |||||||||
#define BIT_XOR __BIT_XOR | |||||||||
#define BIT_XOR2 __BIT_XOR2 | |||||||||
#define BIT_ZERO __BIT_ZERO | |||||||||
#endif | |||||||||
#endif /* !_SYS_BITSET_H_ */ | #endif /* !_SYS_BITSET_H_ */ |
Shouldn't these symbols (BITSET_XXX) hidden as well?