sys/bitset.h: reduce visibility of BIT_* macros

Add two underscore characters "__" to names of BIT_* and BITSET_*
macros to move them to the implementation name space and to prevent
a name space pollution due to BIT_* macros in 3rd party programs with
conflicting parameter signatures.

These prefixed macro names are used in kernel header files to define
macros in e.g. sched.h, sys/cpuset.h and sys/domainset.h.

If C programs are built with either -D_KERNEL (automatically passed
when building a kernel or kernel modules) or -D_WANT_FREENBSD_BITSET
(or this macros is defined in the source code before including the
bitset macros), then all macros are made visible with their previous
names, too. E.g., both __BIT_SET() and BIT_SET() are visible with
either of _KERNEL or _WANT_FREEBSD_BITSET defined.

The main reason for this change is that some 3rd party sources
including sched.h have been found to contain conflicting BIT_*
macros.

As a work-around, parts of shed.h have been made conditional and
depend on _WITH_CPU_SET_T being set when sched.h is included.
Ports that expect the full functionality provided by sched.h need
to be built with -D_WITH_CPU_SET_T. But this leads to conflicts if
BIT_* macros are defined in that program, too.

This patch set makes all of sched.h visible again without this
parameter being passed and without any name space pollution due
to BIT_* macros becoming visible when sched.h is included.

This patch set will be backported to the STABLE branches, but ports
will need to use -D_WITH_CPU_SET_T as long as there are supported
releases that do not contain these patches.

Reviewed by:	kib, markj
MFC after:	1 month
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D33235
This commit is contained in:
Stefan Eßer 2021-12-05 22:27:33 +01:00
parent 288a92252b
commit 5e04571cf3
13 changed files with 186 additions and 109 deletions

View File

@ -33,20 +33,16 @@
#include <sys/types.h>
#include <sys/sched.h>
#if __BSD_VISIBLE
#ifdef _WITH_CPU_SET_T
#include <sys/cpuset.h>
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

View File

@ -28,6 +28,8 @@
* $FreeBSD$
*/
#define _WANT_FREEBSD_BITSET
#include <sys/param.h>
#include <sys/counter.h>
#include <sys/cpuset.h>

View File

@ -22,6 +22,7 @@
__FBSDID("$FreeBSD$");
#define PFIOC_USE_LATEST
#define _WANT_FREEBSD_BITSET
#include <sys/types.h>
#include <sys/bitset.h>

View File

@ -184,7 +184,7 @@ struct node_queue_opt {
};
#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 {

View File

@ -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 @@ One example use of
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 @@ Unlike every other reference to individual set members, which are zero-indexed,
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 .

View File

@ -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 @@ struct t { \
* 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_ */

View File

@ -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_ */

View File

@ -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;
/*

View File

@ -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_ */

View File

@ -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.

View File

@ -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

View File

@ -7,6 +7,8 @@
* the FreeBSD Foundation.
*/
#define _WANT_FREEBSD_BITSET
#include <sys/types.h>
#include <sys/_bitset.h>
#include <sys/bitset.h>

View File

@ -32,6 +32,8 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#define _WANT_FREEBSD_BITSET
#include <sys/param.h>
#include <sys/types.h>
#include <sys/time.h>