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