diff --git a/include/sched.h b/include/sched.h --- a/include/sched.h +++ b/include/sched.h @@ -33,20 +33,16 @@ #include #include #if __BSD_VISIBLE -#ifdef _WITH_CPU_SET_T #include struct _cpuset; typedef struct _cpuset cpu_set_t; -#endif /* _WITH_CPU_SET_T */ #endif /* __BSD_VISIBLE */ __BEGIN_DECLS #if __BSD_VISIBLE -#ifdef _WITH_CPU_SET_T int sched_getaffinity(pid_t pid, size_t cpusetsz, cpuset_t *cpuset); int sched_setaffinity(int pid, size_t cpusetsz, const cpuset_t *cpuset); int sched_getcpu(void); -#endif /* _WITH_CPU_SET_T */ #endif /* __BSD_VISIBLE */ __END_DECLS diff --git a/lib/libmemstat/memstat_uma.c b/lib/libmemstat/memstat_uma.c --- a/lib/libmemstat/memstat_uma.c +++ b/lib/libmemstat/memstat_uma.c @@ -28,6 +28,8 @@ * $FreeBSD$ */ +#define _WANT_FREEBSD_BITSET + #include #include #include diff --git a/sbin/pfctl/pfctl_altq.c b/sbin/pfctl/pfctl_altq.c --- a/sbin/pfctl/pfctl_altq.c +++ b/sbin/pfctl/pfctl_altq.c @@ -22,6 +22,7 @@ __FBSDID("$FreeBSD$"); #define PFIOC_USE_LATEST +#define _WANT_FREEBSD_BITSET #include #include diff --git a/sbin/pfctl/pfctl_parser.h b/sbin/pfctl/pfctl_parser.h --- a/sbin/pfctl/pfctl_parser.h +++ b/sbin/pfctl/pfctl_parser.h @@ -184,7 +184,7 @@ }; #define QPRI_BITSET_SIZE 256 -BITSET_DEFINE(qpri_bitset, QPRI_BITSET_SIZE); +__BITSET_DEFINE(qpri_bitset, QPRI_BITSET_SIZE); LIST_HEAD(gen_sc, segment); struct pfctl_altq { diff --git a/share/man/man9/bitset.9 b/share/man/man9/bitset.9 --- a/share/man/man9/bitset.9 +++ b/share/man/man9/bitset.9 @@ -164,6 +164,7 @@ .Fo BIT_COPY_STORE_REL .Fa "const SETSIZE" "struct STRUCTNAME *from" "struct STRUCTNAME *to" .Fc +.Fd #define _WANT_FREEBSD_BITSET .Sh DESCRIPTION The .Nm @@ -179,6 +180,16 @@ is .In sys/cpuset.h . .Pp +These macros are meant to be used in the kernel and are visible if +.Dv _KERNEL is defined when +.In sys/_bitset.h +or +.In sys/bitset.h +are included in a program. +Userland programs must define +.Dv _WANT_FREEBSD_BITSET +before including these files to make the macros visible. +.Pp The .Fn BITSET_DEFINE macro defines a bitset struct @@ -584,3 +595,17 @@ and .Fn BIT_FLS return a one-indexed result (or zero if the set is empty). +.Pp +In order to use the macros defined in +.In sys/bitset.h +and +.In sys/_bitset.h +in userland programs, +.Dv _WANT_FREEBSD_BITSET +has to be defined before including the header files. +This requirements exists to prevent a name space pollution due to macros defined in +.Nm +in programs that include +.In sys/cpuset.h +or +.In sched.h . diff --git a/sys/sys/_bitset.h b/sys/sys/_bitset.h --- a/sys/sys/_bitset.h +++ b/sys/sys/_bitset.h @@ -44,8 +44,8 @@ #define __bitset_words(_s) (__howmany(_s, _BITSET_BITS)) -#define BITSET_DEFINE(t, _s) \ -struct t { \ +#define __BITSET_DEFINE(_t, _s) \ +struct _t { \ long __bits[__bitset_words((_s))]; \ } @@ -55,12 +55,17 @@ * Sadly we cannot declare a bitset struct with '__bits[]', because it's * the only member of the struct and the compiler complains. */ -#define BITSET_DEFINE_VAR(t) BITSET_DEFINE(t, 1) +#define __BITSET_DEFINE_VAR(_t) __BITSET_DEFINE(_t, 1) /* * Define a default type that can be used while manually specifying size * to every call. */ -BITSET_DEFINE(bitset, 1); +__BITSET_DEFINE(bitset, 1); + +#if defined(_KERNEL) || defined(_WANT_FREEBSD_BITSET) +#define BITSET_DEFINE(_t, _s) __BITSET_DEFINE(_t, _s) +#define BITSET_DEFINE_VAR(_t) __BITSET_DEFINE_VAR(_t) +#endif #endif /* !_SYS__BITSET_H_ */ diff --git a/sys/sys/_cpuset.h b/sys/sys/_cpuset.h --- a/sys/sys/_cpuset.h +++ b/sys/sys/_cpuset.h @@ -46,7 +46,7 @@ #define CPU_SETSIZE CPU_MAXSIZE #endif -BITSET_DEFINE(_cpuset, CPU_SETSIZE); +__BITSET_DEFINE(_cpuset, CPU_SETSIZE); typedef struct _cpuset cpuset_t; #endif /* !_SYS__CPUSET_H_ */ diff --git a/sys/sys/_domainset.h b/sys/sys/_domainset.h --- a/sys/sys/_domainset.h +++ b/sys/sys/_domainset.h @@ -43,7 +43,7 @@ #define DOMAINSET_SETSIZE DOMAINSET_MAXSIZE #endif -BITSET_DEFINE(_domainset, DOMAINSET_SETSIZE); +__BITSET_DEFINE(_domainset, DOMAINSET_SETSIZE); typedef struct _domainset domainset_t; /* diff --git a/sys/sys/bitset.h b/sys/sys/bitset.h --- a/sys/sys/bitset.h +++ b/sys/sys/bitset.h @@ -48,36 +48,36 @@ (__constexpr_cond(__bitset_words((_s)) == 1) ? \ 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))) -#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)) -#define BIT_SET(_s, n, p) \ +#define __BIT_SET(_s, n, p) \ ((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; \ for (__i = 0; __i < __bitset_words((_s)); __i++) \ (p)->__bits[__i] = 0L; \ } while (0) -#define BIT_FILL(_s, p) do { \ +#define __BIT_FILL(_s, p) do { \ __size_t __i; \ for (__i = 0; __i < __bitset_words((_s)); __i++) \ (p)->__bits[__i] = -1L; \ } while (0) -#define BIT_SETOF(_s, n, p) do { \ - BIT_ZERO(_s, p); \ +#define __BIT_SETOF(_s, n, p) do { \ + __BIT_ZERO(_s, p); \ (p)->__bits[__bitset_word(_s, n)] = __bitset_mask((_s), (n)); \ } while (0) /* Is p empty. */ -#define BIT_EMPTY(_s, p) __extension__ ({ \ +#define __BIT_EMPTY(_s, p) __extension__ ({ \ __size_t __i; \ for (__i = 0; __i < __bitset_words((_s)); __i++) \ if ((p)->__bits[__i]) \ @@ -86,7 +86,7 @@ }) /* Is p full set. */ -#define BIT_ISFULLSET(_s, p) __extension__ ({ \ +#define __BIT_ISFULLSET(_s, p) __extension__ ({ \ __size_t __i; \ for (__i = 0; __i < __bitset_words((_s)); __i++) \ if ((p)->__bits[__i] != (long)-1) \ @@ -95,7 +95,7 @@ }) /* Is c a subset of p. */ -#define BIT_SUBSET(_s, p, c) __extension__ ({ \ +#define __BIT_SUBSET(_s, p, c) __extension__ ({ \ __size_t __i; \ for (__i = 0; __i < __bitset_words((_s)); __i++) \ if (((c)->__bits[__i] & \ @@ -106,7 +106,7 @@ }) /* 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; \ for (__i = 0; __i < __bitset_words((_s)); __i++) \ if (((c)->__bits[__i] & \ @@ -116,7 +116,7 @@ }) /* 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; \ for (__i = 0; __i < __bitset_words((_s)); __i++) \ if (((c)->__bits[__i] != \ @@ -125,49 +125,49 @@ __i != __bitset_words((_s)); \ }) -#define BIT_OR(_s, d, s) do { \ +#define __BIT_OR(_s, d, s) do { \ __size_t __i; \ for (__i = 0; __i < __bitset_words((_s)); __i++) \ (d)->__bits[__i] |= (s)->__bits[__i]; \ } while (0) -#define BIT_OR2(_s, d, s1, s2) do { \ +#define __BIT_OR2(_s, d, s1, s2) do { \ __size_t __i; \ for (__i = 0; __i < __bitset_words((_s)); __i++) \ (d)->__bits[__i] = (s1)->__bits[__i] | (s2)->__bits[__i];\ } while (0) -#define BIT_AND(_s, d, s) do { \ +#define __BIT_AND(_s, d, s) do { \ __size_t __i; \ for (__i = 0; __i < __bitset_words((_s)); __i++) \ (d)->__bits[__i] &= (s)->__bits[__i]; \ } while (0) -#define BIT_AND2(_s, d, s1, s2) do { \ +#define __BIT_AND2(_s, d, s1, s2) do { \ __size_t __i; \ for (__i = 0; __i < __bitset_words((_s)); __i++) \ (d)->__bits[__i] = (s1)->__bits[__i] & (s2)->__bits[__i];\ } while (0) -#define BIT_ANDNOT(_s, d, s) do { \ +#define __BIT_ANDNOT(_s, d, s) do { \ __size_t __i; \ for (__i = 0; __i < __bitset_words((_s)); __i++) \ (d)->__bits[__i] &= ~(s)->__bits[__i]; \ } while (0) -#define BIT_ANDNOT2(_s, d, s1, s2) do { \ +#define __BIT_ANDNOT2(_s, d, s1, s2) do { \ __size_t __i; \ for (__i = 0; __i < __bitset_words((_s)); __i++) \ (d)->__bits[__i] = (s1)->__bits[__i] & ~(s2)->__bits[__i];\ } while (0) -#define BIT_XOR(_s, d, s) do { \ +#define __BIT_XOR(_s, d, s) do { \ __size_t __i; \ for (__i = 0; __i < __bitset_words((_s)); __i++) \ (d)->__bits[__i] ^= (s)->__bits[__i]; \ } while (0) -#define BIT_XOR2(_s, d, s1, s2) do { \ +#define __BIT_XOR2(_s, d, s1, s2) do { \ __size_t __i; \ for (__i = 0; __i < __bitset_words((_s)); __i++) \ (d)->__bits[__i] = (s1)->__bits[__i] ^ (s2)->__bits[__i];\ @@ -179,42 +179,42 @@ * 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)], \ __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)], \ __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)], \ __bitset_mask((_s), n)) -#define BIT_TEST_CLR_ATOMIC(_s, n, p) \ +#define __BIT_TEST_CLR_ATOMIC(_s, n, p) \ (atomic_testandclear_long( \ &(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( \ &(p)->__bits[__bitset_word((_s), (n))], (n)) != 0) /* Convenience functions catering special cases. */ -#define BIT_AND_ATOMIC(_s, d, s) do { \ +#define __BIT_AND_ATOMIC(_s, d, s) do { \ __size_t __i; \ for (__i = 0; __i < __bitset_words((_s)); __i++) \ atomic_clear_long(&(d)->__bits[__i], \ ~(s)->__bits[__i]); \ } while (0) -#define BIT_OR_ATOMIC(_s, d, s) do { \ +#define __BIT_OR_ATOMIC(_s, d, s) do { \ __size_t __i; \ for (__i = 0; __i < __bitset_words((_s)); __i++) \ atomic_set_long(&(d)->__bits[__i], \ (s)->__bits[__i]); \ } while (0) -#define BIT_COPY_STORE_REL(_s, f, t) do { \ +#define __BIT_COPY_STORE_REL(_s, f, t) do { \ __size_t __i; \ for (__i = 0; __i < __bitset_words((_s)); __i++) \ atomic_store_rel_long(&(t)->__bits[__i], \ @@ -222,10 +222,10 @@ } 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. */ -#define BIT_FFS_AT(_s, p, start) __extension__ ({ \ +#define __BIT_FFS_AT(_s, p, start) __extension__ ({ \ __size_t __i; \ long __bit, __mask; \ \ @@ -244,9 +244,9 @@ __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; \ long __bit; \ \ @@ -261,7 +261,7 @@ __bit; \ }) -#define BIT_COUNT(_s, p) __extension__ ({ \ +#define __BIT_COUNT(_s, p) __extension__ ({ \ __size_t __i; \ long __count; \ \ @@ -271,7 +271,7 @@ __count; \ }) -#define _BIT_FOREACH_ADVANCE(_s, i, p, op) __extension__ ({ \ +#define __BIT_FOREACH_ADVANCE(_s, i, p, op) __extension__ ({ \ int __found; \ for (;;) { \ if (__bits != 0) { \ @@ -293,24 +293,68 @@ /* * 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; \ - _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_ISCLR(_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 BITSET_T_INITIALIZER(x) \ +#define __BITSET_T_INITIALIZER(x) \ { .__bits = { x } } -#define BITSET_FSET(n) \ +#define __BITSET_FSET(n) \ [ 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. */ -#define BITSET_ALLOC(_s, mt, mf) malloc(BITSET_SIZE((_s)), mt, (mf)) +#define __BITSET_ALLOC(_s, mt, mf) malloc(__BITSET_SIZE((_s)), mt, (mf)) + +#if defined(_KERNEL) || defined(_WANT_FREEBSD_BITSET) +#define BIT_AND(_s, d, s) __BIT_AND(_s, d, s) +#define BIT_AND2(_s, d, s1, s2) __BIT_AND2(_s, d, s1, s2) +#define BIT_ANDNOT(_s, d, s) __BIT_ANDNOT(_s, d, s) +#define BIT_ANDNOT2(_s, d, s1, s2) __BIT_ANDNOT2(_s, d, s1, s2) +#define BIT_AND_ATOMIC(_s, d, s) __BIT_AND_ATOMIC(_s, d, s) +#define BIT_CLR(_s, n, p) __BIT_CLR(_s, n, p) +#define BIT_CLR_ATOMIC(_s, n, p) __BIT_CLR_ATOMIC(_s, n, p) +#define BIT_CMP(_s, p, c) __BIT_CMP(_s, p, c) +#define BIT_COPY(_s, f, t) __BIT_COPY(_s, f, t) +#define BIT_COPY_STORE_REL(_s, f, t) __BIT_COPY_STORE_REL(_s, f, t) +#define BIT_COUNT(_s, p) __BIT_COUNT(_s, p) +#define BIT_EMPTY(_s, p) __BIT_EMPTY(_s, p) +#define BIT_FFS(_s, p) __BIT_FFS(_s, p) +#define BIT_FFS_AT(_s, p, start) __BIT_FFS_AT(_s, p, start) +#define BIT_FILL(_s, p) __BIT_FILL(_s, p) +#define BIT_FLS(_s, p) __BIT_FLS(_s, p) +#define BIT_FOREACH(_s, i, p, op) __BIT_FOREACH(_s, i, p, op) +#define BIT_FOREACH_ADVANCE(_s, i, p, op) __BIT_FOREACH_ADVANCE(_s, i, p, op) +#define BIT_FOREACH_ISCLR(_s, i, p) __BIT_FOREACH_ISCLR(_s, i, p) +#define BIT_FOREACH_ISSET(_s, i, p) __BIT_FOREACH_ISSET(_s, i, p) +#define BIT_ISFULLSET(_s, p) __BIT_ISFULLSET(_s, p) +#define BIT_ISSET(_s, n, p) __BIT_ISSET(_s, n, p) +#define BIT_OR(_s, d, s) __BIT_OR(_s, d, s) +#define BIT_OR2(_s, d, s1, s2) __BIT_OR2(_s, d, s1, s2) +#define BIT_OR_ATOMIC(_s, d, s) __BIT_OR_ATOMIC(_s, d, s) +#define BIT_OVERLAP(_s, p, c) __BIT_OVERLAP(_s, p, c) +#define BIT_SET(_s, n, p) __BIT_SET(_s, n, p) +#define BIT_SETOF(_s, n, p) __BIT_SETOF(_s, n, p) +#define BIT_SET_ATOMIC(_s, n, p) __BIT_SET_ATOMIC(_s, n, p) +#define BIT_SET_ATOMIC_ACQ(_s, n, p) __BIT_SET_ATOMIC_ACQ(_s, n, p) +#define BIT_SUBSET(_s, p, c) __BIT_SUBSET(_s, p, c) +#define BIT_TEST_CLR_ATOMIC(_s, n, p) __BIT_TEST_CLR_ATOMIC(_s, n, p) +#define BIT_TEST_SET_ATOMIC(_s, n, p) __BIT_TEST_SET_ATOMIC(_s, n, p) +#define BIT_XOR(_s, d, s) __BIT_XOR(_s, d, s) +#define BIT_XOR2(_s, d, s1, s2) __BIT_XOR2(_s, d, s1, s2) +#define BIT_ZERO(_s, p) __BIT_ZERO(_s, p) + +#define BITSET_ALLOC(_s, mt, mf) __BITSET_ALLOC(_s, mt, mf) +#define BITSET_FSET(n) __BITSET_FSET(n) +#define BITSET_SIZE(_s) __BITSET_SIZE(_s) +#define BITSET_T_INITIALIZER(x) __BITSET_T_INITIALIZER(x) +#endif #endif /* !_SYS_BITSET_H_ */ diff --git a/sys/sys/cpuset.h b/sys/sys/cpuset.h --- a/sys/sys/cpuset.h +++ b/sys/sys/cpuset.h @@ -43,35 +43,35 @@ #define CPUSETBUFSIZ ((2 + sizeof(long) * 2) * _NCPUWORDS) -#define CPU_CLR(n, p) BIT_CLR(CPU_SETSIZE, n, p) -#define CPU_COPY(f, t) BIT_COPY(CPU_SETSIZE, f, t) -#define CPU_ISSET(n, p) BIT_ISSET(CPU_SETSIZE, n, p) -#define CPU_SET(n, p) BIT_SET(CPU_SETSIZE, n, p) -#define CPU_ZERO(p) BIT_ZERO(CPU_SETSIZE, p) -#define CPU_FILL(p) BIT_FILL(CPU_SETSIZE, p) -#define CPU_SETOF(n, p) BIT_SETOF(CPU_SETSIZE, n, p) -#define CPU_EQUAL(p, c) (BIT_CMP(CPU_SETSIZE, p, c) == 0) -#define CPU_EMPTY(p) BIT_EMPTY(CPU_SETSIZE, p) -#define CPU_ISFULLSET(p) BIT_ISFULLSET(CPU_SETSIZE, p) -#define CPU_SUBSET(p, c) BIT_SUBSET(CPU_SETSIZE, p, c) -#define CPU_OVERLAP(p, c) BIT_OVERLAP(CPU_SETSIZE, p, c) -#define CPU_CMP(p, c) BIT_CMP(CPU_SETSIZE, p, c) -#define CPU_OR(d, s) BIT_OR(CPU_SETSIZE, d, s) -#define CPU_AND(d, s) BIT_AND(CPU_SETSIZE, d, s) -#define CPU_ANDNOT(d, s) BIT_ANDNOT(CPU_SETSIZE, d, s) -#define CPU_CLR_ATOMIC(n, p) BIT_CLR_ATOMIC(CPU_SETSIZE, n, p) -#define CPU_SET_ATOMIC(n, p) BIT_SET_ATOMIC(CPU_SETSIZE, n, p) -#define CPU_SET_ATOMIC_ACQ(n, p) BIT_SET_ATOMIC_ACQ(CPU_SETSIZE, n, p) -#define CPU_AND_ATOMIC(n, p) BIT_AND_ATOMIC(CPU_SETSIZE, n, p) -#define CPU_OR_ATOMIC(d, s) BIT_OR_ATOMIC(CPU_SETSIZE, d, s) -#define CPU_COPY_STORE_REL(f, t) BIT_COPY_STORE_REL(CPU_SETSIZE, f, t) -#define CPU_FFS(p) BIT_FFS(CPU_SETSIZE, p) -#define CPU_FLS(p) BIT_FLS(CPU_SETSIZE, p) -#define CPU_FOREACH_ISSET(i, p) BIT_FOREACH_ISSET(CPU_SETSIZE, i, p) -#define CPU_FOREACH_ISCLR(i, p) BIT_FOREACH_ISCLR(CPU_SETSIZE, i, p) -#define CPU_COUNT(p) ((int)BIT_COUNT(CPU_SETSIZE, p)) -#define CPUSET_FSET BITSET_FSET(_NCPUWORDS) -#define CPUSET_T_INITIALIZER BITSET_T_INITIALIZER +#define CPU_CLR(n, p) __BIT_CLR(CPU_SETSIZE, n, p) +#define CPU_COPY(f, t) __BIT_COPY(CPU_SETSIZE, f, t) +#define CPU_ISSET(n, p) __BIT_ISSET(CPU_SETSIZE, n, p) +#define CPU_SET(n, p) __BIT_SET(CPU_SETSIZE, n, p) +#define CPU_ZERO(p) __BIT_ZERO(CPU_SETSIZE, p) +#define CPU_FILL(p) __BIT_FILL(CPU_SETSIZE, p) +#define CPU_SETOF(n, p) __BIT_SETOF(CPU_SETSIZE, n, p) +#define CPU_EQUAL(p, c) (__BIT_CMP(CPU_SETSIZE, p, c) == 0) +#define CPU_EMPTY(p) __BIT_EMPTY(CPU_SETSIZE, p) +#define CPU_ISFULLSET(p) __BIT_ISFULLSET(CPU_SETSIZE, p) +#define CPU_SUBSET(p, c) __BIT_SUBSET(CPU_SETSIZE, p, c) +#define CPU_OVERLAP(p, c) __BIT_OVERLAP(CPU_SETSIZE, p, c) +#define CPU_CMP(p, c) __BIT_CMP(CPU_SETSIZE, p, c) +#define CPU_OR(d, s) __BIT_OR(CPU_SETSIZE, d, s) +#define CPU_AND(d, s) __BIT_AND(CPU_SETSIZE, d, s) +#define CPU_ANDNOT(d, s) __BIT_ANDNOT(CPU_SETSIZE, d, s) +#define CPU_CLR_ATOMIC(n, p) __BIT_CLR_ATOMIC(CPU_SETSIZE, n, p) +#define CPU_SET_ATOMIC(n, p) __BIT_SET_ATOMIC(CPU_SETSIZE, n, p) +#define CPU_SET_ATOMIC_ACQ(n, p) __BIT_SET_ATOMIC_ACQ(CPU_SETSIZE, n, p) +#define CPU_AND_ATOMIC(n, p) __BIT_AND_ATOMIC(CPU_SETSIZE, n, p) +#define CPU_OR_ATOMIC(d, s) __BIT_OR_ATOMIC(CPU_SETSIZE, d, s) +#define CPU_COPY_STORE_REL(f, t) __BIT_COPY_STORE_REL(CPU_SETSIZE, f, t) +#define CPU_FFS(p) __BIT_FFS(CPU_SETSIZE, p) +#define CPU_FLS(p) __BIT_FLS(CPU_SETSIZE, p) +#define CPU_FOREACH_ISSET(i, p) __BIT_FOREACH_ISSET(CPU_SETSIZE, i, p) +#define CPU_FOREACH_ISCLR(i, p) __BIT_FOREACH_ISCLR(CPU_SETSIZE, i, p) +#define CPU_COUNT(p) ((int)__BIT_COUNT(CPU_SETSIZE, p)) +#define CPUSET_FSET __BITSET_FSET(_NCPUWORDS) +#define CPUSET_T_INITIALIZER(x) __BITSET_T_INITIALIZER(x) /* * Valid cpulevel_t values. diff --git a/sys/sys/domainset.h b/sys/sys/domainset.h --- a/sys/sys/domainset.h +++ b/sys/sys/domainset.h @@ -43,34 +43,34 @@ sizeof("::") + sizeof(__XSTRING(DOMAINSET_POLICY_MAX)) + \ sizeof(__XSTRING(MAXMEMDOM))) -#define DOMAINSET_CLR(n, p) BIT_CLR(DOMAINSET_SETSIZE, n, p) -#define DOMAINSET_COPY(f, t) BIT_COPY(DOMAINSET_SETSIZE, f, t) -#define DOMAINSET_ISSET(n, p) BIT_ISSET(DOMAINSET_SETSIZE, n, p) -#define DOMAINSET_SET(n, p) BIT_SET(DOMAINSET_SETSIZE, n, p) -#define DOMAINSET_ZERO(p) BIT_ZERO(DOMAINSET_SETSIZE, p) -#define DOMAINSET_FILL(p) BIT_FILL(DOMAINSET_SETSIZE, p) -#define DOMAINSET_SETOF(n, p) BIT_SETOF(DOMAINSET_SETSIZE, n, p) -#define DOMAINSET_EMPTY(p) BIT_EMPTY(DOMAINSET_SETSIZE, p) -#define DOMAINSET_ISFULLSET(p) BIT_ISFULLSET(DOMAINSET_SETSIZE, p) -#define DOMAINSET_SUBSET(p, c) BIT_SUBSET(DOMAINSET_SETSIZE, p, c) -#define DOMAINSET_OVERLAP(p, c) BIT_OVERLAP(DOMAINSET_SETSIZE, p, c) -#define DOMAINSET_CMP(p, c) BIT_CMP(DOMAINSET_SETSIZE, p, c) -#define DOMAINSET_OR(d, s) BIT_OR(DOMAINSET_SETSIZE, d, s) -#define DOMAINSET_AND(d, s) BIT_AND(DOMAINSET_SETSIZE, d, s) -#define DOMAINSET_ANDNOT(d, s) BIT_ANDNOT(DOMAINSET_SETSIZE, d, s) -#define DOMAINSET_CLR_ATOMIC(n, p) BIT_CLR_ATOMIC(DOMAINSET_SETSIZE, n, p) -#define DOMAINSET_SET_ATOMIC(n, p) BIT_SET_ATOMIC(DOMAINSET_SETSIZE, n, p) +#define DOMAINSET_CLR(n, p) __BIT_CLR(DOMAINSET_SETSIZE, n, p) +#define DOMAINSET_COPY(f, t) __BIT_COPY(DOMAINSET_SETSIZE, f, t) +#define DOMAINSET_ISSET(n, p) __BIT_ISSET(DOMAINSET_SETSIZE, n, p) +#define DOMAINSET_SET(n, p) __BIT_SET(DOMAINSET_SETSIZE, n, p) +#define DOMAINSET_ZERO(p) __BIT_ZERO(DOMAINSET_SETSIZE, p) +#define DOMAINSET_FILL(p) __BIT_FILL(DOMAINSET_SETSIZE, p) +#define DOMAINSET_SETOF(n, p) __BIT_SETOF(DOMAINSET_SETSIZE, n, p) +#define DOMAINSET_EMPTY(p) __BIT_EMPTY(DOMAINSET_SETSIZE, p) +#define DOMAINSET_ISFULLSET(p) __BIT_ISFULLSET(DOMAINSET_SETSIZE, p) +#define DOMAINSET_SUBSET(p, c) __BIT_SUBSET(DOMAINSET_SETSIZE, p, c) +#define DOMAINSET_OVERLAP(p, c) __BIT_OVERLAP(DOMAINSET_SETSIZE, p, c) +#define DOMAINSET_CMP(p, c) __BIT_CMP(DOMAINSET_SETSIZE, p, c) +#define DOMAINSET_OR(d, s) __BIT_OR(DOMAINSET_SETSIZE, d, s) +#define DOMAINSET_AND(d, s) __BIT_AND(DOMAINSET_SETSIZE, d, s) +#define DOMAINSET_ANDNOT(d, s) __BIT_ANDNOT(DOMAINSET_SETSIZE, d, s) +#define DOMAINSET_CLR_ATOMIC(n, p) __BIT_CLR_ATOMIC(DOMAINSET_SETSIZE, n, p) +#define DOMAINSET_SET_ATOMIC(n, p) __BIT_SET_ATOMIC(DOMAINSET_SETSIZE, n, p) #define DOMAINSET_SET_ATOMIC_ACQ(n, p) \ - BIT_SET_ATOMIC_ACQ(DOMAINSET_SETSIZE, n, p) -#define DOMAINSET_AND_ATOMIC(n, p) BIT_AND_ATOMIC(DOMAINSET_SETSIZE, n, p) -#define DOMAINSET_OR_ATOMIC(d, s) BIT_OR_ATOMIC(DOMAINSET_SETSIZE, d, s) + __BIT_SET_ATOMIC_ACQ(DOMAINSET_SETSIZE, n, p) +#define DOMAINSET_AND_ATOMIC(n, p) __BIT_AND_ATOMIC(DOMAINSET_SETSIZE, n, p) +#define DOMAINSET_OR_ATOMIC(d, s) __BIT_OR_ATOMIC(DOMAINSET_SETSIZE, d, s) #define DOMAINSET_COPY_STORE_REL(f, t) \ - BIT_COPY_STORE_REL(DOMAINSET_SETSIZE, f, t) -#define DOMAINSET_FFS(p) BIT_FFS(DOMAINSET_SETSIZE, p) -#define DOMAINSET_FLS(p) BIT_FLS(DOMAINSET_SETSIZE, p) -#define DOMAINSET_COUNT(p) ((int)BIT_COUNT(DOMAINSET_SETSIZE, p)) -#define DOMAINSET_FSET BITSET_FSET(_NDOMAINSETWORDS) -#define DOMAINSET_T_INITIALIZER BITSET_T_INITIALIZER + __BIT_COPY_STORE_REL(DOMAINSET_SETSIZE, f, t) +#define DOMAINSET_FFS(p) __BIT_FFS(DOMAINSET_SETSIZE, p) +#define DOMAINSET_FLS(p) __BIT_FLS(DOMAINSET_SETSIZE, p) +#define DOMAINSET_COUNT(p) ((int)__BIT_COUNT(DOMAINSET_SETSIZE, p)) +#define DOMAINSET_FSET __BITSET_FSET(_NDOMAINSETWORDS) +#define DOMAINSET_T_INITIALIZER(x) __BITSET_T_INITIALIZER(x) #define DOMAINSET_POLICY_INVALID 0 #define DOMAINSET_POLICY_ROUNDROBIN 1 diff --git a/tests/sys/sys/bitset_test.c b/tests/sys/sys/bitset_test.c --- a/tests/sys/sys/bitset_test.c +++ b/tests/sys/sys/bitset_test.c @@ -7,6 +7,8 @@ * the FreeBSD Foundation. */ +#define _WANT_FREEBSD_BITSET + #include #include #include diff --git a/usr.bin/cpuset/cpuset.c b/usr.bin/cpuset/cpuset.c --- a/usr.bin/cpuset/cpuset.c +++ b/usr.bin/cpuset/cpuset.c @@ -32,6 +32,8 @@ #include __FBSDID("$FreeBSD$"); +#define _WANT_FREEBSD_BITSET + #include #include #include