xref: /illumos-gate/usr/src/uts/common/sys/stdalign.h (revision ed093b41)
1*ed093b41SRobert Mustacchi /*
2*ed093b41SRobert Mustacchi  * This file and its contents are supplied under the terms of the
3*ed093b41SRobert Mustacchi  * Common Development and Distribution License ("CDDL"), version 1.0.
4*ed093b41SRobert Mustacchi  * You may only use this file in accordance with the terms of version
5*ed093b41SRobert Mustacchi  * 1.0 of the CDDL.
6*ed093b41SRobert Mustacchi  *
7*ed093b41SRobert Mustacchi  * A full copy of the text of the CDDL should have accompanied this
8*ed093b41SRobert Mustacchi  * source.  A copy of the CDDL is also available via the Internet at
9*ed093b41SRobert Mustacchi  * http://www.illumos.org/license/CDDL.
10*ed093b41SRobert Mustacchi  */
11*ed093b41SRobert Mustacchi 
12*ed093b41SRobert Mustacchi /*
13*ed093b41SRobert Mustacchi  * Copyright 2016 Joyent, Inc.
14*ed093b41SRobert Mustacchi  * Copyright 2023 Oxide Computer Company
15*ed093b41SRobert Mustacchi  */
16*ed093b41SRobert Mustacchi 
17*ed093b41SRobert Mustacchi #ifndef _SYS_STDALIGN_H
18*ed093b41SRobert Mustacchi #define	_SYS_STDALIGN_H
19*ed093b41SRobert Mustacchi 
20*ed093b41SRobert Mustacchi /*
21*ed093b41SRobert Mustacchi  * ISO/IEC C11 stdalign.h. This header is meant to provide definitions for the
22*ed093b41SRobert Mustacchi  * alignas and alignof 'keywords' into the underlying compiler-understood value.
23*ed093b41SRobert Mustacchi  * In addition, there are two macros that are meant to define that this process
24*ed093b41SRobert Mustacchi  * has happened. C++11 added alignas/alignof as keywords and including this
25*ed093b41SRobert Mustacchi  * header is meant to cause us to still have the _is_defined macros, but not
26*ed093b41SRobert Mustacchi  * define this overall.
27*ed093b41SRobert Mustacchi  *
28*ed093b41SRobert Mustacchi  * Unlike other cases we don't use any symbol guards here (other than C++) and
29*ed093b41SRobert Mustacchi  * just allow the implementation to either have _Alignas and _Alignof or not
30*ed093b41SRobert Mustacchi  * have it and lead to a compiler error for the user. The main justification of
31*ed093b41SRobert Mustacchi  * this is that this header is only defined in C11 (and newer). It's not defined
32*ed093b41SRobert Mustacchi  * in other standards and just as if you include a non-standard header, in this
33*ed093b41SRobert Mustacchi  * case we don't try to stop that (same as if you included something like
34*ed093b41SRobert Mustacchi  * libdevinfo.h).
35*ed093b41SRobert Mustacchi  */
36*ed093b41SRobert Mustacchi 
37*ed093b41SRobert Mustacchi #ifdef __cplusplus
38*ed093b41SRobert Mustacchi extern "C" {
39*ed093b41SRobert Mustacchi #endif
40*ed093b41SRobert Mustacchi 
41*ed093b41SRobert Mustacchi #ifndef	__cplusplus
42*ed093b41SRobert Mustacchi 
43*ed093b41SRobert Mustacchi #define	alignas	_Alignas
44*ed093b41SRobert Mustacchi /*CSTYLED*/
45*ed093b41SRobert Mustacchi #define	alignof	_Alignof
46*ed093b41SRobert Mustacchi 
47*ed093b41SRobert Mustacchi #endif	/* !__cplusplus */
48*ed093b41SRobert Mustacchi 
49*ed093b41SRobert Mustacchi #define	__alignas_is_defined	1
50*ed093b41SRobert Mustacchi #define	__alignof_is_defined	1
51*ed093b41SRobert Mustacchi 
52*ed093b41SRobert Mustacchi #ifdef __cplusplus
53*ed093b41SRobert Mustacchi }
54*ed093b41SRobert Mustacchi #endif
55*ed093b41SRobert Mustacchi 
56*ed093b41SRobert Mustacchi #endif /* _SYS_STDALIGN_H */
57