1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 #ifndef _SYS_CDEFS_H
19 #define _SYS_CDEFS_H 1
20
21
22 #ifndef _FEATURES_H
23 # include <features.h>
24 #endif
25
26
27
28
29 #if defined __GNUC__ && !defined __STDC__
30 # error "You need a ISO C conforming compiler to use the glibc headers"
31 #endif
32
33
34 #undef __P
35 #undef __PMT
36
37
38
39
40
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
62
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
72
73
74
75
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
101
102 # if (defined __cplusplus \
103 || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L))
104 # define __inline inline
105 # else
106 # define __inline
107 # endif
108
109 # define __THROW
110 # define __THROWNL
111 # define __NTH(fct) fct
112
113 #endif
114
115
116
117 #define __P(args) args
118 #define __PMT(args) args
119
120
121
122
123 #define __CONCAT(x,y) x ## y
124 #define __STRING(x) #x
125
126
127 #define __ptr_t void *
128
129
130
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
141 #define __bos(ptr) __builtin_object_size (ptr, __USE_FORTIFY_LEVEL > 1)
142 #define __bos0(ptr) __builtin_object_size (ptr, 0)
143
144
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
163
164
165
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
171
172 # define __flexarr []
173 # define __glibc_c99_flexarr_available 1
174 #elif defined __GNUC__
175
176
177 # define __flexarr [0]
178 # define __glibc_c99_flexarr_available 1
179 #else
180
181 # define __flexarr [1]
182 # define __glibc_c99_flexarr_available 0
183 #endif
184
185
186
187
188
189
190
191
192
193
194
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
215
216
217
218
219 #endif
220
221
222
223
224 #if !(defined __GNUC__ || defined __clang__)
225 # define __attribute__(xyz)
226 #endif
227
228
229
230
231 #if __GNUC_PREREQ (2,96) || __glibc_has_attribute (__malloc__)
232 # define __attribute_malloc__ __attribute__ ((__malloc__))
233 #else
234 # define __attribute_malloc__
235 #endif
236
237
238
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)
244 #endif
245
246
247
248
249 #if __GNUC_PREREQ (2,96) || __glibc_has_attribute (__pure__)
250 # define __attribute_pure__ __attribute__ ((__pure__))
251 #else
252 # define __attribute_pure__
253 #endif
254
255
256 #if __GNUC_PREREQ (2,5) || __glibc_has_attribute (__const__)
257 # define __attribute_const__ __attribute__ ((__const__))
258 #else
259 # define __attribute_const__
260 #endif
261
262 #if __GNUC_PREREQ (2,7) || __glibc_has_attribute (__unused__)
263 # define __attribute_maybe_unused__ __attribute__ ((__unused__))
264 #else
265 # define __attribute_maybe_unused__
266 #endif
267
268
269
270
271 #if __GNUC_PREREQ (3,1) || __glibc_has_attribute (__used__)
272 # define __attribute_used__ __attribute__ ((__used__))
273 # define __attribute_noinline__ __attribute__ ((__noinline__))
274 #else
275 # define __attribute_used__ __attribute__ ((__unused__))
276 # define __attribute_noinline__
277 #endif
278
279
280 #if __GNUC_PREREQ (3,2) || __glibc_has_attribute (__deprecated__)
281 # define __attribute_deprecated__ __attribute__ ((__deprecated__))
282 #else
283 # define __attribute_deprecated__
284 #endif
285
286
287
288
289 #if __GNUC_PREREQ (4,5) \
290 || __glibc_has_extension (__attribute_deprecated_with_message__)
291 # define __attribute_deprecated_msg__(msg) \
292 __attribute__ ((__deprecated__ (msg)))
293 #else
294 # define __attribute_deprecated_msg__(msg) __attribute_deprecated__
295 #endif
296
297
298
299
300
301
302
303 #if __GNUC_PREREQ (2,8) || __glibc_has_attribute (__format_arg__)
304 # define __attribute_format_arg__(x) __attribute__ ((__format_arg__ (x)))
305 #else
306 # define __attribute_format_arg__(x)
307 #endif
308
309
310
311
312
313 #if __GNUC_PREREQ (2,97) || __glibc_has_attribute (__format__)
314 # define __attribute_format_strfmon__(a,b) \
315 __attribute__ ((__format__ (__strfmon__, a, b)))
316 #else
317 # define __attribute_format_strfmon__(a,b)
318 #endif
319
320
321
322
323
324 #ifndef __attribute_nonnull__
325 # if __GNUC_PREREQ (3,3) || __glibc_has_attribute (__nonnull__)
326 # define __attribute_nonnull__(params) __attribute__ ((__nonnull__ params))
327 # else
328 # define __attribute_nonnull__(params)
329 # endif
330 #endif
331 #ifndef __nonnull
332 # define __nonnull(params) __attribute_nonnull__ (params)
333 #endif
334
335
336
337 #ifndef __returns_nonnull
338 # if __GNUC_PREREQ (4, 9) || __glibc_has_attribute (__returns_nonnull__)
339 # define __returns_nonnull __attribute__ ((__returns_nonnull__))
340 # else
341 # define __returns_nonnull
342 # endif
343 #endif
344
345
346
347 #if __GNUC_PREREQ (3,4) || __glibc_has_attribute (__warn_unused_result__)
348 # define __attribute_warn_unused_result__ \
349 __attribute__ ((__warn_unused_result__))
350 # if defined __USE_FORTIFY_LEVEL && __USE_FORTIFY_LEVEL > 0
351 # define __wur __attribute_warn_unused_result__
352 # endif
353 #else
354 # define __attribute_warn_unused_result__
355 #endif
356 #ifndef __wur
357 # define __wur
358 #endif
359
360
361 #if __GNUC_PREREQ (3,2) || __glibc_has_attribute (__always_inline__)
362
363
364
365 # undef __always_inline
366 # define __always_inline __inline __attribute__ ((__always_inline__))
367 #else
368 # undef __always_inline
369 # define __always_inline __inline
370 #endif
371
372
373
374 #if __GNUC_PREREQ (4,3) || __glibc_has_attribute (__artificial__)
375 # define __attribute_artificial__ __attribute__ ((__artificial__))
376 #else
377 # define __attribute_artificial__
378 #endif
379
380
381
382
383
384
385
386
387
388
389 #if (!defined __cplusplus || __GNUC_PREREQ (4,3) \
390 || (defined __clang__ && (defined __GNUC_STDC_INLINE__ \
391 || defined __GNUC_GNU_INLINE__)))
392 # if defined __GNUC_STDC_INLINE__ || defined __cplusplus
393 # define __extern_inline extern __inline __attribute__ ((__gnu_inline__))
394 # define __extern_always_inline \
395 extern __always_inline __attribute__ ((__gnu_inline__))
396 # else
397 # define __extern_inline extern __inline
398 # define __extern_always_inline extern __always_inline
399 # endif
400 #endif
401
402 #ifdef __extern_always_inline
403 # define __fortify_function __extern_always_inline __attribute_artificial__
404 #endif
405
406
407
408 #if __GNUC_PREREQ (4,3)
409 # define __va_arg_pack() __builtin_va_arg_pack ()
410 # define __va_arg_pack_len() __builtin_va_arg_pack_len ()
411 #endif
412
413
414
415
416
417 #if !(__GNUC_PREREQ (2,8) || defined __clang__)
418 # define __extension__
419 #endif
420
421
422
423
424 #if !(__GNUC_PREREQ (2,92) || __clang_major__ >= 3)
425 # if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
426 # define __restrict restrict
427 # else
428 # define __restrict
429 # endif
430 #endif
431
432
433
434
435
436 #if (__GNUC_PREREQ (3,1) || __clang_major__ >= 3) && !defined __cplusplus
437 # define __restrict_arr __restrict
438 #else
439 # ifdef __GNUC__
440 # define __restrict_arr
441 # else
442 # if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
443 # define __restrict_arr restrict
444 # else
445
446 # define __restrict_arr
447 # endif
448 # endif
449 #endif
450
451 #if (__GNUC__ >= 3) || __glibc_has_builtin (__builtin_expect)
452 # define __glibc_unlikely(cond) __builtin_expect ((cond), 0)
453 # define __glibc_likely(cond) __builtin_expect ((cond), 1)
454 #else
455 # define __glibc_unlikely(cond) (cond)
456 # define __glibc_likely(cond) (cond)
457 #endif
458
459 #if (!defined _Noreturn \
460 && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \
461 && !(__GNUC_PREREQ (4,7) \
462 || (3 < __clang_major__ + (5 <= __clang_minor__))))
463 # if __GNUC_PREREQ (2,8)
464 # define _Noreturn __attribute__ ((__noreturn__))
465 # else
466 # define _Noreturn
467 # endif
468 #endif
469
470 #if __GNUC_PREREQ (8, 0)
471
472
473
474 # define __attribute_nonstring__ __attribute__ ((__nonstring__))
475 #else
476 # define __attribute_nonstring__
477 #endif
478
479
480 #undef __attribute_copy__
481 #if __GNUC_PREREQ (9, 0)
482
483
484 # define __attribute_copy__(arg) __attribute__ ((__copy__ (arg)))
485 #else
486 # define __attribute_copy__(arg)
487 #endif
488
489 #if (!defined _Static_assert && !defined __cplusplus \
490 && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \
491 && (!(__GNUC_PREREQ (4, 6) || __clang_major__ >= 4) \
492 || defined __STRICT_ANSI__))
493 # define _Static_assert(expr, diagnostic) \
494 extern int (*__Static_assert_function (void)) \
495 [!!sizeof (struct { int __error_if_negative: (expr) ? 2 : -1; })]
496 #endif
497
498
499
500 #ifndef __GNULIB_CDEFS
501 # include <bits/wordsize.h>
502 # include <bits/long-double.h>
503 #endif
504
505 #if __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1
506 # ifdef __REDIRECT
507
508
509 # define __LDBL_REDIR(name, proto) ... unused__ldbl_redir
510 # define __LDBL_REDIR_DECL(name) \
511 extern __typeof (name) name __asm (__ASMNAME ("__" #name "ieee128"));
512
513
514 # define __LDBL_REDIR2_DECL(name) \
515 extern __typeof (__##name) __##name \
516 __asm (__ASMNAME ("__" #name "ieee128"));
517
518
519 # define __LDBL_REDIR1(name, proto, alias) ... unused__ldbl_redir1
520 # define __LDBL_REDIR1_DECL(name, alias) \
521 extern __typeof (name) name __asm (__ASMNAME (#alias));
522
523 # define __LDBL_REDIR1_NTH(name, proto, alias) \
524 __REDIRECT_NTH (name, proto, alias)
525 # define __REDIRECT_NTH_LDBL(name, proto, alias) \
526 __LDBL_REDIR1_NTH (name, proto, __##alias##ieee128)
527
528
529 # define __REDIRECT_LDBL(name, proto, alias) ... unused__redirect_ldbl
530 # define __LDBL_REDIR_NTH(name, proto) ... unused__ldbl_redir_nth
531
532 # else
533 _Static_assert (0, "IEEE 128-bits long double requires redirection on this platform");
534 # endif
535 #elif defined __LONG_DOUBLE_MATH_OPTIONAL && defined __NO_LONG_DOUBLE_MATH
536 # define __LDBL_COMPAT 1
537 # ifdef __REDIRECT
538 # define __LDBL_REDIR1(name, proto, alias) __REDIRECT (name, proto, alias)
539 # define __LDBL_REDIR(name, proto) \
540 __LDBL_REDIR1 (name, proto, __nldbl_##name)
541 # define __LDBL_REDIR1_NTH(name, proto, alias) __REDIRECT_NTH (name, proto, alias)
542 # define __LDBL_REDIR_NTH(name, proto) \
543 __LDBL_REDIR1_NTH (name, proto, __nldbl_##name)
544 # define __LDBL_REDIR2_DECL(name) \
545 extern __typeof (__##name) __##name __asm (__ASMNAME ("__nldbl___" #name));
546 # define __LDBL_REDIR1_DECL(name, alias) \
547 extern __typeof (name) name __asm (__ASMNAME (#alias));
548 # define __LDBL_REDIR_DECL(name) \
549 extern __typeof (name) name __asm (__ASMNAME ("__nldbl_" #name));
550 # define __REDIRECT_LDBL(name, proto, alias) \
551 __LDBL_REDIR1 (name, proto, __nldbl_##alias)
552 # define __REDIRECT_NTH_LDBL(name, proto, alias) \
553 __LDBL_REDIR1_NTH (name, proto, __nldbl_##alias)
554 # endif
555 #endif
556 #if (!defined __LDBL_COMPAT && __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 0) \
557 || !defined __REDIRECT
558 # define __LDBL_REDIR1(name, proto, alias) name proto
559 # define __LDBL_REDIR(name, proto) name proto
560 # define __LDBL_REDIR1_NTH(name, proto, alias) name proto __THROW
561 # define __LDBL_REDIR_NTH(name, proto) name proto __THROW
562 # define __LDBL_REDIR2_DECL(name)
563 # define __LDBL_REDIR_DECL(name)
564 # ifdef __REDIRECT
565 # define __REDIRECT_LDBL(name, proto, alias) __REDIRECT (name, proto, alias)
566 # define __REDIRECT_NTH_LDBL(name, proto, alias) \
567 __REDIRECT_NTH (name, proto, alias)
568 # endif
569 #endif
570
571
572
573
574
575
576 #if __GNUC_PREREQ (4,8) || __glibc_clang_prereq (3,5)
577 # define __glibc_macro_warning1(message) _Pragma (#message)
578 # define __glibc_macro_warning(message) \
579 __glibc_macro_warning1 (GCC warning message)
580 #else
581 # define __glibc_macro_warning(msg)
582 #endif
583
584
585
586
587
588
589
590
591 #if !defined __cplusplus \
592 && (__GNUC_PREREQ (4, 9) \
593 || __glibc_has_extension (c_generic_selections) \
594 || (!defined __GNUC__ && defined __STDC_VERSION__ \
595 && __STDC_VERSION__ >= 201112L))
596 # define __HAVE_GENERIC_SELECTION 1
597 #else
598 # define __HAVE_GENERIC_SELECTION 0
599 #endif
600
601 #if __GNUC_PREREQ (10, 0)
602
603
604
605
606
607 # define __attr_access(x) __attribute__ ((__access__ x))
608 # if __GNUC_PREREQ (11, 0)
609 # define __attr_access_none(argno) __attribute__ ((__access__ (__none__, argno)))
610 # else
611 # define __attr_access_none(argno)
612 # endif
613 #else
614 # define __attr_access(x)
615 # define __attr_access_none(argno)
616 #endif
617
618 #if __GNUC_PREREQ (11, 0)
619
620
621 # define __attr_dealloc(dealloc, argno) \
622 __attribute__ ((__malloc__ (dealloc, argno)))
623 # define __attr_dealloc_free __attr_dealloc (__builtin_free, 1)
624 #else
625 # define __attr_dealloc(dealloc, argno)
626 # define __attr_dealloc_free
627 #endif
628
629
630
631 #if __GNUC_PREREQ (4, 1)
632 # define __attribute_returns_twice__ __attribute__ ((__returns_twice__))
633 #else
634 # define __attribute_returns_twice__
635 #endif
636
637 #endif