xref: /Universal-ctags/gnulib/cdefs.h (revision 820c1a8d46849a90376d8eb15b319ac05439f656)
1*820c1a8dSHiroo HAYASHI /* Copyright (C) 1992-2021 Free Software Foundation, Inc.
2*820c1a8dSHiroo HAYASHI    This file is part of the GNU C Library.
3*820c1a8dSHiroo HAYASHI 
4*820c1a8dSHiroo HAYASHI    The GNU C Library is free software; you can redistribute it and/or
5*820c1a8dSHiroo HAYASHI    modify it under the terms of the GNU Lesser General Public
6*820c1a8dSHiroo HAYASHI    License as published by the Free Software Foundation; either
7*820c1a8dSHiroo HAYASHI    version 2.1 of the License, or (at your option) any later version.
8*820c1a8dSHiroo HAYASHI 
9*820c1a8dSHiroo HAYASHI    The GNU C Library is distributed in the hope that it will be useful,
10*820c1a8dSHiroo HAYASHI    but WITHOUT ANY WARRANTY; without even the implied warranty of
11*820c1a8dSHiroo HAYASHI    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12*820c1a8dSHiroo HAYASHI    Lesser General Public License for more details.
13*820c1a8dSHiroo HAYASHI 
14*820c1a8dSHiroo HAYASHI    You should have received a copy of the GNU Lesser General Public
15*820c1a8dSHiroo HAYASHI    License along with the GNU C Library; if not, see
16*820c1a8dSHiroo HAYASHI    <https://www.gnu.org/licenses/>.  */
17*820c1a8dSHiroo HAYASHI 
18*820c1a8dSHiroo HAYASHI #ifndef	_SYS_CDEFS_H
19*820c1a8dSHiroo HAYASHI #define	_SYS_CDEFS_H	1
20*820c1a8dSHiroo HAYASHI 
21*820c1a8dSHiroo HAYASHI /* We are almost always included from features.h. */
22*820c1a8dSHiroo HAYASHI #ifndef _FEATURES_H
23*820c1a8dSHiroo HAYASHI # include <features.h>
24*820c1a8dSHiroo HAYASHI #endif
25*820c1a8dSHiroo HAYASHI 
26*820c1a8dSHiroo HAYASHI /* The GNU libc does not support any K&R compilers or the traditional mode
27*820c1a8dSHiroo HAYASHI    of ISO C compilers anymore.  Check for some of the combinations not
28*820c1a8dSHiroo HAYASHI    supported anymore.  */
29*820c1a8dSHiroo HAYASHI #if defined __GNUC__ && !defined __STDC__
30*820c1a8dSHiroo HAYASHI # error "You need a ISO C conforming compiler to use the glibc headers"
31*820c1a8dSHiroo HAYASHI #endif
32*820c1a8dSHiroo HAYASHI 
33*820c1a8dSHiroo HAYASHI /* Some user header file might have defined this before.  */
34*820c1a8dSHiroo HAYASHI #undef	__P
35*820c1a8dSHiroo HAYASHI #undef	__PMT
36*820c1a8dSHiroo HAYASHI 
37*820c1a8dSHiroo HAYASHI /* Compilers that lack __has_attribute may object to
38*820c1a8dSHiroo HAYASHI        #if defined __has_attribute && __has_attribute (...)
39*820c1a8dSHiroo HAYASHI    even though they do not need to evaluate the right-hand side of the &&.
40*820c1a8dSHiroo HAYASHI    Similarly for __has_builtin, etc.  */
41*820c1a8dSHiroo HAYASHI #if (defined __has_attribute \
42*820c1a8dSHiroo HAYASHI      && (!defined __clang_minor__ \
43*820c1a8dSHiroo HAYASHI          || 3 < __clang_major__ + (5 <= __clang_minor__)))
44*820c1a8dSHiroo HAYASHI # define __glibc_has_attribute(attr) __has_attribute (attr)
45*820c1a8dSHiroo HAYASHI #else
46*820c1a8dSHiroo HAYASHI # define __glibc_has_attribute(attr) 0
47*820c1a8dSHiroo HAYASHI #endif
48*820c1a8dSHiroo HAYASHI #ifdef __has_builtin
49*820c1a8dSHiroo HAYASHI # define __glibc_has_builtin(name) __has_builtin (name)
50*820c1a8dSHiroo HAYASHI #else
51*820c1a8dSHiroo HAYASHI # define __glibc_has_builtin(name) 0
52*820c1a8dSHiroo HAYASHI #endif
53*820c1a8dSHiroo HAYASHI #ifdef __has_extension
54*820c1a8dSHiroo HAYASHI # define __glibc_has_extension(ext) __has_extension (ext)
55*820c1a8dSHiroo HAYASHI #else
56*820c1a8dSHiroo HAYASHI # define __glibc_has_extension(ext) 0
57*820c1a8dSHiroo HAYASHI #endif
58*820c1a8dSHiroo HAYASHI 
59*820c1a8dSHiroo HAYASHI #if defined __GNUC__ || defined __clang__
60*820c1a8dSHiroo HAYASHI 
61*820c1a8dSHiroo HAYASHI /* All functions, except those with callbacks or those that
62*820c1a8dSHiroo HAYASHI    synchronize memory, are leaf functions.  */
63*820c1a8dSHiroo HAYASHI # if __GNUC_PREREQ (4, 6) && !defined _LIBC
64*820c1a8dSHiroo HAYASHI #  define __LEAF , __leaf__
65*820c1a8dSHiroo HAYASHI #  define __LEAF_ATTR __attribute__ ((__leaf__))
66*820c1a8dSHiroo HAYASHI # else
67*820c1a8dSHiroo HAYASHI #  define __LEAF
68*820c1a8dSHiroo HAYASHI #  define __LEAF_ATTR
69*820c1a8dSHiroo HAYASHI # endif
70*820c1a8dSHiroo HAYASHI 
71*820c1a8dSHiroo HAYASHI /* GCC can always grok prototypes.  For C++ programs we add throw()
72*820c1a8dSHiroo HAYASHI    to help it optimize the function calls.  But this only works with
73*820c1a8dSHiroo HAYASHI    gcc 2.8.x and egcs.  For gcc 3.4 and up we even mark C functions
74*820c1a8dSHiroo HAYASHI    as non-throwing using a function attribute since programs can use
75*820c1a8dSHiroo HAYASHI    the -fexceptions options for C code as well.  */
76*820c1a8dSHiroo HAYASHI # if !defined __cplusplus \
77*820c1a8dSHiroo HAYASHI      && (__GNUC_PREREQ (3, 4) || __glibc_has_attribute (__nothrow__))
78*820c1a8dSHiroo HAYASHI #  define __THROW	__attribute__ ((__nothrow__ __LEAF))
79*820c1a8dSHiroo HAYASHI #  define __THROWNL	__attribute__ ((__nothrow__))
80*820c1a8dSHiroo HAYASHI #  define __NTH(fct)	__attribute__ ((__nothrow__ __LEAF)) fct
81*820c1a8dSHiroo HAYASHI #  define __NTHNL(fct)  __attribute__ ((__nothrow__)) fct
82*820c1a8dSHiroo HAYASHI # else
83*820c1a8dSHiroo HAYASHI #  if defined __cplusplus && (__GNUC_PREREQ (2,8) || __clang_major >= 4)
84*820c1a8dSHiroo HAYASHI #   if __cplusplus >= 201103L
85*820c1a8dSHiroo HAYASHI #    define __THROW	noexcept (true)
86*820c1a8dSHiroo HAYASHI #   else
87*820c1a8dSHiroo HAYASHI #    define __THROW	throw ()
88*820c1a8dSHiroo HAYASHI #   endif
89*820c1a8dSHiroo HAYASHI #   define __THROWNL	__THROW
90*820c1a8dSHiroo HAYASHI #   define __NTH(fct)	__LEAF_ATTR fct __THROW
91*820c1a8dSHiroo HAYASHI #   define __NTHNL(fct) fct __THROW
92*820c1a8dSHiroo HAYASHI #  else
93*820c1a8dSHiroo HAYASHI #   define __THROW
94*820c1a8dSHiroo HAYASHI #   define __THROWNL
95*820c1a8dSHiroo HAYASHI #   define __NTH(fct)	fct
96*820c1a8dSHiroo HAYASHI #   define __NTHNL(fct) fct
97*820c1a8dSHiroo HAYASHI #  endif
98*820c1a8dSHiroo HAYASHI # endif
99*820c1a8dSHiroo HAYASHI 
100*820c1a8dSHiroo HAYASHI #else	/* Not GCC or clang.  */
101*820c1a8dSHiroo HAYASHI 
102*820c1a8dSHiroo HAYASHI # if (defined __cplusplus						\
103*820c1a8dSHiroo HAYASHI       || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L))
104*820c1a8dSHiroo HAYASHI #  define __inline	inline
105*820c1a8dSHiroo HAYASHI # else
106*820c1a8dSHiroo HAYASHI #  define __inline		/* No inline functions.  */
107*820c1a8dSHiroo HAYASHI # endif
108*820c1a8dSHiroo HAYASHI 
109*820c1a8dSHiroo HAYASHI # define __THROW
110*820c1a8dSHiroo HAYASHI # define __THROWNL
111*820c1a8dSHiroo HAYASHI # define __NTH(fct)	fct
112*820c1a8dSHiroo HAYASHI 
113*820c1a8dSHiroo HAYASHI #endif	/* GCC || clang.  */
114*820c1a8dSHiroo HAYASHI 
115*820c1a8dSHiroo HAYASHI /* These two macros are not used in glibc anymore.  They are kept here
116*820c1a8dSHiroo HAYASHI    only because some other projects expect the macros to be defined.  */
117*820c1a8dSHiroo HAYASHI #define __P(args)	args
118*820c1a8dSHiroo HAYASHI #define __PMT(args)	args
119*820c1a8dSHiroo HAYASHI 
120*820c1a8dSHiroo HAYASHI /* For these things, GCC behaves the ANSI way normally,
121*820c1a8dSHiroo HAYASHI    and the non-ANSI way under -traditional.  */
122*820c1a8dSHiroo HAYASHI 
123*820c1a8dSHiroo HAYASHI #define __CONCAT(x,y)	x ## y
124*820c1a8dSHiroo HAYASHI #define __STRING(x)	#x
125*820c1a8dSHiroo HAYASHI 
126*820c1a8dSHiroo HAYASHI /* This is not a typedef so `const __ptr_t' does the right thing.  */
127*820c1a8dSHiroo HAYASHI #define __ptr_t void *
128*820c1a8dSHiroo HAYASHI 
129*820c1a8dSHiroo HAYASHI 
130*820c1a8dSHiroo HAYASHI /* C++ needs to know that types and declarations are C, not C++.  */
131*820c1a8dSHiroo HAYASHI #ifdef	__cplusplus
132*820c1a8dSHiroo HAYASHI # define __BEGIN_DECLS	extern "C" {
133*820c1a8dSHiroo HAYASHI # define __END_DECLS	}
134*820c1a8dSHiroo HAYASHI #else
135*820c1a8dSHiroo HAYASHI # define __BEGIN_DECLS
136*820c1a8dSHiroo HAYASHI # define __END_DECLS
137*820c1a8dSHiroo HAYASHI #endif
138*820c1a8dSHiroo HAYASHI 
139*820c1a8dSHiroo HAYASHI 
140*820c1a8dSHiroo HAYASHI /* Fortify support.  */
141*820c1a8dSHiroo HAYASHI #define __bos(ptr) __builtin_object_size (ptr, __USE_FORTIFY_LEVEL > 1)
142*820c1a8dSHiroo HAYASHI #define __bos0(ptr) __builtin_object_size (ptr, 0)
143*820c1a8dSHiroo HAYASHI 
144*820c1a8dSHiroo HAYASHI /* Use __builtin_dynamic_object_size at _FORTIFY_SOURCE=3 when available.  */
145*820c1a8dSHiroo HAYASHI #if __USE_FORTIFY_LEVEL == 3 && __glibc_clang_prereq (9, 0)
146*820c1a8dSHiroo HAYASHI # define __glibc_objsize0(__o) __builtin_dynamic_object_size (__o, 0)
147*820c1a8dSHiroo HAYASHI # define __glibc_objsize(__o) __builtin_dynamic_object_size (__o, 1)
148*820c1a8dSHiroo HAYASHI #else
149*820c1a8dSHiroo HAYASHI # define __glibc_objsize0(__o) __bos0 (__o)
150*820c1a8dSHiroo HAYASHI # define __glibc_objsize(__o) __bos (__o)
151*820c1a8dSHiroo HAYASHI #endif
152*820c1a8dSHiroo HAYASHI 
153*820c1a8dSHiroo HAYASHI #if __GNUC_PREREQ (4,3)
154*820c1a8dSHiroo HAYASHI # define __warnattr(msg) __attribute__((__warning__ (msg)))
155*820c1a8dSHiroo HAYASHI # define __errordecl(name, msg) \
156*820c1a8dSHiroo HAYASHI   extern void name (void) __attribute__((__error__ (msg)))
157*820c1a8dSHiroo HAYASHI #else
158*820c1a8dSHiroo HAYASHI # define __warnattr(msg)
159*820c1a8dSHiroo HAYASHI # define __errordecl(name, msg) extern void name (void)
160*820c1a8dSHiroo HAYASHI #endif
161*820c1a8dSHiroo HAYASHI 
162*820c1a8dSHiroo HAYASHI /* Support for flexible arrays.
163*820c1a8dSHiroo HAYASHI    Headers that should use flexible arrays only if they're "real"
164*820c1a8dSHiroo HAYASHI    (e.g. only if they won't affect sizeof()) should test
165*820c1a8dSHiroo HAYASHI    #if __glibc_c99_flexarr_available.  */
166*820c1a8dSHiroo HAYASHI #if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L && !defined __HP_cc
167*820c1a8dSHiroo HAYASHI # define __flexarr	[]
168*820c1a8dSHiroo HAYASHI # define __glibc_c99_flexarr_available 1
169*820c1a8dSHiroo HAYASHI #elif __GNUC_PREREQ (2,97) || defined __clang__
170*820c1a8dSHiroo HAYASHI /* GCC 2.97 and clang support C99 flexible array members as an extension,
171*820c1a8dSHiroo HAYASHI    even when in C89 mode or compiling C++ (any version).  */
172*820c1a8dSHiroo HAYASHI # define __flexarr	[]
173*820c1a8dSHiroo HAYASHI # define __glibc_c99_flexarr_available 1
174*820c1a8dSHiroo HAYASHI #elif defined __GNUC__
175*820c1a8dSHiroo HAYASHI /* Pre-2.97 GCC did not support C99 flexible arrays but did have
176*820c1a8dSHiroo HAYASHI    an equivalent extension with slightly different notation.  */
177*820c1a8dSHiroo HAYASHI # define __flexarr	[0]
178*820c1a8dSHiroo HAYASHI # define __glibc_c99_flexarr_available 1
179*820c1a8dSHiroo HAYASHI #else
180*820c1a8dSHiroo HAYASHI /* Some other non-C99 compiler.  Approximate with [1].  */
181*820c1a8dSHiroo HAYASHI # define __flexarr	[1]
182*820c1a8dSHiroo HAYASHI # define __glibc_c99_flexarr_available 0
183*820c1a8dSHiroo HAYASHI #endif
184*820c1a8dSHiroo HAYASHI 
185*820c1a8dSHiroo HAYASHI 
186*820c1a8dSHiroo HAYASHI /* __asm__ ("xyz") is used throughout the headers to rename functions
187*820c1a8dSHiroo HAYASHI    at the assembly language level.  This is wrapped by the __REDIRECT
188*820c1a8dSHiroo HAYASHI    macro, in order to support compilers that can do this some other
189*820c1a8dSHiroo HAYASHI    way.  When compilers don't support asm-names at all, we have to do
190*820c1a8dSHiroo HAYASHI    preprocessor tricks instead (which don't have exactly the right
191*820c1a8dSHiroo HAYASHI    semantics, but it's the best we can do).
192*820c1a8dSHiroo HAYASHI 
193*820c1a8dSHiroo HAYASHI    Example:
194*820c1a8dSHiroo HAYASHI    int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); */
195*820c1a8dSHiroo HAYASHI 
196*820c1a8dSHiroo HAYASHI #if (defined __GNUC__ && __GNUC__ >= 2) || (__clang_major__ >= 4)
197*820c1a8dSHiroo HAYASHI 
198*820c1a8dSHiroo HAYASHI # define __REDIRECT(name, proto, alias) name proto __asm__ (__ASMNAME (#alias))
199*820c1a8dSHiroo HAYASHI # ifdef __cplusplus
200*820c1a8dSHiroo HAYASHI #  define __REDIRECT_NTH(name, proto, alias) \
201*820c1a8dSHiroo HAYASHI      name proto __THROW __asm__ (__ASMNAME (#alias))
202*820c1a8dSHiroo HAYASHI #  define __REDIRECT_NTHNL(name, proto, alias) \
203*820c1a8dSHiroo HAYASHI      name proto __THROWNL __asm__ (__ASMNAME (#alias))
204*820c1a8dSHiroo HAYASHI # else
205*820c1a8dSHiroo HAYASHI #  define __REDIRECT_NTH(name, proto, alias) \
206*820c1a8dSHiroo HAYASHI      name proto __asm__ (__ASMNAME (#alias)) __THROW
207*820c1a8dSHiroo HAYASHI #  define __REDIRECT_NTHNL(name, proto, alias) \
208*820c1a8dSHiroo HAYASHI      name proto __asm__ (__ASMNAME (#alias)) __THROWNL
209*820c1a8dSHiroo HAYASHI # endif
210*820c1a8dSHiroo HAYASHI # define __ASMNAME(cname)  __ASMNAME2 (__USER_LABEL_PREFIX__, cname)
211*820c1a8dSHiroo HAYASHI # define __ASMNAME2(prefix, cname) __STRING (prefix) cname
212*820c1a8dSHiroo HAYASHI 
213*820c1a8dSHiroo HAYASHI /*
214*820c1a8dSHiroo HAYASHI #elif __SOME_OTHER_COMPILER__
215*820c1a8dSHiroo HAYASHI 
216*820c1a8dSHiroo HAYASHI # define __REDIRECT(name, proto, alias) name proto; \
217*820c1a8dSHiroo HAYASHI 	_Pragma("let " #name " = " #alias)
218*820c1a8dSHiroo HAYASHI */
219*820c1a8dSHiroo HAYASHI #endif
220*820c1a8dSHiroo HAYASHI 
221*820c1a8dSHiroo HAYASHI /* GCC and clang have various useful declarations that can be made with
222*820c1a8dSHiroo HAYASHI    the '__attribute__' syntax.  All of the ways we use this do fine if
223*820c1a8dSHiroo HAYASHI    they are omitted for compilers that don't understand it.  */
224*820c1a8dSHiroo HAYASHI #if !(defined __GNUC__ || defined __clang__)
225*820c1a8dSHiroo HAYASHI # define __attribute__(xyz)	/* Ignore */
226*820c1a8dSHiroo HAYASHI #endif
227*820c1a8dSHiroo HAYASHI 
228*820c1a8dSHiroo HAYASHI /* At some point during the gcc 2.96 development the `malloc' attribute
229*820c1a8dSHiroo HAYASHI    for functions was introduced.  We don't want to use it unconditionally
230*820c1a8dSHiroo HAYASHI    (although this would be possible) since it generates warnings.  */
231*820c1a8dSHiroo HAYASHI #if __GNUC_PREREQ (2,96) || __glibc_has_attribute (__malloc__)
232*820c1a8dSHiroo HAYASHI # define __attribute_malloc__ __attribute__ ((__malloc__))
233*820c1a8dSHiroo HAYASHI #else
234*820c1a8dSHiroo HAYASHI # define __attribute_malloc__ /* Ignore */
235*820c1a8dSHiroo HAYASHI #endif
236*820c1a8dSHiroo HAYASHI 
237*820c1a8dSHiroo HAYASHI /* Tell the compiler which arguments to an allocation function
238*820c1a8dSHiroo HAYASHI    indicate the size of the allocation.  */
239*820c1a8dSHiroo HAYASHI #if __GNUC_PREREQ (4, 3)
240*820c1a8dSHiroo HAYASHI # define __attribute_alloc_size__(params) \
241*820c1a8dSHiroo HAYASHI   __attribute__ ((__alloc_size__ params))
242*820c1a8dSHiroo HAYASHI #else
243*820c1a8dSHiroo HAYASHI # define __attribute_alloc_size__(params) /* Ignore.  */
244*820c1a8dSHiroo HAYASHI #endif
245*820c1a8dSHiroo HAYASHI 
246*820c1a8dSHiroo HAYASHI /* At some point during the gcc 2.96 development the `pure' attribute
247*820c1a8dSHiroo HAYASHI    for functions was introduced.  We don't want to use it unconditionally
248*820c1a8dSHiroo HAYASHI    (although this would be possible) since it generates warnings.  */
249*820c1a8dSHiroo HAYASHI #if __GNUC_PREREQ (2,96) || __glibc_has_attribute (__pure__)
250*820c1a8dSHiroo HAYASHI # define __attribute_pure__ __attribute__ ((__pure__))
251*820c1a8dSHiroo HAYASHI #else
252*820c1a8dSHiroo HAYASHI # define __attribute_pure__ /* Ignore */
253*820c1a8dSHiroo HAYASHI #endif
254*820c1a8dSHiroo HAYASHI 
255*820c1a8dSHiroo HAYASHI /* This declaration tells the compiler that the value is constant.  */
256*820c1a8dSHiroo HAYASHI #if __GNUC_PREREQ (2,5) || __glibc_has_attribute (__const__)
257*820c1a8dSHiroo HAYASHI # define __attribute_const__ __attribute__ ((__const__))
258*820c1a8dSHiroo HAYASHI #else
259*820c1a8dSHiroo HAYASHI # define __attribute_const__ /* Ignore */
260*820c1a8dSHiroo HAYASHI #endif
261*820c1a8dSHiroo HAYASHI 
262*820c1a8dSHiroo HAYASHI #if __GNUC_PREREQ (2,7) || __glibc_has_attribute (__unused__)
263*820c1a8dSHiroo HAYASHI # define __attribute_maybe_unused__ __attribute__ ((__unused__))
264*820c1a8dSHiroo HAYASHI /* Once the next version of the C standard comes out, we can
265*820c1a8dSHiroo HAYASHI    do something like the following here:
266*820c1a8dSHiroo HAYASHI    #elif defined __STDC_VERSION__ && 202???L <= __STDC_VERSION__
267*820c1a8dSHiroo HAYASHI    # define __attribute_maybe_unused__ [[__maybe_unused__]]   */
268*820c1a8dSHiroo HAYASHI #else
269*820c1a8dSHiroo HAYASHI # define __attribute_maybe_unused__ /* Ignore */
270*820c1a8dSHiroo HAYASHI #endif
271*820c1a8dSHiroo HAYASHI 
272*820c1a8dSHiroo HAYASHI /* At some point during the gcc 3.1 development the `used' attribute
273*820c1a8dSHiroo HAYASHI    for functions was introduced.  We don't want to use it unconditionally
274*820c1a8dSHiroo HAYASHI    (although this would be possible) since it generates warnings.  */
275*820c1a8dSHiroo HAYASHI #if __GNUC_PREREQ (3,1) || __glibc_has_attribute (__used__)
276*820c1a8dSHiroo HAYASHI # define __attribute_used__ __attribute__ ((__used__))
277*820c1a8dSHiroo HAYASHI # define __attribute_noinline__ __attribute__ ((__noinline__))
278*820c1a8dSHiroo HAYASHI #else
279*820c1a8dSHiroo HAYASHI # define __attribute_used__ __attribute__ ((__unused__))
280*820c1a8dSHiroo HAYASHI # define __attribute_noinline__ /* Ignore */
281*820c1a8dSHiroo HAYASHI #endif
282*820c1a8dSHiroo HAYASHI 
283*820c1a8dSHiroo HAYASHI /* Since version 3.2, gcc allows marking deprecated functions.  */
284*820c1a8dSHiroo HAYASHI #if __GNUC_PREREQ (3,2) || __glibc_has_attribute (__deprecated__)
285*820c1a8dSHiroo HAYASHI # define __attribute_deprecated__ __attribute__ ((__deprecated__))
286*820c1a8dSHiroo HAYASHI #else
287*820c1a8dSHiroo HAYASHI # define __attribute_deprecated__ /* Ignore */
288*820c1a8dSHiroo HAYASHI #endif
289*820c1a8dSHiroo HAYASHI 
290*820c1a8dSHiroo HAYASHI /* Since version 4.5, gcc also allows one to specify the message printed
291*820c1a8dSHiroo HAYASHI    when a deprecated function is used.  clang claims to be gcc 4.2, but
292*820c1a8dSHiroo HAYASHI    may also support this feature.  */
293*820c1a8dSHiroo HAYASHI #if __GNUC_PREREQ (4,5) \
294*820c1a8dSHiroo HAYASHI     || __glibc_has_extension (__attribute_deprecated_with_message__)
295*820c1a8dSHiroo HAYASHI # define __attribute_deprecated_msg__(msg) \
296*820c1a8dSHiroo HAYASHI 	 __attribute__ ((__deprecated__ (msg)))
297*820c1a8dSHiroo HAYASHI #else
298*820c1a8dSHiroo HAYASHI # define __attribute_deprecated_msg__(msg) __attribute_deprecated__
299*820c1a8dSHiroo HAYASHI #endif
300*820c1a8dSHiroo HAYASHI 
301*820c1a8dSHiroo HAYASHI /* At some point during the gcc 2.8 development the `format_arg' attribute
302*820c1a8dSHiroo HAYASHI    for functions was introduced.  We don't want to use it unconditionally
303*820c1a8dSHiroo HAYASHI    (although this would be possible) since it generates warnings.
304*820c1a8dSHiroo HAYASHI    If several `format_arg' attributes are given for the same function, in
305*820c1a8dSHiroo HAYASHI    gcc-3.0 and older, all but the last one are ignored.  In newer gccs,
306*820c1a8dSHiroo HAYASHI    all designated arguments are considered.  */
307*820c1a8dSHiroo HAYASHI #if __GNUC_PREREQ (2,8) || __glibc_has_attribute (__format_arg__)
308*820c1a8dSHiroo HAYASHI # define __attribute_format_arg__(x) __attribute__ ((__format_arg__ (x)))
309*820c1a8dSHiroo HAYASHI #else
310*820c1a8dSHiroo HAYASHI # define __attribute_format_arg__(x) /* Ignore */
311*820c1a8dSHiroo HAYASHI #endif
312*820c1a8dSHiroo HAYASHI 
313*820c1a8dSHiroo HAYASHI /* At some point during the gcc 2.97 development the `strfmon' format
314*820c1a8dSHiroo HAYASHI    attribute for functions was introduced.  We don't want to use it
315*820c1a8dSHiroo HAYASHI    unconditionally (although this would be possible) since it
316*820c1a8dSHiroo HAYASHI    generates warnings.  */
317*820c1a8dSHiroo HAYASHI #if __GNUC_PREREQ (2,97) || __glibc_has_attribute (__format__)
318*820c1a8dSHiroo HAYASHI # define __attribute_format_strfmon__(a,b) \
319*820c1a8dSHiroo HAYASHI   __attribute__ ((__format__ (__strfmon__, a, b)))
320*820c1a8dSHiroo HAYASHI #else
321*820c1a8dSHiroo HAYASHI # define __attribute_format_strfmon__(a,b) /* Ignore */
322*820c1a8dSHiroo HAYASHI #endif
323*820c1a8dSHiroo HAYASHI 
324*820c1a8dSHiroo HAYASHI /* The nonnull function attribute marks pointer parameters that
325*820c1a8dSHiroo HAYASHI    must not be NULL.  This has the name __nonnull in glibc,
326*820c1a8dSHiroo HAYASHI    and __attribute_nonnull__ in files shared with Gnulib to avoid
327*820c1a8dSHiroo HAYASHI    collision with a different __nonnull in DragonFlyBSD 5.9.  */
328*820c1a8dSHiroo HAYASHI #ifndef __attribute_nonnull__
329*820c1a8dSHiroo HAYASHI # if __GNUC_PREREQ (3,3) || __glibc_has_attribute (__nonnull__)
330*820c1a8dSHiroo HAYASHI #  define __attribute_nonnull__(params) __attribute__ ((__nonnull__ params))
331*820c1a8dSHiroo HAYASHI # else
332*820c1a8dSHiroo HAYASHI #  define __attribute_nonnull__(params)
333*820c1a8dSHiroo HAYASHI # endif
334*820c1a8dSHiroo HAYASHI #endif
335*820c1a8dSHiroo HAYASHI #ifndef __nonnull
336*820c1a8dSHiroo HAYASHI # define __nonnull(params) __attribute_nonnull__ (params)
337*820c1a8dSHiroo HAYASHI #endif
338*820c1a8dSHiroo HAYASHI 
339*820c1a8dSHiroo HAYASHI /* If fortification mode, we warn about unused results of certain
340*820c1a8dSHiroo HAYASHI    function calls which can lead to problems.  */
341*820c1a8dSHiroo HAYASHI #if __GNUC_PREREQ (3,4) || __glibc_has_attribute (__warn_unused_result__)
342*820c1a8dSHiroo HAYASHI # define __attribute_warn_unused_result__ \
343*820c1a8dSHiroo HAYASHI    __attribute__ ((__warn_unused_result__))
344*820c1a8dSHiroo HAYASHI # if defined __USE_FORTIFY_LEVEL && __USE_FORTIFY_LEVEL > 0
345*820c1a8dSHiroo HAYASHI #  define __wur __attribute_warn_unused_result__
346*820c1a8dSHiroo HAYASHI # endif
347*820c1a8dSHiroo HAYASHI #else
348*820c1a8dSHiroo HAYASHI # define __attribute_warn_unused_result__ /* empty */
349*820c1a8dSHiroo HAYASHI #endif
350*820c1a8dSHiroo HAYASHI #ifndef __wur
351*820c1a8dSHiroo HAYASHI # define __wur /* Ignore */
352*820c1a8dSHiroo HAYASHI #endif
353*820c1a8dSHiroo HAYASHI 
354*820c1a8dSHiroo HAYASHI /* Forces a function to be always inlined.  */
355*820c1a8dSHiroo HAYASHI #if __GNUC_PREREQ (3,2) || __glibc_has_attribute (__always_inline__)
356*820c1a8dSHiroo HAYASHI /* The Linux kernel defines __always_inline in stddef.h (283d7573), and
357*820c1a8dSHiroo HAYASHI    it conflicts with this definition.  Therefore undefine it first to
358*820c1a8dSHiroo HAYASHI    allow either header to be included first.  */
359*820c1a8dSHiroo HAYASHI # undef __always_inline
360*820c1a8dSHiroo HAYASHI # define __always_inline __inline __attribute__ ((__always_inline__))
361*820c1a8dSHiroo HAYASHI #else
362*820c1a8dSHiroo HAYASHI # undef __always_inline
363*820c1a8dSHiroo HAYASHI # define __always_inline __inline
364*820c1a8dSHiroo HAYASHI #endif
365*820c1a8dSHiroo HAYASHI 
366*820c1a8dSHiroo HAYASHI /* Associate error messages with the source location of the call site rather
367*820c1a8dSHiroo HAYASHI    than with the source location inside the function.  */
368*820c1a8dSHiroo HAYASHI #if __GNUC_PREREQ (4,3) || __glibc_has_attribute (__artificial__)
369*820c1a8dSHiroo HAYASHI # define __attribute_artificial__ __attribute__ ((__artificial__))
370*820c1a8dSHiroo HAYASHI #else
371*820c1a8dSHiroo HAYASHI # define __attribute_artificial__ /* Ignore */
372*820c1a8dSHiroo HAYASHI #endif
373*820c1a8dSHiroo HAYASHI 
374*820c1a8dSHiroo HAYASHI /* GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99
375*820c1a8dSHiroo HAYASHI    inline semantics, unless -fgnu89-inline is used.  Using __GNUC_STDC_INLINE__
376*820c1a8dSHiroo HAYASHI    or __GNUC_GNU_INLINE is not a good enough check for gcc because gcc versions
377*820c1a8dSHiroo HAYASHI    older than 4.3 may define these macros and still not guarantee GNU inlining
378*820c1a8dSHiroo HAYASHI    semantics.
379*820c1a8dSHiroo HAYASHI 
380*820c1a8dSHiroo HAYASHI    clang++ identifies itself as gcc-4.2, but has support for GNU inlining
381*820c1a8dSHiroo HAYASHI    semantics, that can be checked for by using the __GNUC_STDC_INLINE_ and
382*820c1a8dSHiroo HAYASHI    __GNUC_GNU_INLINE__ macro definitions.  */
383*820c1a8dSHiroo HAYASHI #if (!defined __cplusplus || __GNUC_PREREQ (4,3) \
384*820c1a8dSHiroo HAYASHI      || (defined __clang__ && (defined __GNUC_STDC_INLINE__ \
385*820c1a8dSHiroo HAYASHI 			       || defined __GNUC_GNU_INLINE__)))
386*820c1a8dSHiroo HAYASHI # if defined __GNUC_STDC_INLINE__ || defined __cplusplus
387*820c1a8dSHiroo HAYASHI #  define __extern_inline extern __inline __attribute__ ((__gnu_inline__))
388*820c1a8dSHiroo HAYASHI #  define __extern_always_inline \
389*820c1a8dSHiroo HAYASHI   extern __always_inline __attribute__ ((__gnu_inline__))
390*820c1a8dSHiroo HAYASHI # else
391*820c1a8dSHiroo HAYASHI #  define __extern_inline extern __inline
392*820c1a8dSHiroo HAYASHI #  define __extern_always_inline extern __always_inline
393*820c1a8dSHiroo HAYASHI # endif
394*820c1a8dSHiroo HAYASHI #endif
395*820c1a8dSHiroo HAYASHI 
396*820c1a8dSHiroo HAYASHI #ifdef __extern_always_inline
397*820c1a8dSHiroo HAYASHI # define __fortify_function __extern_always_inline __attribute_artificial__
398*820c1a8dSHiroo HAYASHI #endif
399*820c1a8dSHiroo HAYASHI 
400*820c1a8dSHiroo HAYASHI /* GCC 4.3 and above allow passing all anonymous arguments of an
401*820c1a8dSHiroo HAYASHI    __extern_always_inline function to some other vararg function.  */
402*820c1a8dSHiroo HAYASHI #if __GNUC_PREREQ (4,3)
403*820c1a8dSHiroo HAYASHI # define __va_arg_pack() __builtin_va_arg_pack ()
404*820c1a8dSHiroo HAYASHI # define __va_arg_pack_len() __builtin_va_arg_pack_len ()
405*820c1a8dSHiroo HAYASHI #endif
406*820c1a8dSHiroo HAYASHI 
407*820c1a8dSHiroo HAYASHI /* It is possible to compile containing GCC extensions even if GCC is
408*820c1a8dSHiroo HAYASHI    run in pedantic mode if the uses are carefully marked using the
409*820c1a8dSHiroo HAYASHI    `__extension__' keyword.  But this is not generally available before
410*820c1a8dSHiroo HAYASHI    version 2.8.  */
411*820c1a8dSHiroo HAYASHI #if !(__GNUC_PREREQ (2,8) || defined __clang__)
412*820c1a8dSHiroo HAYASHI # define __extension__		/* Ignore */
413*820c1a8dSHiroo HAYASHI #endif
414*820c1a8dSHiroo HAYASHI 
415*820c1a8dSHiroo HAYASHI /* __restrict is known in EGCS 1.2 and above, and in clang.
416*820c1a8dSHiroo HAYASHI    It works also in C++ mode (outside of arrays), but only when spelled
417*820c1a8dSHiroo HAYASHI    as '__restrict', not 'restrict'.  */
418*820c1a8dSHiroo HAYASHI #if !(__GNUC_PREREQ (2,92) || __clang_major__ >= 3)
419*820c1a8dSHiroo HAYASHI # if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
420*820c1a8dSHiroo HAYASHI #  define __restrict	restrict
421*820c1a8dSHiroo HAYASHI # else
422*820c1a8dSHiroo HAYASHI #  define __restrict	/* Ignore */
423*820c1a8dSHiroo HAYASHI # endif
424*820c1a8dSHiroo HAYASHI #endif
425*820c1a8dSHiroo HAYASHI 
426*820c1a8dSHiroo HAYASHI /* ISO C99 also allows to declare arrays as non-overlapping.  The syntax is
427*820c1a8dSHiroo HAYASHI      array_name[restrict]
428*820c1a8dSHiroo HAYASHI    GCC 3.1 and clang support this.
429*820c1a8dSHiroo HAYASHI    This syntax is not usable in C++ mode.  */
430*820c1a8dSHiroo HAYASHI #if (__GNUC_PREREQ (3,1) || __clang_major__ >= 3) && !defined __cplusplus
431*820c1a8dSHiroo HAYASHI # define __restrict_arr	__restrict
432*820c1a8dSHiroo HAYASHI #else
433*820c1a8dSHiroo HAYASHI # ifdef __GNUC__
434*820c1a8dSHiroo HAYASHI #  define __restrict_arr	/* Not supported in old GCC.  */
435*820c1a8dSHiroo HAYASHI # else
436*820c1a8dSHiroo HAYASHI #  if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
437*820c1a8dSHiroo HAYASHI #   define __restrict_arr	restrict
438*820c1a8dSHiroo HAYASHI #  else
439*820c1a8dSHiroo HAYASHI /* Some other non-C99 compiler.  */
440*820c1a8dSHiroo HAYASHI #   define __restrict_arr	/* Not supported.  */
441*820c1a8dSHiroo HAYASHI #  endif
442*820c1a8dSHiroo HAYASHI # endif
443*820c1a8dSHiroo HAYASHI #endif
444*820c1a8dSHiroo HAYASHI 
445*820c1a8dSHiroo HAYASHI #if (__GNUC__ >= 3) || __glibc_has_builtin (__builtin_expect)
446*820c1a8dSHiroo HAYASHI # define __glibc_unlikely(cond)	__builtin_expect ((cond), 0)
447*820c1a8dSHiroo HAYASHI # define __glibc_likely(cond)	__builtin_expect ((cond), 1)
448*820c1a8dSHiroo HAYASHI #else
449*820c1a8dSHiroo HAYASHI # define __glibc_unlikely(cond)	(cond)
450*820c1a8dSHiroo HAYASHI # define __glibc_likely(cond)	(cond)
451*820c1a8dSHiroo HAYASHI #endif
452*820c1a8dSHiroo HAYASHI 
453*820c1a8dSHiroo HAYASHI #if (!defined _Noreturn \
454*820c1a8dSHiroo HAYASHI      && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \
455*820c1a8dSHiroo HAYASHI      &&  !(__GNUC_PREREQ (4,7) \
456*820c1a8dSHiroo HAYASHI            || (3 < __clang_major__ + (5 <= __clang_minor__))))
457*820c1a8dSHiroo HAYASHI # if __GNUC_PREREQ (2,8)
458*820c1a8dSHiroo HAYASHI #  define _Noreturn __attribute__ ((__noreturn__))
459*820c1a8dSHiroo HAYASHI # else
460*820c1a8dSHiroo HAYASHI #  define _Noreturn
461*820c1a8dSHiroo HAYASHI # endif
462*820c1a8dSHiroo HAYASHI #endif
463*820c1a8dSHiroo HAYASHI 
464*820c1a8dSHiroo HAYASHI #if __GNUC_PREREQ (8, 0)
465*820c1a8dSHiroo HAYASHI /* Describes a char array whose address can safely be passed as the first
466*820c1a8dSHiroo HAYASHI    argument to strncpy and strncat, as the char array is not necessarily
467*820c1a8dSHiroo HAYASHI    a NUL-terminated string.  */
468*820c1a8dSHiroo HAYASHI # define __attribute_nonstring__ __attribute__ ((__nonstring__))
469*820c1a8dSHiroo HAYASHI #else
470*820c1a8dSHiroo HAYASHI # define __attribute_nonstring__
471*820c1a8dSHiroo HAYASHI #endif
472*820c1a8dSHiroo HAYASHI 
473*820c1a8dSHiroo HAYASHI /* Undefine (also defined in libc-symbols.h).  */
474*820c1a8dSHiroo HAYASHI #undef __attribute_copy__
475*820c1a8dSHiroo HAYASHI #if __GNUC_PREREQ (9, 0)
476*820c1a8dSHiroo HAYASHI /* Copies attributes from the declaration or type referenced by
477*820c1a8dSHiroo HAYASHI    the argument.  */
478*820c1a8dSHiroo HAYASHI # define __attribute_copy__(arg) __attribute__ ((__copy__ (arg)))
479*820c1a8dSHiroo HAYASHI #else
480*820c1a8dSHiroo HAYASHI # define __attribute_copy__(arg)
481*820c1a8dSHiroo HAYASHI #endif
482*820c1a8dSHiroo HAYASHI 
483*820c1a8dSHiroo HAYASHI #if (!defined _Static_assert && !defined __cplusplus \
484*820c1a8dSHiroo HAYASHI      && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \
485*820c1a8dSHiroo HAYASHI      && (!(__GNUC_PREREQ (4, 6) || __clang_major__ >= 4) \
486*820c1a8dSHiroo HAYASHI          || defined __STRICT_ANSI__))
487*820c1a8dSHiroo HAYASHI # define _Static_assert(expr, diagnostic) \
488*820c1a8dSHiroo HAYASHI     extern int (*__Static_assert_function (void)) \
489*820c1a8dSHiroo HAYASHI       [!!sizeof (struct { int __error_if_negative: (expr) ? 2 : -1; })]
490*820c1a8dSHiroo HAYASHI #endif
491*820c1a8dSHiroo HAYASHI 
492*820c1a8dSHiroo HAYASHI /* Gnulib avoids including these, as they don't work on non-glibc or
493*820c1a8dSHiroo HAYASHI    older glibc platforms.  */
494*820c1a8dSHiroo HAYASHI #ifndef __GNULIB_CDEFS
495*820c1a8dSHiroo HAYASHI # include <bits/wordsize.h>
496*820c1a8dSHiroo HAYASHI # include <bits/long-double.h>
497*820c1a8dSHiroo HAYASHI #endif
498*820c1a8dSHiroo HAYASHI 
499*820c1a8dSHiroo HAYASHI #if __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1
500*820c1a8dSHiroo HAYASHI # ifdef __REDIRECT
501*820c1a8dSHiroo HAYASHI 
502*820c1a8dSHiroo HAYASHI /* Alias name defined automatically.  */
503*820c1a8dSHiroo HAYASHI #  define __LDBL_REDIR(name, proto) ... unused__ldbl_redir
504*820c1a8dSHiroo HAYASHI #  define __LDBL_REDIR_DECL(name) \
505*820c1a8dSHiroo HAYASHI   extern __typeof (name) name __asm (__ASMNAME ("__" #name "ieee128"));
506*820c1a8dSHiroo HAYASHI 
507*820c1a8dSHiroo HAYASHI /* Alias name defined automatically, with leading underscores.  */
508*820c1a8dSHiroo HAYASHI #  define __LDBL_REDIR2_DECL(name) \
509*820c1a8dSHiroo HAYASHI   extern __typeof (__##name) __##name \
510*820c1a8dSHiroo HAYASHI     __asm (__ASMNAME ("__" #name "ieee128"));
511*820c1a8dSHiroo HAYASHI 
512*820c1a8dSHiroo HAYASHI /* Alias name defined manually.  */
513*820c1a8dSHiroo HAYASHI #  define __LDBL_REDIR1(name, proto, alias) ... unused__ldbl_redir1
514*820c1a8dSHiroo HAYASHI #  define __LDBL_REDIR1_DECL(name, alias) \
515*820c1a8dSHiroo HAYASHI   extern __typeof (name) name __asm (__ASMNAME (#alias));
516*820c1a8dSHiroo HAYASHI 
517*820c1a8dSHiroo HAYASHI #  define __LDBL_REDIR1_NTH(name, proto, alias) \
518*820c1a8dSHiroo HAYASHI   __REDIRECT_NTH (name, proto, alias)
519*820c1a8dSHiroo HAYASHI #  define __REDIRECT_NTH_LDBL(name, proto, alias) \
520*820c1a8dSHiroo HAYASHI   __LDBL_REDIR1_NTH (name, proto, __##alias##ieee128)
521*820c1a8dSHiroo HAYASHI 
522*820c1a8dSHiroo HAYASHI /* Unused.  */
523*820c1a8dSHiroo HAYASHI #  define __REDIRECT_LDBL(name, proto, alias) ... unused__redirect_ldbl
524*820c1a8dSHiroo HAYASHI #  define __LDBL_REDIR_NTH(name, proto) ... unused__ldbl_redir_nth
525*820c1a8dSHiroo HAYASHI 
526*820c1a8dSHiroo HAYASHI # else
527*820c1a8dSHiroo HAYASHI _Static_assert (0, "IEEE 128-bits long double requires redirection on this platform");
528*820c1a8dSHiroo HAYASHI # endif
529*820c1a8dSHiroo HAYASHI #elif defined __LONG_DOUBLE_MATH_OPTIONAL && defined __NO_LONG_DOUBLE_MATH
530*820c1a8dSHiroo HAYASHI # define __LDBL_COMPAT 1
531*820c1a8dSHiroo HAYASHI # ifdef __REDIRECT
532*820c1a8dSHiroo HAYASHI #  define __LDBL_REDIR1(name, proto, alias) __REDIRECT (name, proto, alias)
533*820c1a8dSHiroo HAYASHI #  define __LDBL_REDIR(name, proto) \
534*820c1a8dSHiroo HAYASHI   __LDBL_REDIR1 (name, proto, __nldbl_##name)
535*820c1a8dSHiroo HAYASHI #  define __LDBL_REDIR1_NTH(name, proto, alias) __REDIRECT_NTH (name, proto, alias)
536*820c1a8dSHiroo HAYASHI #  define __LDBL_REDIR_NTH(name, proto) \
537*820c1a8dSHiroo HAYASHI   __LDBL_REDIR1_NTH (name, proto, __nldbl_##name)
538*820c1a8dSHiroo HAYASHI #  define __LDBL_REDIR2_DECL(name) \
539*820c1a8dSHiroo HAYASHI   extern __typeof (__##name) __##name __asm (__ASMNAME ("__nldbl___" #name));
540*820c1a8dSHiroo HAYASHI #  define __LDBL_REDIR1_DECL(name, alias) \
541*820c1a8dSHiroo HAYASHI   extern __typeof (name) name __asm (__ASMNAME (#alias));
542*820c1a8dSHiroo HAYASHI #  define __LDBL_REDIR_DECL(name) \
543*820c1a8dSHiroo HAYASHI   extern __typeof (name) name __asm (__ASMNAME ("__nldbl_" #name));
544*820c1a8dSHiroo HAYASHI #  define __REDIRECT_LDBL(name, proto, alias) \
545*820c1a8dSHiroo HAYASHI   __LDBL_REDIR1 (name, proto, __nldbl_##alias)
546*820c1a8dSHiroo HAYASHI #  define __REDIRECT_NTH_LDBL(name, proto, alias) \
547*820c1a8dSHiroo HAYASHI   __LDBL_REDIR1_NTH (name, proto, __nldbl_##alias)
548*820c1a8dSHiroo HAYASHI # endif
549*820c1a8dSHiroo HAYASHI #endif
550*820c1a8dSHiroo HAYASHI #if (!defined __LDBL_COMPAT && __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 0) \
551*820c1a8dSHiroo HAYASHI     || !defined __REDIRECT
552*820c1a8dSHiroo HAYASHI # define __LDBL_REDIR1(name, proto, alias) name proto
553*820c1a8dSHiroo HAYASHI # define __LDBL_REDIR(name, proto) name proto
554*820c1a8dSHiroo HAYASHI # define __LDBL_REDIR1_NTH(name, proto, alias) name proto __THROW
555*820c1a8dSHiroo HAYASHI # define __LDBL_REDIR_NTH(name, proto) name proto __THROW
556*820c1a8dSHiroo HAYASHI # define __LDBL_REDIR2_DECL(name)
557*820c1a8dSHiroo HAYASHI # define __LDBL_REDIR_DECL(name)
558*820c1a8dSHiroo HAYASHI # ifdef __REDIRECT
559*820c1a8dSHiroo HAYASHI #  define __REDIRECT_LDBL(name, proto, alias) __REDIRECT (name, proto, alias)
560*820c1a8dSHiroo HAYASHI #  define __REDIRECT_NTH_LDBL(name, proto, alias) \
561*820c1a8dSHiroo HAYASHI   __REDIRECT_NTH (name, proto, alias)
562*820c1a8dSHiroo HAYASHI # endif
563*820c1a8dSHiroo HAYASHI #endif
564*820c1a8dSHiroo HAYASHI 
565*820c1a8dSHiroo HAYASHI /* __glibc_macro_warning (MESSAGE) issues warning MESSAGE.  This is
566*820c1a8dSHiroo HAYASHI    intended for use in preprocessor macros.
567*820c1a8dSHiroo HAYASHI 
568*820c1a8dSHiroo HAYASHI    Note: MESSAGE must be a _single_ string; concatenation of string
569*820c1a8dSHiroo HAYASHI    literals is not supported.  */
570*820c1a8dSHiroo HAYASHI #if __GNUC_PREREQ (4,8) || __glibc_clang_prereq (3,5)
571*820c1a8dSHiroo HAYASHI # define __glibc_macro_warning1(message) _Pragma (#message)
572*820c1a8dSHiroo HAYASHI # define __glibc_macro_warning(message) \
573*820c1a8dSHiroo HAYASHI   __glibc_macro_warning1 (GCC warning message)
574*820c1a8dSHiroo HAYASHI #else
575*820c1a8dSHiroo HAYASHI # define __glibc_macro_warning(msg)
576*820c1a8dSHiroo HAYASHI #endif
577*820c1a8dSHiroo HAYASHI 
578*820c1a8dSHiroo HAYASHI /* Generic selection (ISO C11) is a C-only feature, available in GCC
579*820c1a8dSHiroo HAYASHI    since version 4.9.  Previous versions do not provide generic
580*820c1a8dSHiroo HAYASHI    selection, even though they might set __STDC_VERSION__ to 201112L,
581*820c1a8dSHiroo HAYASHI    when in -std=c11 mode.  Thus, we must check for !defined __GNUC__
582*820c1a8dSHiroo HAYASHI    when testing __STDC_VERSION__ for generic selection support.
583*820c1a8dSHiroo HAYASHI    On the other hand, Clang also defines __GNUC__, so a clang-specific
584*820c1a8dSHiroo HAYASHI    check is required to enable the use of generic selection.  */
585*820c1a8dSHiroo HAYASHI #if !defined __cplusplus \
586*820c1a8dSHiroo HAYASHI     && (__GNUC_PREREQ (4, 9) \
587*820c1a8dSHiroo HAYASHI 	|| __glibc_has_extension (c_generic_selections) \
588*820c1a8dSHiroo HAYASHI 	|| (!defined __GNUC__ && defined __STDC_VERSION__ \
589*820c1a8dSHiroo HAYASHI 	    && __STDC_VERSION__ >= 201112L))
590*820c1a8dSHiroo HAYASHI # define __HAVE_GENERIC_SELECTION 1
591*820c1a8dSHiroo HAYASHI #else
592*820c1a8dSHiroo HAYASHI # define __HAVE_GENERIC_SELECTION 0
593*820c1a8dSHiroo HAYASHI #endif
594*820c1a8dSHiroo HAYASHI 
595*820c1a8dSHiroo HAYASHI #if __GNUC_PREREQ (10, 0)
596*820c1a8dSHiroo HAYASHI /* Designates a 1-based positional argument ref-index of pointer type
597*820c1a8dSHiroo HAYASHI    that can be used to access size-index elements of the pointed-to
598*820c1a8dSHiroo HAYASHI    array according to access mode, or at least one element when
599*820c1a8dSHiroo HAYASHI    size-index is not provided:
600*820c1a8dSHiroo HAYASHI      access (access-mode, <ref-index> [, <size-index>])  */
601*820c1a8dSHiroo HAYASHI #define __attr_access(x) __attribute__ ((__access__ x))
602*820c1a8dSHiroo HAYASHI #else
603*820c1a8dSHiroo HAYASHI #  define __attr_access(x)
604*820c1a8dSHiroo HAYASHI #endif
605*820c1a8dSHiroo HAYASHI 
606*820c1a8dSHiroo HAYASHI /* Specify that a function such as setjmp or vfork may return
607*820c1a8dSHiroo HAYASHI    twice.  */
608*820c1a8dSHiroo HAYASHI #if __GNUC_PREREQ (4, 1)
609*820c1a8dSHiroo HAYASHI # define __attribute_returns_twice__ __attribute__ ((__returns_twice__))
610*820c1a8dSHiroo HAYASHI #else
611*820c1a8dSHiroo HAYASHI # define __attribute_returns_twice__ /* Ignore.  */
612*820c1a8dSHiroo HAYASHI #endif
613*820c1a8dSHiroo HAYASHI 
614*820c1a8dSHiroo HAYASHI #endif	 /* sys/cdefs.h */
615