[newlib 20/22] sys/_bitset.h: Fix fall-out from commit 5e04571cf3c

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


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

The changes to the bitset macros allowed sched.h to be included
into userland programs without name space pollution due to BIT_*
and BITSET_* macros.

The definition of a "struct bitset" had been overlooked. This name
space pollution caused the build of port print/miktex to fail.

This commit makes the definition of struct bitset depend on the
same condition as the visibility of the BIT_* and BITSET_* macros,
i.e. needs _KERNEL or _WANT_FREEBSD_BITSET to be defined before
including sys/_bitset.h.

It has been tested with "make universe" since a prior attempt to
fix the issue broke the PowerPC64 kernel build.

This commit shall be MFCed together with commit 5e04571cf3c.

Reported by:    arrowd
MFC after:      1 month
---
 newlib/libc/sys/rtems/include/sys/_bitset.h | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/newlib/libc/sys/rtems/include/sys/_bitset.h b/newlib/libc/sys/rtems/include/sys/_bitset.h
index 1c167daf3..70b9713ff 100644
--- a/newlib/libc/sys/rtems/include/sys/_bitset.h
+++ b/newlib/libc/sys/rtems/include/sys/_bitset.h
@@ -52,7 +52,7 @@ struct _t {								\
 /*
  * Helper to declare a bitset without it's size being a constant.
  *
- * Sadly we cannot declare a bitset struct with '__bits[]', because it's
+ * 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)
@@ -61,11 +61,12 @@ struct _t {								\
  * Define a default type that can be used while manually specifying size
  * to every call.
  */
-__BITSET_DEFINE(bitset, 1);
 
 #if defined(_KERNEL) || defined(_WANT_FREEBSD_BITSET)
+__BITSET_DEFINE(bitset, 1);
+
 #define	BITSET_DEFINE(_t, _s)	__BITSET_DEFINE(_t, _s)
 #define	BITSET_DEFINE_VAR(_t)	__BITSET_DEFINE_VAR(_t)
-#endif
+#endif /* defined(_KERNEL) || defined(_WANT_FREEBSD_BITSET) */
 
 #endif /* !_SYS__BITSET_H_ */
-- 
2.35.3



More information about the devel mailing list