diff options
Diffstat (limited to 'usr/src/head/stdalign.h')
-rw-r--r-- | usr/src/head/stdalign.h | 23 |
1 files changed, 18 insertions, 5 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 |