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