cdefs.h 23 KB

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