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