summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Mustacchi <rm@fingolfin.org>2022-11-10 05:34:51 +0000
committerRobert Mustacchi <rm@fingolfin.org>2022-12-14 15:58:56 +0000
commit7b5987898994d86cd20e00dbf8c305dfbfbb8bea (patch)
tree4dfd0db3415579be854f1fb77ebf536a87e2ac16
parent7f6a299e282ed51917878b84744774a6634e5dc6 (diff)
downloadillumos-gate-7b5987898994d86cd20e00dbf8c305dfbfbb8bea.tar.gz
15135 stdalign.h is very C11-y, but perhaps disrespectful of C++
Reviewed by: Gordon Ross <gordon.w.ross@gmail.com> Reviewed by: Andrew Stormont <andyjstormont@gmail.com> Approved by: Dan McDonald <danmcd@mnx.io>
-rw-r--r--usr/src/head/stdalign.h23
-rw-r--r--usr/src/test/libc-tests/cfg/symbols/stdalign_h.cfg8
2 files changed, 22 insertions, 9 deletions
diff --git a/usr/src/head/stdalign.h b/usr/src/head/stdalign.h
index 2577a8de92..15160d660e 100644
--- a/usr/src/head/stdalign.h
+++ b/usr/src/head/stdalign.h
@@ -11,30 +11,43 @@
/*
* Copyright 2016 Joyent, Inc.
+ * Copyright 2022 Oxide Computer Company
*/
#ifndef _STDALIGN_H
#define _STDALIGN_H
/*
- * ISO/IEC C11 stdalign.h
+ * ISO/IEC C11 stdalign.h. This header is meant to provide definitions for the
+ * alignas and alignof 'keywords' into the underlying compiler-understood value.
+ * In addition, there are two macros that are meant to define that this process
+ * has happened. C++11 added alignas/alignof as keywords and including this
+ * header is meant to cause us to still have the _is_defined macros, but not
+ * define this overall.
+ *
+ * Unlike other cases we don't use any symbol guards here (other than C++) and
+ * just allow the implementation to either have _Alignas and _Alignof or not
+ * have it and lead to a compiler error for the user. The main justification of
+ * this is that this header is only defined in C11 (and newer). It's not defined
+ * in other standards and just as if you include a non-standard header, in this
+ * case we don't try to stop that (same as if you included something like
+ * libdevinfo.h).
*/
-#include <sys/feature_tests.h>
#ifdef __cplusplus
extern "C" {
#endif
-#if !defined(_STRICT_SYMBOLS) || defined(_STDC_C11)
+#ifndef __cplusplus
#define alignas _Alignas
#define alignof _Alignof
+#endif /* !__cplusplus */
+
#define __alignas_is_defined 1
#define __alignof_is_defined 1
-#endif /* !_STRICT_SYMBOLS || _STDC_C11 */
-
#ifdef __cplusplus
}
#endif
diff --git a/usr/src/test/libc-tests/cfg/symbols/stdalign_h.cfg b/usr/src/test/libc-tests/cfg/symbols/stdalign_h.cfg
index 81b7419e31..aa2c517bb6 100644
--- a/usr/src/test/libc-tests/cfg/symbols/stdalign_h.cfg
+++ b/usr/src/test/libc-tests/cfg/symbols/stdalign_h.cfg
@@ -20,7 +20,7 @@
#
# Defines
#
-define | alignas | | stdalign.h | -ALL +C11
-define | alignof | | stdalign.h | -ALL +C11
-define | __alignas_is_defined | 1 | stdalign.h | -ALL +C11
-define | __alignof_is_defined | 1 | stdalign.h | -ALL +C11
+define | alignas | | stdalign.h | +ALL
+define | alignof | | stdalign.h | +ALL
+define | __alignas_is_defined | 1 | stdalign.h | +ALL
+define | __alignof_is_defined | 1 | stdalign.h | +ALL