[newlib 16/22] sys/bitset.h: reduce visibility of BIT_* macros

Sebastian Huber sebastian.huber at embedded-brains.de
Wed Jun 22 08:24:39 UTC 2022


From: Stefan Eßer <se at FreeBSD.org>

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
---
 newlib/libc/sys/rtems/include/sys/_bitset.h |  13 +-
 newlib/libc/sys/rtems/include/sys/_cpuset.h |   2 +-
 newlib/libc/sys/rtems/include/sys/bitset.h  | 130 +++++++++++++-------
 newlib/libc/sys/rtems/include/sys/cpuset.h  |  60 ++++-----
 4 files changed, 127 insertions(+), 78 deletions(-)

diff --git a/newlib/libc/sys/rtems/include/sys/_bitset.h b/newlib/libc/sys/rtems/include/sys/_bitset.h
index e54f04cbe..1c167daf3 100644
--- a/newlib/libc/sys/rtems/include/sys/_bitset.h
+++ b/newlib/libc/sys/rtems/include/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 @@ 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_ */
diff --git a/newlib/libc/sys/rtems/include/sys/_cpuset.h b/newlib/libc/sys/rtems/include/sys/_cpuset.h
index dee341665..c6383f363 100644
--- a/newlib/libc/sys/rtems/include/sys/_cpuset.h
+++ b/newlib/libc/sys/rtems/include/sys/_cpuset.h
@@ -46,7 +46,7 @@
 #endif
 #endif
 
-BITSET_DEFINE(_cpuset, CPU_SETSIZE);
+__BITSET_DEFINE(_cpuset, CPU_SETSIZE);
 typedef struct _cpuset cpuset_t;
 
 #endif /* !_SYS__CPUSET_H_ */
diff --git a/newlib/libc/sys/rtems/include/sys/bitset.h b/newlib/libc/sys/rtems/include/sys/bitset.h
index 88cda9dd9..00bdc23f9 100644
--- a/newlib/libc/sys/rtems/include/sys/bitset.h
+++ b/newlib/libc/sys/rtems/include/sys/bitset.h
@@ -51,36 +51,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])					\
@@ -89,7 +89,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)			\
@@ -98,7 +98,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] &					\
@@ -109,7 +109,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] &					\
@@ -119,7 +119,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] !=				\
@@ -128,49 +128,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];\
@@ -182,42 +182,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],		\
@@ -225,10 +225,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;						\
 									\
@@ -247,9 +247,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;							\
 									\
@@ -264,7 +264,7 @@
 	__bit;								\
 })
 
-#define	BIT_COUNT(_s, p) __extension__ ({				\
+#define	__BIT_COUNT(_s, p) __extension__ ({				\
 	__size_t __i;							\
 	long __count;							\
 									\
