1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 #ifndef _SYS_CDEFS_H
20 #define _SYS_CDEFS_H 1
21
22
23 #ifndef _FEATURES_H
24 # include <features.h>
25 #endif
26
27
28
29
30 #if defined __GNUC__ && !defined __STDC__
31 # error "You need a ISO C conforming compiler to use the glibc headers"
32 #endif
33
34
35 #undef __P
36 #undef __PMT
37
38
39
40
41
42 #if (defined __has_attribute \
43 && (!defined __clang_minor__ \
44 || (defined __apple_build_version__ \
45 ? 6000000 <= __apple_build_version__ \
46 : 3 < __clang_major__ + (5 <= __clang_minor__))))
47 # define __glibc_has_attribute(attr) __has_attribute (attr)
48 #else
49 # define __glibc_has_attribute(attr) 0
50 #endif
51 #ifdef __has_builtin
52 # define __glibc_has_builtin(name) __has_builtin (name)
53 #else
54 # define __glibc_has_builtin(name) 0
55 #endif
56 #ifdef __has_extension
57 # define __glibc_has_extension(ext) __has_extension (ext)
58 #else
59 # define __glibc_has_extension(ext) 0
60 #endif
61
62 #if defined __GNUC__ || defined __clang__
63
64
65
66 # if __GNUC_PREREQ (4, 6) && !defined _LIBC
67 # define __LEAF , __leaf__
68 # define __LEAF_ATTR __attribute__ ((__leaf__))
69 # else
70 # define __LEAF
71 # define __LEAF_ATTR
72 # endif
73
74
75
76
77
78
79 # if !defined __cplusplus \
80 && (__GNUC_PREREQ (3, 4) || __glibc_has_attribute (__nothrow__))
81 # define __THROW __attribute__ ((__nothrow__ __LEAF))
82 # define __THROWNL __attribute__ ((__nothrow__))
83 # define __NTH(fct) __attribute__ ((__nothrow__ __LEAF)) fct
84 # define __NTHNL(fct) __attribute__ ((__nothrow__)) fct
85 # else
86 # if defined __cplusplus && (__GNUC_PREREQ (2,8) || __clang_major >= 4)
87 # if __cplusplus >= 201103L
88 # define __THROW noexcept (true)
89 # else
90 # define __THROW throw ()
91 # endif
92 # define __THROWNL __THROW
93 # define __NTH(fct) __LEAF_ATTR fct __THROW
94 # define __NTHNL(fct) fct __THROW
95 # else
96 # define __THROW
97 # define __THROWNL
98 # define __NTH(fct) fct
99 # define __NTHNL(fct) fct
100 # endif
101 # endif
102
103 #else
104
105 # if (defined __cplusplus \
106 || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L))
107 # define __inline inline
108 # else
109 # define __inline
110 # endif
111
112 # define __THROW
113 # define __THROWNL
114 # define __NTH(fct) fct
115
116 #endif
117
118
119
120 #define __P(args) args
121 #define __PMT(args) args
122
123
124
125
126 #define __CONCAT(x,y) x ## y
127 #define __STRING(x) #x
128
129
130 #define __ptr_t void *
131
132
133
134 #ifdef __cplusplus
135 # define __BEGIN_DECLS extern "C" {
136 # define __END_DECLS }
137 #else
138 # define __BEGIN_DECLS
139 # define __END_DECLS
140 #endif
141
142
143
144
145
146 #ifndef __GNULIB_CDEFS
147
148
149 # define __bos(ptr) __builtin_object_size (ptr, __USE_FORTIFY_LEVEL > 1)
150 # define __bos0(ptr) __builtin_object_size (ptr, 0)
151
152
153 # if __USE_FORTIFY_LEVEL == 3 && (__glibc_clang_prereq (9, 0) \
154 || __GNUC_PREREQ (12, 0))
155 # define __glibc_objsize0(__o) __builtin_dynamic_object_size (__o, 0)
156 # define __glibc_objsize(__o) __builtin_dynamic_object_size (__o, 1)
157 # else
158 # define __glibc_objsize0(__o) __bos0 (__o)
159 # define __glibc_objsize(__o) __bos (__o)
160 # endif
161
162
163
164
165
166 # define __glibc_safe_len_cond(__l, __s, __osz) ((__l) <= (__osz) / (__s))
167 # define __glibc_unsigned_or_positive(__l) \
168 ((__typeof (__l)) 0 < (__typeof (__l)) -1 \
169 || (__builtin_constant_p (__l) && (__l) > 0))
170
171
172
173 # define __glibc_safe_or_unknown_len(__l, __s, __osz) \
174 ((__osz) == (__SIZE_TYPE__) -1 \
175 || (__glibc_unsigned_or_positive (__l) \
176 && __builtin_constant_p (__glibc_safe_len_cond ((__SIZE_TYPE__) (__l), \
177 (__s), (__osz))) \
178 && __glibc_safe_len_cond ((__SIZE_TYPE__) (__l), (__s), (__osz))))
179
180
181
182
183 # define __glibc_unsafe_len(__l, __s, __osz) \
184 (__glibc_unsigned_or_positive (__l) \
185 && __builtin_constant_p (__glibc_safe_len_cond ((__SIZE_TYPE__) (__l), \
186 __s, __osz)) \
187 && !__glibc_safe_len_cond ((__SIZE_TYPE__) (__l), __s, __osz))
188
189
190
191
192 # define __glibc_fortify(f, __l, __s, __osz, ...) \
193 (__glibc_safe_or_unknown_len (__l, __s, __osz) \
194 ? __ ## f ## _alias (__VA_ARGS__) \
195 : (__glibc_unsafe_len (__l, __s, __osz) \
196 ? __ ## f ## _chk_warn (__VA_ARGS__, __osz) \
197 : __ ## f ## _chk (__VA_ARGS__, __osz))) \
198
199
200
201
202 # define __glibc_fortify_n(f, __l, __s, __osz, ...) \
203 (__glibc_safe_or_unknown_len (__l, __s, __osz) \
204 ? __ ## f ## _alias (__VA_ARGS__) \
205 : (__glibc_unsafe_len (__l, __s, __osz) \
206 ? __ ## f ## _chk_warn (__VA_ARGS__, (__osz) / (__s)) \
207 : __ ## f ## _chk (__VA_ARGS__, (__osz) / (__s)))) \
208
209 #endif
210
211
212 #if __GNUC_PREREQ (4,3)
213 # define __warnattr(msg) __attribute__((__warning__ (msg)))
214 # define __errordecl(name, msg) \
215 extern void name (void) __attribute__((__error__ (msg)))
216 #else
217 # define __warnattr(msg)
218 # define __errordecl(name, msg) extern void name (void)
219 #endif
220
221
222
223
224
225 #if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L && !defined __HP_cc
226 # define __flexarr []
227 # define __glibc_c99_flexarr_available 1
228 #elif __GNUC_PREREQ (2,97) || defined __clang__
229
230
231 # define __flexarr []
232 # define __glibc_c99_flexarr_available 1
233 #elif defined __GNUC__
234
235
236 # define __flexarr [0]
237 # define __glibc_c99_flexarr_available 1
238 #else
239
240 # define __flexarr [1]
241 # define __glibc_c99_flexarr_available 0
242 #endif
243
244
245
246
247
248
249
250
251
252
253
254
255 #if (defined __GNUC__ && __GNUC__ >= 2) || (__clang_major__ >= 4)
256
257 # define __REDIRECT(name, proto, alias) name proto __asm__ (__ASMNAME (#alias))
258 # ifdef __cplusplus
259 # define __REDIRECT_NTH(name, proto, alias) \
260 name proto __THROW __asm__ (__ASMNAME (#alias))
261 # define __REDIRECT_NTHNL(name, proto, alias) \
262 name proto __THROWNL __asm__ (__ASMNAME (#alias))
263 # else
264 # define __REDIRECT_NTH(name, proto, alias) \
265 name proto __asm__ (__ASMNAME (#alias)) __THROW
266 # define __REDIRECT_NTHNL(name, proto, alias) \
267 name proto __asm__ (__ASMNAME (#alias)) __THROWNL
268 # endif
269 # define __ASMNAME(cname) __ASMNAME2 (__USER_LABEL_PREFIX__, cname)
270 # define __ASMNAME2(prefix, cname) __STRING (prefix) cname
271
272
273
274
275
276
277
278 #endif
279
280
281
282
283 #if !(defined __GNUC__ || defined __clang__)
284 # define __attribute__(xyz)
285 #endif
286
287
288
289
290 #if __GNUC_PREREQ (2,96) || __glibc_has_attribute (__malloc__)
291 # define __attribute_malloc__ __attribute__ ((__malloc__))
292 #else
293 # define __attribute_malloc__
294 #endif
295
296
297
298 #if __GNUC_PREREQ (4, 3)
299 # define __attribute_alloc_size__(params) \
300 __attribute__ ((__alloc_size__ params))
301 #else
302 # define __attribute_alloc_size__(params)
303 #endif
304
305
306
307 #if __GNUC_PREREQ (4, 9) || __glibc_has_attribute (__alloc_align__)
308 # define __attribute_alloc_align__(param) \
309 __attribute__ ((__alloc_align__ param))
310 #else
311 # define __attribute_alloc_align__(param)
312 #endif
313
314
315
316
317 #if __GNUC_PREREQ (2,96) || __glibc_has_attribute (__pure__)
318 # define __attribute_pure__ __attribute__ ((__pure__))
319 #else
320 # define __attribute_pure__
321 #endif
322
323
324 #if __GNUC_PREREQ (2,5) || __glibc_has_attribute (__const__)
325 # define __attribute_const__ __attribute__ ((__const__))
326 #else
327 # define __attribute_const__
328 #endif
329
330 #if __GNUC_PREREQ (2,7) || __glibc_has_attribute (__unused__)
331 # define __attribute_maybe_unused__ __attribute__ ((__unused__))
332 #else
333 # define __attribute_maybe_unused__
334 #endif
335
336
337
338
339 #if __GNUC_PREREQ (3,1) || __glibc_has_attribute (__used__)
340 # define __attribute_used__ __attribute__ ((__used__))
341 # define __attribute_noinline__ __attribute__ ((__noinline__))
342 #else
343 # define __attribute_used__ __attribute__ ((__unused__))
344 # define __attribute_noinline__
345 #endif
346
347
348 #if __GNUC_PREREQ (3,2) || __glibc_has_attribute (__deprecated__)
349 # define __attribute_deprecated__ __attribute__ ((__deprecated__))
350 #else
351 # define __attribute_deprecated__
352 #endif
353
354
355
356
357 #if __GNUC_PREREQ (4,5) \
358 || __glibc_has_extension (__attribute_deprecated_with_message__)
359 # define __attribute_deprecated_msg__(msg) \
360 __attribute__ ((__deprecated__ (msg)))
361 #else
362 # define __attribute_deprecated_msg__(msg) __attribute_deprecated__
363 #endif
364
365
366
367
368
369
370
371 #if __GNUC_PREREQ (2,8) || __glibc_has_attribute (__format_arg__)
372 # define __attribute_format_arg__(x) __attribute__ ((__format_arg__ (x)))
373 #else
374 # define __attribute_format_arg__(x)
375 #endif
376
377
378
379
380
381 #if __GNUC_PREREQ (2,97) || __glibc_has_attribute (__format__)
382 # define __attribute_format_strfmon__(a,b) \
383 __attribute__ ((__format__ (__strfmon__, a, b)))
384 #else
385 # define __attribute_format_strfmon__(a,b)
386 #endif
387
388
389
390
391
392 #ifndef __attribute_nonnull__
393 # if __GNUC_PREREQ (3,3) || __glibc_has_attribute (__nonnull__)
394 # define __attribute_nonnull__(params) __attribute__ ((__nonnull__ params))
395 # else
396 # define __attribute_nonnull__(params)
397 # endif
398 #endif
399 #ifndef __nonnull
400 # define __nonnull(params) __attribute_nonnull__ (params)
401 #endif
402
403
404
405 #ifndef __returns_nonnull
406 # if __GNUC_PREREQ (4, 9) || __glibc_has_attribute (__returns_nonnull__)
407 # define __returns_nonnull __attribute__ ((__returns_nonnull__))
408 # else
409 # define __returns_nonnull
410 # endif
411 #endif
412
413
414
415 #if __GNUC_PREREQ (3,4) || __glibc_has_attribute (__warn_unused_result__)
416 # define __attribute_warn_unused_result__ \
417 __attribute__ ((__warn_unused_result__))
418 # if defined __USE_FORTIFY_LEVEL && __USE_FORTIFY_LEVEL > 0
419 # define __wur __attribute_warn_unused_result__
420 # endif
421 #else
422 # define __attribute_warn_unused_result__
423 #endif
424 #ifndef __wur
425 # define __wur
426 #endif
427
428
429 #if __GNUC_PREREQ (3,2) || __glibc_has_attribute (__always_inline__)
430
431
432
433 # undef __always_inline
434 # define __always_inline __inline __attribute__ ((__always_inline__))
435 #else
436 # undef __always_inline
437 # define __always_inline __inline
438 #endif
439
440
441
442 #if __GNUC_PREREQ (4,3) || __glibc_has_attribute (__artificial__)
443 # define __attribute_artificial__ __attribute__ ((__artificial__))
444 #else
445 # define __attribute_artificial__
446 #endif
447
448
449
450
451
452
453
454
455
456
457 #if (!defined __cplusplus || __GNUC_PREREQ (4,3) \
458 || (defined __clang__ && (defined __GNUC_STDC_INLINE__ \
459 || defined __GNUC_GNU_INLINE__)))
460 # if defined __GNUC_STDC_INLINE__ || defined __cplusplus
461 # define __extern_inline extern __inline __attribute__ ((__gnu_inline__))
462 # define __extern_always_inline \
463 extern __always_inline __attribute__ ((__gnu_inline__))
464 # else
465 # define __extern_inline extern __inline
466 # define __extern_always_inline extern __always_inline
467 # endif
468 #endif
469
470 #ifdef __extern_always_inline
471 # define __fortify_function __extern_always_inline __attribute_artificial__
472 #endif
473
474
475
476 #if __GNUC_PREREQ (4,3)
477 # define __va_arg_pack() __builtin_va_arg_pack ()
478 # define __va_arg_pack_len() __builtin_va_arg_pack_len ()
479 #endif
480
481
482
483
484
485 #if !(__GNUC_PREREQ (2,8) || defined __clang__)
486 # define __extension__
487 #endif
488
489
490
491
492 #if !(__GNUC_PREREQ (2,92) || __clang_major__ >= 3)
493 # if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
494 # define __restrict restrict
495 # else
496 # define __restrict
497 # endif
498 #endif
499
500
501
502
503
504 #if (__GNUC_PREREQ (3,1) || __clang_major__ >= 3) && !defined __cplusplus
505 # define __restrict_arr __restrict
506 #else
507 # ifdef __GNUC__
508 # define __restrict_arr
509 # else
510 # if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
511 # define __restrict_arr restrict
512 # else
513
514 # define __restrict_arr
515 # endif
516 # endif
517 #endif
518
519 #if (__GNUC__ >= 3) || __glibc_has_builtin (__builtin_expect)
520 # define __glibc_unlikely(cond) __builtin_expect ((cond), 0)
521 # define __glibc_likely(cond) __builtin_expect ((cond), 1)
522 #else
523 # define __glibc_unlikely(cond) (cond)
524 # define __glibc_likely(cond) (cond)
525 #endif
526
527 #if (!defined _Noreturn \
528 && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \
529 && !(__GNUC_PREREQ (4,7) \
530 || (3 < __clang_major__ + (5 <= __clang_minor__))))
531 # if __GNUC_PREREQ (2,8)
532 # define _Noreturn __attribute__ ((__noreturn__))
533 # else
534 # define _Noreturn
535 # endif
536 #endif
537
538 #if __GNUC_PREREQ (8, 0)
539
540
541
542 # define __attribute_nonstring__ __attribute__ ((__nonstring__))
543 #else
544 # define __attribute_nonstring__
545 #endif
546
547
548 #undef __attribute_copy__
549 #if __GNUC_PREREQ (9, 0)
550
551
552 # define __attribute_copy__(arg) __attribute__ ((__copy__ (arg)))
553 #else
554 # define __attribute_copy__(arg)
555 #endif
556
557 #if (!defined _Static_assert && !defined __cplusplus \
558 && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \
559 && (!(__GNUC_PREREQ (4, 6) || __clang_major__ >= 4) \
560 || defined __STRICT_ANSI__))
561 # define _Static_assert(expr, diagnostic) \
562 extern int (*__Static_assert_function (void)) \
563 [!!sizeof (struct { int __error_if_negative: (expr) ? 2 : -1; })]
564 #endif
565
566
567
568 #ifndef __GNULIB_CDEFS
569 # include <bits/wordsize.h>
570 # include <bits/long-double.h>
571 #endif
572
573 #if __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1
574 # ifdef __REDIRECT
575
576
577 # define __LDBL_REDIR(name, proto) ... unused__ldbl_redir
578 # define __LDBL_REDIR_DECL(name) \
579 extern __typeof (name) name __asm (__ASMNAME ("__" #name "ieee128"));
580
581
582 # define __LDBL_REDIR2_DECL(name) \
583 extern __typeof (__##name) __##name \
584 __asm (__ASMNAME ("__" #name "ieee128"));
585
586
587 # define __LDBL_REDIR1(name, proto, alias) ... unused__ldbl_redir1
588 # define __LDBL_REDIR1_DECL(name, alias) \
589 extern __typeof (name) name __asm (__ASMNAME (#alias));
590
591 # define __LDBL_REDIR1_NTH(name, proto, alias) \
592 __REDIRECT_NTH (name, proto, alias)
593 # define __REDIRECT_NTH_LDBL(name, proto, alias) \
594 __LDBL_REDIR1_NTH (name, proto, __##alias##ieee128)
595
596
597 # define __REDIRECT_LDBL(name, proto, alias) ... unused__redirect_ldbl
598 # define __LDBL_REDIR_NTH(name, proto) ... unused__ldbl_redir_nth
599
600 # else
601 _Static_assert (0, "IEEE 128-bits long double requires redirection on this platform");
602 # endif
603 #elif defined __LONG_DOUBLE_MATH_OPTIONAL && defined __NO_LONG_DOUBLE_MATH
604 # define __LDBL_COMPAT 1
605 # ifdef __REDIRECT
606 # define __LDBL_REDIR1(name, proto, alias) __REDIRECT (name, proto, alias)
607 # define __LDBL_REDIR(name, proto) \
608 __LDBL_REDIR1 (name, proto, __nldbl_##name)
609 # define __LDBL_REDIR1_NTH(name, proto, alias) __REDIRECT_NTH (name, proto, alias)
610 # define __LDBL_REDIR_NTH(name, proto) \
611 __LDBL_REDIR1_NTH (name, proto, __nldbl_##name)
612 # define __LDBL_REDIR2_DECL(name) \
613 extern __typeof (__##name) __##name __asm (__ASMNAME ("__nldbl___" #name));
614 # define __LDBL_REDIR1_DECL(name, alias) \
615 extern __typeof (name) name __asm (__ASMNAME (#alias));
616 # define __LDBL_REDIR_DECL(name) \
617 extern __typeof (name) name __asm (__ASMNAME ("__nldbl_" #name));
618 # define __REDIRECT_LDBL(name, proto, alias) \
619 __LDBL_REDIR1 (name, proto, __nldbl_##alias)
620 # define __REDIRECT_NTH_LDBL(name, proto, alias) \
621 __LDBL_REDIR1_NTH (name, proto, __nldbl_##alias)
622 # endif
623 #endif
624 #if (!defined __LDBL_COMPAT && __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 0) \
625 || !defined __REDIRECT
626 # define __LDBL_REDIR1(name, proto, alias) name proto
627 # define __LDBL_REDIR(name, proto) name proto
628 # define __LDBL_REDIR1_NTH(name, proto, alias) name proto __THROW
629 # define __LDBL_REDIR_NTH(name, proto) name proto __THROW
630 # define __LDBL_REDIR2_DECL(name)
631 # define __LDBL_REDIR_DECL(name)
632 # ifdef __REDIRECT
633 # define __REDIRECT_LDBL(name, proto, alias) __REDIRECT (name, proto, alias)
634 # define __REDIRECT_NTH_LDBL(name, proto, alias) \
635 __REDIRECT_NTH (name, proto, alias)
636 # endif
637 #endif
638
639
640
641
642
643
644 #if __GNUC_PREREQ (4,8) || __glibc_clang_prereq (3,5)
645 # define __glibc_macro_warning1(message) _Pragma (#message)
646 # define __glibc_macro_warning(message) \
647 __glibc_macro_warning1 (GCC warning message)
648 #else
649 # define __glibc_macro_warning(msg)
650 #endif
651
652
653
654
655
656
657
658
659 #if !defined __cplusplus \
660 && (__GNUC_PREREQ (4, 9) \
661 || __glibc_has_extension (c_generic_selections) \
662 || (!defined __GNUC__ && defined __STDC_VERSION__ \
663 && __STDC_VERSION__ >= 201112L))
664 # define __HAVE_GENERIC_SELECTION 1
665 #else
666 # define __HAVE_GENERIC_SELECTION 0
667 #endif
668
669 #if __GNUC_PREREQ (10, 0)
670
671
672
673
674
675 # define __attr_access(x) __attribute__ ((__access__ x))
676
677
678
679
680 # if __USE_FORTIFY_LEVEL == 3
681 # define __fortified_attr_access(a, o, s) __attribute__ ((__access__ (a, o)))
682 # else
683 # define __fortified_attr_access(a, o, s) __attr_access ((a, o, s))
684 # endif
685 # if __GNUC_PREREQ (11, 0)
686 # define __attr_access_none(argno) __attribute__ ((__access__ (__none__, argno)))
687 # else
688 # define __attr_access_none(argno)
689 # endif
690 #else
691 # define __fortified_attr_access(a, o, s)
692 # define __attr_access(x)
693 # define __attr_access_none(argno)
694 #endif
695
696 #if __GNUC_PREREQ (11, 0)
697
698
699 # define __attr_dealloc(dealloc, argno) \
700 __attribute__ ((__malloc__ (dealloc, argno)))
701 # define __attr_dealloc_free __attr_dealloc (__builtin_free, 1)
702 #else
703 # define __attr_dealloc(dealloc, argno)
704 # define __attr_dealloc_free
705 #endif
706
707
708
709 #if __GNUC_PREREQ (4, 1)
710 # define __attribute_returns_twice__ __attribute__ ((__returns_twice__))
711 #else
712 # define __attribute_returns_twice__
713 #endif
714
715 #endif