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