@@ -274,7 +274,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) {					\
@@ -296,24 +296,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/newlib/libc/sys/rtems/include/sys/cpuset.h b/newlib/libc/sys/rtems/include/sys/cpuset.h
index e46090b8a..e24bce30c 100644
--- a/newlib/libc/sys/rtems/include/sys/cpuset.h
+++ b/newlib/libc/sys/rtems/include/sys/cpuset.h
@@ -50,22 +50,22 @@
 
 #define	CPUSETBUFSIZ	((2 + sizeof(long) * 2) * _NCPUWORDS)
 
-#define	CPU_SETOF(n, p)			BIT_SETOF(CPU_SETSIZE, n, 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_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	CPUSET_FSET			BITSET_FSET(_NCPUWORDS)
-#define	CPUSET_T_INITIALIZER		BITSET_T_INITIALIZER
+#define	CPU_SETOF(n, p)			__BIT_SETOF(CPU_SETSIZE, n, 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_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	CPUSET_FSET			__BITSET_FSET(_NCPUWORDS)
+#define	CPUSET_T_INITIALIZER		__BITSET_T_INITIALIZER
 
 typedef cpuset_t cpu_set_t;
 
@@ -91,7 +91,7 @@ static __inline void CPU_FREE(cpu_set_t *set)
 
 static __inline void CPU_ZERO_S(size_t setsize, cpu_set_t *set)
 {
-  BIT_ZERO(_cpu_set_bits(setsize), set);
+  __BIT_ZERO(_cpu_set_bits(setsize), set);
 }
 
 static __inline void CPU_ZERO(cpu_set_t *set)
@@ -101,7 +101,7 @@ static __inline void CPU_ZERO(cpu_set_t *set)
 
 static __inline void CPU_FILL_S(size_t setsize, cpu_set_t *set)
 {
-  BIT_FILL(_cpu_set_bits(setsize), set);
+  __BIT_FILL(_cpu_set_bits(setsize), set);
 }
 
 static __inline void CPU_FILL(cpu_set_t *set)
@@ -111,7 +111,7 @@ static __inline void CPU_FILL(cpu_set_t *set)
 
 static __inline void CPU_SET_S(int cpu, size_t setsize, cpu_set_t *set)
 {
-  BIT_SET(_cpu_set_bits(setsize), cpu, set);
+  __BIT_SET(_cpu_set_bits(setsize), cpu, set);
 }
 
 static __inline void CPU_SET(int cpu, cpu_set_t *set)
@@ -121,7 +121,7 @@ static __inline void CPU_SET(int cpu, cpu_set_t *set)
 
 static __inline void CPU_CLR_S(int cpu, size_t setsize, cpu_set_t *set)
 {
-  BIT_CLR(_cpu_set_bits(setsize), cpu, set);
+  __BIT_CLR(_cpu_set_bits(setsize), cpu, set);
 }
 
 static __inline void CPU_CLR(int cpu, cpu_set_t *set)
@@ -131,7 +131,7 @@ static __inline void CPU_CLR(int cpu, cpu_set_t *set)
 
 static __inline int CPU_ISSET_S(int cpu, size_t setsize, const cpu_set_t *set)
 {
-  return BIT_ISSET(_cpu_set_bits(setsize), cpu, set);
+  return __BIT_ISSET(_cpu_set_bits(setsize), cpu, set);
 }
 
 static __inline int CPU_ISSET(int cpu, const cpu_set_t *set)
@@ -141,13 +141,13 @@ static __inline int CPU_ISSET(int cpu, const cpu_set_t *set)
 
 static __inline void CPU_COPY(const cpu_set_t *src, cpu_set_t *dest)
 {
-  BIT_COPY(_cpu_set_bits(setsize), src, dest);
+  __BIT_COPY(_cpu_set_bits(setsize), src, dest);
 }
 
 static __inline void CPU_AND_S(size_t setsize, cpu_set_t *destset,
   const cpu_set_t *srcset1, const cpu_set_t *srcset2)
 {
-  BIT_AND2(_cpu_set_bits(setsize), destset, srcset1, srcset2);
+  __BIT_AND2(_cpu_set_bits(setsize), destset, srcset1, srcset2);
 }
 
 static __inline void CPU_AND(cpu_set_t *destset, const cpu_set_t *srcset1,
@@ -159,7 +159,7 @@ static __inline void CPU_AND(cpu_set_t *destset, const cpu_set_t *srcset1,
 static __inline void CPU_OR_S(size_t setsize, cpu_set_t *destset,
   const cpu_set_t *srcset1, const cpu_set_t *srcset2)
 {
-  BIT_OR2(_cpu_set_bits(setsize), destset, srcset1, srcset2);
+  __BIT_OR2(_cpu_set_bits(setsize), destset, srcset1, srcset2);
 }
 
 static __inline void CPU_OR(cpu_set_t *destset, const cpu_set_t *srcset1,
@@ -171,7 +171,7 @@ static __inline void CPU_OR(cpu_set_t *destset, const cpu_set_t *srcset1,
 static __inline void CPU_XOR_S(size_t setsize, cpu_set_t *destset,
   const cpu_set_t *srcset1, const cpu_set_t *srcset2)
 {
-  BIT_XOR2(_cpu_set_bits(setsize), destset, srcset1, srcset2);
+  __BIT_XOR2(_cpu_set_bits(setsize), destset, srcset1, srcset2);
 }
 
 static __inline void CPU_XOR(cpu_set_t *destset, const cpu_set_t *srcset1,
@@ -183,7 +183,7 @@ static __inline void CPU_XOR(cpu_set_t *destset, const cpu_set_t *srcset1,
 static __inline void CPU_ANDNOT_S(size_t setsize, cpu_set_t *destset,
   const cpu_set_t *srcset1, const cpu_set_t *srcset2)
 {
-  BIT_ANDNOT2(_cpu_set_bits(setsize), destset, srcset1, srcset2);
+  __BIT_ANDNOT2(_cpu_set_bits(setsize), destset, srcset1, srcset2);
 }
 
 static __inline void CPU_ANDNOT(cpu_set_t *destset, const cpu_set_t *srcset1,
@@ -194,7 +194,7 @@ static __inline void CPU_ANDNOT(cpu_set_t *destset, const cpu_set_t *srcset1,
 
 static __inline int CPU_COUNT_S(size_t setsize, const cpu_set_t *set)
 {
-  return (int)BIT_COUNT(_cpu_set_bits(setsize), set);
+  return (int)__BIT_COUNT(_cpu_set_bits(setsize), set);
 }
 
 static __inline int CPU_COUNT(const cpu_set_t *set)
@@ -205,7 +205,7 @@ static __inline int CPU_COUNT(const cpu_set_t *set)
 static __inline int CPU_EQUAL_S(size_t setsize, const cpu_set_t *set1,
   const cpu_set_t *set2)
 {
-  return BIT_CMP(_cpu_set_bits(setsize), set1, set2) == 0;
+  return __BIT_CMP(_cpu_set_bits(setsize), set1, set2) == 0;
 }
 
 static __inline int CPU_EQUAL(const cpu_set_t *set1, const cpu_set_t *set2)
@@ -215,12 +215,12 @@ static __inline int CPU_EQUAL(const cpu_set_t *set1, const cpu_set_t *set2)
 
 static __inline int CPU_CMP(const cpu_set_t *set1, const cpu_set_t *set2)
 {
-  return BIT_CMP(CPU_SETSIZE, set1, set2);
+  return __BIT_CMP(CPU_SETSIZE, set1, set2);
 }
 
 static __inline int CPU_EMPTY(const cpu_set_t *set)
 {
-  return BIT_EMPTY(_cpu_set_bits(sizeof(*set)), set);
+  return __BIT_EMPTY(_cpu_set_bits(sizeof(*set)), set);
 }
 
 __END_DECLS
-- 
2.35.3



More information about the devel mailing list