summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/uts/common/sys/types.h36
1 files changed, 29 insertions, 7 deletions
diff --git a/usr/src/uts/common/sys/types.h b/usr/src/uts/common/sys/types.h
index dcb2c86283..c583bc6362 100644
--- a/usr/src/uts/common/sys/types.h
+++ b/usr/src/uts/common/sys/types.h
@@ -28,6 +28,7 @@
*
* Copyright 2013 Nexenta Systems, Inc. All rights reserved.
* Copyright 2016 Joyent, Inc.
+ * Copyright 2021 Oxide Computer Company
*/
#ifndef _SYS_TYPES_H
@@ -188,15 +189,36 @@ typedef int blksize_t; /* used for block sizes */
typedef long blksize_t; /* used for block sizes */
#endif
-#if defined(__XOPEN_OR_POSIX)
+/*
+ * The boolean_t type has had a varied amount of exposure over the years in
+ * terms of how its enumeration constants have been exposed. In particular, it
+ * originally used the __XOPEN_OR_POSIX macro to determine whether to prefix the
+ * B_TRUE and B_FALSE with an underscore. This check never included the
+ * question of if we were in a strict ANSI C environment or whether extensions
+ * were defined.
+ *
+ * Compilers such as clang started defaulting to always including an
+ * XOPEN_SOURCE declaration on behalf of users, but also noted __EXTENSIONS__.
+ * This would lead most software that had used the non-underscore versions to
+ * need it. As such, we have adjusted the non-strict XOPEN environment to retain
+ * its old behavior so as to minimize namespace pollution; however, we instead
+ * include both variants of the definitions in the generally visible version
+ * allowing software written in either world to hopefully end up in a good
+ * place.
+ *
+ * This isn't perfect, but should hopefully minimize the pain for folks actually
+ * trying to build software.
+ */
+#if defined(__XOPEN_OR_POSIX) && !defined(__EXTENSIONS__)
typedef enum { _B_FALSE, _B_TRUE } boolean_t;
#else
-typedef enum { B_FALSE, B_TRUE } boolean_t;
+typedef enum { B_FALSE = 0, B_TRUE = 1, _B_FALSE = 0, _B_TRUE = 1 } boolean_t;
+#endif /* __XOPEN_OR_POSIX && !__EXTENSIONS__ */
+
#ifdef _KERNEL
#define VALID_BOOLEAN(x) (((x) == B_FALSE) || ((x) == B_TRUE))
#define VOID2BOOLEAN(x) (((uintptr_t)(x) == 0) ? B_FALSE : B_TRUE)
#endif /* _KERNEL */
-#endif /* defined(__XOPEN_OR_POSIX) */
#ifdef _KERNEL
#define BOOLEAN2VOID(x) ((x) ? 1 : 0)
@@ -409,8 +431,8 @@ typedef struct _pthread_mutex { /* = mutex_t in synch.h */
uint16_t __pthread_mutex_flag1;
uint8_t __pthread_mutex_flag2;
uint8_t __pthread_mutex_ceiling;
- uint16_t __pthread_mutex_type;
- uint16_t __pthread_mutex_magic;
+ uint16_t __pthread_mutex_type;
+ uint16_t __pthread_mutex_magic;
} __pthread_mutex_flags;
union {
struct {
@@ -428,8 +450,8 @@ typedef struct _pthread_mutex { /* = mutex_t in synch.h */
typedef struct _pthread_cond { /* = cond_t in synch.h */
struct {
uint8_t __pthread_cond_flag[4];
- uint16_t __pthread_cond_type;
- uint16_t __pthread_cond_magic;
+ uint16_t __pthread_cond_type;
+ uint16_t __pthread_cond_magic;
} __pthread_cond_flags;
upad64_t __pthread_cond_data;
} pthread_cond_t;