| 1 | /* Copyright (C) 1992-2025 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__ && !defined __cplusplus |
| 31 | # error "You need a ISO C or 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 | || 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 | /* All functions, except those with callbacks or those that |
| 63 | synchronize memory, are leaf functions. */ |
| 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 | /* GCC can always grok prototypes. For C++ programs we add throw() |
| 73 | to help it optimize the function calls. But this only works with |
| 74 | gcc 2.8.x and egcs. For gcc 3.4 and up we even mark C functions |
| 75 | as non-throwing using a function attribute since programs can use |
| 76 | the -fexceptions options for C code as well. */ |
| 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 | # if __GNUC_PREREQ (4, 3) || __glibc_has_attribute (__cold__) |
| 102 | # define __COLD __attribute__ ((__cold__)) |
| 103 | # else |
| 104 | # define __COLD |
| 105 | # endif |
| 106 | |
| 107 | #else /* Not GCC or clang. */ |
| 108 | |
| 109 | # if (defined __cplusplus \ |
| 110 | || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L)) |
| 111 | # define __inline inline |
| 112 | # else |
| 113 | # define __inline /* No inline functions. */ |
| 114 | # endif |
| 115 | |
| 116 | # define __THROW |
| 117 | # define __THROWNL |
| 118 | # define __NTH(fct) fct |
| 119 | # define __COLD |
| 120 | |
| 121 | #endif /* GCC || clang. */ |
| 122 | |
| 123 | /* These two macros are not used in glibc anymore. They are kept here |
| 124 | only because some other projects expect the macros to be defined. */ |
| 125 | #define __P(args) args |
| 126 | #define __PMT(args) args |
| 127 | |
| 128 | /* For these things, GCC behaves the ANSI way normally, |
| 129 | and the non-ANSI way under -traditional. */ |
| 130 | |
| 131 | #define __CONCAT(x,y) x ## y |
| 132 | #define __STRING(x) #x |
| 133 | |
| 134 | /* This is not a typedef so `const __ptr_t' does the right thing. */ |
| 135 | #define __ptr_t void * |
| 136 | |
| 137 | |
| 138 | /* C++ needs to know that types and declarations are C, not C++. */ |
| 139 | #ifdef __cplusplus |
| 140 | # define __BEGIN_DECLS extern "C" { |
| 141 | # define __END_DECLS } |
| 142 | #else |
| 143 | # define __BEGIN_DECLS |
| 144 | # define __END_DECLS |
| 145 | #endif |
| 146 | |
| 147 | |
| 148 | /* The overloadable attribute was added on clang 2.6. */ |
| 149 | #if defined __clang_major__ \ |
| 150 | && (__clang_major__ + (__clang_minor__ >= 6) > 2) |
| 151 | # define __attribute_overloadable__ __attribute__((__overloadable__)) |
| 152 | #else |
| 153 | # define __attribute_overloadable__ |
| 154 | #endif |
| 155 | |
| 156 | /* Fortify support. */ |
| 157 | #define __bos(ptr) __builtin_object_size (ptr, __USE_FORTIFY_LEVEL > 1) |
| 158 | #define __bos0(ptr) __builtin_object_size (ptr, 0) |
| 159 | |
| 160 | /* Use __builtin_dynamic_object_size at _FORTIFY_SOURCE=3 when available. */ |
| 161 | #if __USE_FORTIFY_LEVEL == 3 && (__glibc_clang_prereq (9, 0) \ |
| 162 | || __GNUC_PREREQ (12, 0)) |
| 163 | # define __glibc_objsize0(__o) __builtin_dynamic_object_size (__o, 0) |
| 164 | # define __glibc_objsize(__o) __builtin_dynamic_object_size (__o, 1) |
| 165 | #else |
| 166 | # define __glibc_objsize0(__o) __bos0 (__o) |
| 167 | # define __glibc_objsize(__o) __bos (__o) |
| 168 | #endif |
| 169 | |
| 170 | #if __USE_FORTIFY_LEVEL > 0 |
| 171 | /* Compile time conditions to choose between the regular, _chk and _chk_warn |
| 172 | variants. These conditions should get evaluated to constant and optimized |
| 173 | away. */ |
| 174 | |
| 175 | #define __glibc_safe_len_cond(__l, __s, __osz) ((__l) <= (__osz) / (__s)) |
| 176 | #define __glibc_unsigned_or_positive(__l) \ |
| 177 | ((__typeof (__l)) 0 < (__typeof (__l)) -1 \ |
| 178 | || (__builtin_constant_p (__l) && (__l) > 0)) |
| 179 | |
| 180 | /* Length is known to be safe at compile time if the __L * __S <= __OBJSZ |
| 181 | condition can be folded to a constant and if it is true, or unknown (-1) */ |
| 182 | #define __glibc_safe_or_unknown_len(__l, __s, __osz) \ |
| 183 | ((__builtin_constant_p (__osz) && (__osz) == (__SIZE_TYPE__) -1) \ |
| 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 | /* Conversely, we know at compile time that the length is unsafe if the |
| 190 | __L * __S <= __OBJSZ condition can be folded to a constant and if it is |
| 191 | false. */ |
| 192 | #define __glibc_unsafe_len(__l, __s, __osz) \ |
| 193 | (__glibc_unsigned_or_positive (__l) \ |
| 194 | && __builtin_constant_p (__glibc_safe_len_cond ((__SIZE_TYPE__) (__l), \ |
| 195 | __s, __osz)) \ |
| 196 | && !__glibc_safe_len_cond ((__SIZE_TYPE__) (__l), __s, __osz)) |
| 197 | |
| 198 | /* To correctly instrument the fortify wrapper clang requires the |
| 199 | pass_object_size attribute, and the attribute has the restriction that the |
| 200 | argument needs to be 'const'. Furthermore, to make it usable with C |
| 201 | interfaces, clang provides the overload attribute, which provides a C++ |
| 202 | like function overload support. The overloaded fortify wrapper with the |
| 203 | pass_object_size attribute has precedence over the default symbol. |
| 204 | |
| 205 | Also, clang does not support __va_arg_pack, so variadic functions are |
| 206 | expanded to issue va_arg implementations. The error function must not have |
| 207 | bodies (address takes are expanded to nonfortified calls), and with |
| 208 | __fortify_function compiler might still create a body with the C++ |
| 209 | mangling name (due to the overload attribute). In this case, the function |
| 210 | is defined with __fortify_function_error_function macro instead. |
| 211 | |
| 212 | The argument size check is also done with a clang-only attribute, |
| 213 | __attribute__ ((__diagnose_if__ (...))), different than gcc which calls |
| 214 | symbol_chk_warn alias with uses __warnattr attribute. |
| 215 | |
| 216 | The pass_object_size was added on clang 4.0, __diagnose_if__ on 5.0, |
| 217 | and pass_dynamic_object_size on 9.0. */ |
| 218 | #if defined __clang_major__ && __clang_major__ >= 5 |
| 219 | # define __fortify_use_clang 1 |
| 220 | |
| 221 | # define __fortify_function_error_function static __attribute__((__unused__)) |
| 222 | |
| 223 | # define __fortify_clang_pass_object_size_n(n) \ |
| 224 | __attribute__ ((__pass_object_size__ (n))) |
| 225 | # define __fortify_clang_pass_object_size0 \ |
| 226 | __fortify_clang_pass_object_size_n (0) |
| 227 | # define __fortify_clang_pass_object_size \ |
| 228 | __fortify_clang_pass_object_size_n (__USE_FORTIFY_LEVEL > 1) |
| 229 | |
| 230 | # if __clang_major__ >= 9 |
| 231 | # define __fortify_clang_pass_dynamic_object_size_n(n) \ |
| 232 | __attribute__ ((__pass_dynamic_object_size__ (n))) |
| 233 | # define __fortify_clang_pass_dynamic_object_size0 \ |
| 234 | __fortify_clang_pass_dynamic_object_size_n (0) |
| 235 | # define __fortify_clang_pass_dynamic_object_size \ |
| 236 | __fortify_clang_pass_dynamic_object_size_n (1) |
| 237 | # else |
| 238 | # define __fortify_clang_pass_dynamic_object_size_n(n) |
| 239 | # define __fortify_clang_pass_dynamic_object_size0 |
| 240 | # define __fortify_clang_pass_dynamic_object_size |
| 241 | # endif |
| 242 | |
| 243 | # define __fortify_clang_bos_static_lt_impl(bos_val, n, s) \ |
| 244 | ((bos_val) != -1ULL && (n) > (bos_val) / (s)) |
| 245 | # define __fortify_clang_bos_static_lt2(__n, __e, __s) \ |
| 246 | __fortify_clang_bos_static_lt_impl (__bos (__e), __n, __s) |
| 247 | # define __fortify_clang_bos_static_lt(__n, __e) \ |
| 248 | __fortify_clang_bos_static_lt2 (__n, __e, 1) |
| 249 | # define __fortify_clang_bos0_static_lt2(__n, __e, __s) \ |
| 250 | __fortify_clang_bos_static_lt_impl (__bos0 (__e), __n, __s) |
| 251 | # define __fortify_clang_bos0_static_lt(__n, __e) \ |
| 252 | __fortify_clang_bos0_static_lt2 (__n, __e, 1) |
| 253 | |
| 254 | # define __fortify_clang_bosn_args(bos_fn, n, buf, div, complaint) \ |
| 255 | (__fortify_clang_bos_static_lt_impl (bos_fn (buf), n, div)), (complaint), \ |
| 256 | "warning" |
| 257 | |
| 258 | # define __fortify_clang_warning(__c, __msg) \ |
| 259 | __attribute__ ((__diagnose_if__ ((__c), (__msg), "warning"))) |
| 260 | # define __fortify_clang_error(__c, __msg) \ |
| 261 | __attribute__ ((__diagnose_if__ ((__c), (__msg), "error"))) |
| 262 | # define __fortify_clang_warning_only_if_bos0_lt(n, buf, complaint) \ |
| 263 | __attribute__ ((__diagnose_if__ \ |
| 264 | (__fortify_clang_bosn_args (__bos0, n, buf, 1, complaint)))) |
| 265 | # define __fortify_clang_warning_only_if_bos0_lt2(n, buf, div, complaint) \ |
| 266 | __attribute__ ((__diagnose_if__ \ |
| 267 | (__fortify_clang_bosn_args (__bos0, n, buf, div, complaint)))) |
| 268 | # define __fortify_clang_warning_only_if_bos_lt(n, buf, complaint) \ |
| 269 | __attribute__ ((__diagnose_if__ \ |
| 270 | (__fortify_clang_bosn_args (__bos, n, buf, 1, complaint)))) |
| 271 | # define __fortify_clang_warning_only_if_bos_lt2(n, buf, div, complaint) \ |
| 272 | __attribute__ ((__diagnose_if__ \ |
| 273 | (__fortify_clang_bosn_args (__bos, n, buf, div, complaint)))) |
| 274 | |
| 275 | # define __fortify_clang_prefer_this_overload \ |
| 276 | __attribute__ ((enable_if (1, ""))) |
| 277 | # define __fortify_clang_unavailable(__msg) \ |
| 278 | __attribute__ ((unavailable(__msg))) |
| 279 | |
| 280 | # if __USE_FORTIFY_LEVEL == 3 |
| 281 | # define __fortify_clang_overload_arg(__type, __attr, __name) \ |
| 282 | __type __attr const __fortify_clang_pass_dynamic_object_size __name |
| 283 | # define __fortify_clang_overload_arg0(__type, __attr, __name) \ |
| 284 | __type __attr const __fortify_clang_pass_dynamic_object_size0 __name |
| 285 | # else |
| 286 | # define __fortify_clang_overload_arg(__type, __attr, __name) \ |
| 287 | __type __attr const __fortify_clang_pass_object_size __name |
| 288 | # define __fortify_clang_overload_arg0(__type, __attr, __name) \ |
| 289 | __type __attr const __fortify_clang_pass_object_size0 __name |
| 290 | # endif |
| 291 | |
| 292 | # define __fortify_clang_mul_may_overflow(size, n) \ |
| 293 | ((size | n) >= (((size_t)1) << (8 * sizeof (size_t) / 2))) |
| 294 | |
| 295 | # define __fortify_clang_size_too_small(__bos, __dest, __len) \ |
| 296 | (__bos (__dest) != (size_t) -1 && __bos (__dest) < __len) |
| 297 | # define __fortify_clang_warn_if_src_too_large(__dest, __src) \ |
| 298 | __fortify_clang_warning (__fortify_clang_size_too_small (__glibc_objsize, \ |
| 299 | __dest, \ |
| 300 | __builtin_strlen (__src) + 1), \ |
| 301 | "destination buffer will always be overflown by source") |
| 302 | # define __fortify_clang_warn_if_dest_too_small(__dest, __len) \ |
| 303 | __fortify_clang_warning (__fortify_clang_size_too_small (__glibc_objsize, \ |
| 304 | __dest, \ |
| 305 | __len), \ |
| 306 | "function called with bigger length than the destination buffer") |
| 307 | # define __fortify_clang_warn_if_dest_too_small0(__dest, __len) \ |
| 308 | __fortify_clang_warning (__fortify_clang_size_too_small (__glibc_objsize0, \ |
| 309 | __dest, \ |
| 310 | __len), \ |
| 311 | "function called with bigger length than the destination buffer") |
| 312 | #else |
| 313 | # define __fortify_use_clang 0 |
| 314 | # define __fortify_clang_warning(__c, __msg) |
| 315 | # define __fortify_clang_warning_only_if_bos0_lt(__n, __buf, __complaint) |
| 316 | # define __fortify_clang_warning_only_if_bos0_lt2(__n, __buf, __div, complaint) |
| 317 | # define __fortify_clang_warning_only_if_bos_lt(__n, __buf, __complaint) |
| 318 | # define __fortify_clang_warning_only_if_bos_lt2(__n, __buf, div, __complaint) |
| 319 | # define __fortify_clang_overload_arg(__type, __attr, __name) \ |
| 320 | __type __attr __name |
| 321 | # define __fortify_clang_overload_arg0(__type, __attr, __name) \ |
| 322 | __fortify_clang_overload_arg (__type, __attr, __name) |
| 323 | # define __fortify_clang_warn_if_src_too_large(__dest, __src) |
| 324 | # define __fortify_clang_warn_if_dest_too_small(__dest, __len) |
| 325 | # define __fortify_clang_warn_if_dest_too_small0(__dest, __len) |
| 326 | #endif |
| 327 | |
| 328 | |
| 329 | /* Fortify function f. __f_alias, __f_chk and __f_chk_warn must be |
| 330 | declared. */ |
| 331 | |
| 332 | #if !__fortify_use_clang |
| 333 | # define __glibc_fortify(f, __l, __s, __osz, ...) \ |
| 334 | (__glibc_safe_or_unknown_len (__l, __s, __osz) \ |
| 335 | ? __ ## f ## _alias (__VA_ARGS__) \ |
| 336 | : (__glibc_unsafe_len (__l, __s, __osz) \ |
| 337 | ? __ ## f ## _chk_warn (__VA_ARGS__, __osz) \ |
| 338 | : __ ## f ## _chk (__VA_ARGS__, __osz))) |
| 339 | #else |
| 340 | # define __glibc_fortify(f, __l, __s, __osz, ...) \ |
| 341 | (__osz == (__SIZE_TYPE__) -1) \ |
| 342 | ? __ ## f ## _alias (__VA_ARGS__) \ |
| 343 | : __ ## f ## _chk (__VA_ARGS__, __osz) |
| 344 | #endif |
| 345 | |
| 346 | /* Fortify function f, where object size argument passed to f is the number of |
| 347 | elements and not total size. */ |
| 348 | |
| 349 | #if !__fortify_use_clang |
| 350 | # define __glibc_fortify_n(f, __l, __s, __osz, ...) \ |
| 351 | (__glibc_safe_or_unknown_len (__l, __s, __osz) \ |
| 352 | ? __ ## f ## _alias (__VA_ARGS__) \ |
| 353 | : (__glibc_unsafe_len (__l, __s, __osz) \ |
| 354 | ? __ ## f ## _chk_warn (__VA_ARGS__, (__osz) / (__s)) \ |
| 355 | : __ ## f ## _chk (__VA_ARGS__, (__osz) / (__s)))) |
| 356 | # else |
| 357 | # define __glibc_fortify_n(f, __l, __s, __osz, ...) \ |
| 358 | (__osz == (__SIZE_TYPE__) -1) \ |
| 359 | ? __ ## f ## _alias (__VA_ARGS__) \ |
| 360 | : __ ## f ## _chk (__VA_ARGS__, (__osz) / (__s)) |
| 361 | #endif |
| 362 | |
| 363 | #endif /* __USE_FORTIFY_LEVEL > 0 */ |
| 364 | |
| 365 | #if __GNUC_PREREQ (4,3) |
| 366 | # define __warnattr(msg) __attribute__((__warning__ (msg))) |
| 367 | # define __errordecl(name, msg) \ |
| 368 | extern void name (void) __attribute__((__error__ (msg))) |
| 369 | #else |
| 370 | # define __warnattr(msg) |
| 371 | # define __errordecl(name, msg) extern void name (void) |
| 372 | #endif |
| 373 | |
| 374 | /* Support for flexible arrays. |
| 375 | Headers that should use flexible arrays only if they're "real" |
| 376 | (e.g. only if they won't affect sizeof()) should test |
| 377 | #if __glibc_c99_flexarr_available. */ |
| 378 | #if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L && !defined __HP_cc |
| 379 | # define __flexarr [] |
| 380 | # define __glibc_c99_flexarr_available 1 |
| 381 | #elif __GNUC_PREREQ (2,97) || defined __clang__ |
| 382 | /* GCC 2.97 and clang support C99 flexible array members as an extension, |
| 383 | even when in C89 mode or compiling C++ (any version). */ |
| 384 | # define __flexarr [] |
| 385 | # define __glibc_c99_flexarr_available 1 |
| 386 | #elif defined __GNUC__ |
| 387 | /* Pre-2.97 GCC did not support C99 flexible arrays but did have |
| 388 | an equivalent extension with slightly different notation. */ |
| 389 | # define __flexarr [0] |
| 390 | # define __glibc_c99_flexarr_available 1 |
| 391 | #else |
| 392 | /* Some other non-C99 compiler. Approximate with [1]. */ |
| 393 | # define __flexarr [1] |
| 394 | # define __glibc_c99_flexarr_available 0 |
| 395 | #endif |
| 396 | |
| 397 | |
| 398 | /* __asm__ ("xyz") is used throughout the headers to rename functions |
| 399 | at the assembly language level. This is wrapped by the __REDIRECT |
| 400 | macro, in order to support compilers that can do this some other |
| 401 | way. When compilers don't support asm-names at all, we have to do |
| 402 | preprocessor tricks instead (which don't have exactly the right |
| 403 | semantics, but it's the best we can do). |
| 404 | |
| 405 | Example: |
| 406 | int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); */ |
| 407 | |
| 408 | #if (defined __GNUC__ && __GNUC__ >= 2) || (__clang_major__ >= 4) |
| 409 | |
| 410 | # define __REDIRECT(name, proto, alias) name proto __asm__ (__ASMNAME (#alias)) |
| 411 | # ifdef __cplusplus |
| 412 | # define __REDIRECT_NTH(name, proto, alias) \ |
| 413 | name proto __THROW __asm__ (__ASMNAME (#alias)) |
| 414 | # define __REDIRECT_NTHNL(name, proto, alias) \ |
| 415 | name proto __THROWNL __asm__ (__ASMNAME (#alias)) |
| 416 | # else |
| 417 | # define __REDIRECT_NTH(name, proto, alias) \ |
| 418 | name proto __asm__ (__ASMNAME (#alias)) __THROW |
| 419 | # define __REDIRECT_NTHNL(name, proto, alias) \ |
| 420 | name proto __asm__ (__ASMNAME (#alias)) __THROWNL |
| 421 | # endif |
| 422 | # define __ASMNAME(cname) __ASMNAME2 (__USER_LABEL_PREFIX__, cname) |
| 423 | # define __ASMNAME2(prefix, cname) __STRING (prefix) cname |
| 424 | |
| 425 | #ifndef __REDIRECT_FORTIFY |
| 426 | #define __REDIRECT_FORTIFY __REDIRECT |
| 427 | #endif |
| 428 | |
| 429 | #ifndef __REDIRECT_FORTIFY_NTH |
| 430 | #define __REDIRECT_FORTIFY_NTH __REDIRECT_NTH |
| 431 | #endif |
| 432 | |
| 433 | /* |
| 434 | #elif __SOME_OTHER_COMPILER__ |
| 435 | |
| 436 | # define __REDIRECT(name, proto, alias) name proto; \ |
| 437 | _Pragma("let " #name " = " #alias) |
| 438 | */ |
| 439 | #endif |
| 440 | |
| 441 | /* GCC and clang have various useful declarations that can be made with |
| 442 | the '__attribute__' syntax. All of the ways we use this do fine if |
| 443 | they are omitted for compilers that don't understand it. */ |
| 444 | #if !(defined __GNUC__ || defined __clang__) |
| 445 | # define __attribute__(xyz) /* Ignore */ |
| 446 | #endif |
| 447 | |
| 448 | /* At some point during the gcc 2.96 development the `malloc' attribute |
| 449 | for functions was introduced. We don't want to use it unconditionally |
| 450 | (although this would be possible) since it generates warnings. */ |
| 451 | #if __GNUC_PREREQ (2,96) || __glibc_has_attribute (__malloc__) |
| 452 | # define __attribute_malloc__ __attribute__ ((__malloc__)) |
| 453 | #else |
| 454 | # define __attribute_malloc__ /* Ignore */ |
| 455 | #endif |
| 456 | |
| 457 | /* Tell the compiler which arguments to an allocation function |
| 458 | indicate the size of the allocation. */ |
| 459 | #if __GNUC_PREREQ (4, 3) |
| 460 | # define __attribute_alloc_size__(params) \ |
| 461 | __attribute__ ((__alloc_size__ params)) |
| 462 | #else |
| 463 | # define __attribute_alloc_size__(params) /* Ignore. */ |
| 464 | #endif |
| 465 | |
| 466 | /* Tell the compiler which argument to an allocation function |
| 467 | indicates the alignment of the allocation. */ |
| 468 | #if __GNUC_PREREQ (4, 9) || __glibc_has_attribute (__alloc_align__) |
| 469 | # define __attribute_alloc_align__(param) \ |
| 470 | __attribute__ ((__alloc_align__ param)) |
| 471 | #else |
| 472 | # define __attribute_alloc_align__(param) /* Ignore. */ |
| 473 | #endif |
| 474 | |
| 475 | /* At some point during the gcc 2.96 development the `pure' attribute |
| 476 | for functions was introduced. We don't want to use it unconditionally |
| 477 | (although this would be possible) since it generates warnings. */ |
| 478 | #if __GNUC_PREREQ (2,96) || __glibc_has_attribute (__pure__) |
| 479 | # define __attribute_pure__ __attribute__ ((__pure__)) |
| 480 | #else |
| 481 | # define __attribute_pure__ /* Ignore */ |
| 482 | #endif |
| 483 | |
| 484 | /* This declaration tells the compiler that the value is constant. */ |
| 485 | #if __GNUC_PREREQ (2,5) || __glibc_has_attribute (__const__) |
| 486 | # define __attribute_const__ __attribute__ ((__const__)) |
| 487 | #else |
| 488 | # define __attribute_const__ /* Ignore */ |
| 489 | #endif |
| 490 | |
| 491 | #if __GNUC_PREREQ (2,7) || __glibc_has_attribute (__unused__) |
| 492 | # define __attribute_maybe_unused__ __attribute__ ((__unused__)) |
| 493 | #else |
| 494 | # define __attribute_maybe_unused__ /* Ignore */ |
| 495 | #endif |
| 496 | |
| 497 | /* At some point during the gcc 3.1 development the `used' attribute |
| 498 | for functions was introduced. We don't want to use it unconditionally |
| 499 | (although this would be possible) since it generates warnings. */ |
| 500 | #if __GNUC_PREREQ (3,1) || __glibc_has_attribute (__used__) |
| 501 | # define __attribute_used__ __attribute__ ((__used__)) |
| 502 | # define __attribute_noinline__ __attribute__ ((__noinline__)) |
| 503 | #else |
| 504 | # define __attribute_used__ __attribute__ ((__unused__)) |
| 505 | # define __attribute_noinline__ /* Ignore */ |
| 506 | #endif |
| 507 | |
| 508 | /* Since version 3.2, gcc allows marking deprecated functions. */ |
| 509 | #if __GNUC_PREREQ (3,2) || __glibc_has_attribute (__deprecated__) |
| 510 | # define __attribute_deprecated__ __attribute__ ((__deprecated__)) |
| 511 | #else |
| 512 | # define __attribute_deprecated__ /* Ignore */ |
| 513 | #endif |
| 514 | |
| 515 | /* Since version 4.5, gcc also allows one to specify the message printed |
| 516 | when a deprecated function is used. clang claims to be gcc 4.2, but |
| 517 | may also support this feature. */ |
| 518 | #if __GNUC_PREREQ (4,5) \ |
| 519 | || __glibc_has_extension (__attribute_deprecated_with_message__) |
| 520 | # define __attribute_deprecated_msg__(msg) \ |
| 521 | __attribute__ ((__deprecated__ (msg))) |
| 522 | #else |
| 523 | # define __attribute_deprecated_msg__(msg) __attribute_deprecated__ |
| 524 | #endif |
| 525 | |
| 526 | /* At some point during the gcc 2.8 development the `format_arg' attribute |
| 527 | for functions was introduced. We don't want to use it unconditionally |
| 528 | (although this would be possible) since it generates warnings. |
| 529 | If several `format_arg' attributes are given for the same function, in |
| 530 | gcc-3.0 and older, all but the last one are ignored. In newer gccs, |
| 531 | all designated arguments are considered. */ |
| 532 | #if __GNUC_PREREQ (2,8) || __glibc_has_attribute (__format_arg__) |
| 533 | # define __attribute_format_arg__(x) __attribute__ ((__format_arg__ (x))) |
| 534 | #else |
| 535 | # define __attribute_format_arg__(x) /* Ignore */ |
| 536 | #endif |
| 537 | |
| 538 | /* At some point during the gcc 2.97 development the `strfmon' format |
| 539 | attribute for functions was introduced. We don't want to use it |
| 540 | unconditionally (although this would be possible) since it |
| 541 | generates warnings. */ |
| 542 | #if __GNUC_PREREQ (2,97) || __glibc_has_attribute (__format__) |
| 543 | # define __attribute_format_strfmon__(a,b) \ |
| 544 | __attribute__ ((__format__ (__strfmon__, a, b))) |
| 545 | #else |
| 546 | # define __attribute_format_strfmon__(a,b) /* Ignore */ |
| 547 | #endif |
| 548 | |
| 549 | /* The nonnull function attribute marks pointer parameters that |
| 550 | must not be NULL. This has the name __nonnull in glibc, |
| 551 | and __attribute_nonnull__ in files shared with Gnulib to avoid |
| 552 | collision with a different __nonnull in DragonFlyBSD 5.9. */ |
| 553 | #ifndef __attribute_nonnull__ |
| 554 | # if __GNUC_PREREQ (3,3) || __glibc_has_attribute (__nonnull__) |
| 555 | # define __attribute_nonnull__(params) __attribute__ ((__nonnull__ params)) |
| 556 | # else |
| 557 | # define __attribute_nonnull__(params) |
| 558 | # endif |
| 559 | #endif |
| 560 | #ifndef __nonnull |
| 561 | # define __nonnull(params) __attribute_nonnull__ (params) |
| 562 | #endif |
| 563 | |
| 564 | /* The returns_nonnull function attribute marks the return type of the function |
| 565 | as always being non-null. */ |
| 566 | #ifndef __returns_nonnull |
| 567 | # if __GNUC_PREREQ (4, 9) || __glibc_has_attribute (__returns_nonnull__) |
| 568 | # define __returns_nonnull __attribute__ ((__returns_nonnull__)) |
| 569 | # else |
| 570 | # define __returns_nonnull |
| 571 | # endif |
| 572 | #endif |
| 573 | |
| 574 | /* If fortification mode, we warn about unused results of certain |
| 575 | function calls which can lead to problems. */ |
| 576 | #if __GNUC_PREREQ (3,4) || __glibc_has_attribute (__warn_unused_result__) |
| 577 | # define __attribute_warn_unused_result__ \ |
| 578 | __attribute__ ((__warn_unused_result__)) |
| 579 | # if defined __USE_FORTIFY_LEVEL && __USE_FORTIFY_LEVEL > 0 |
| 580 | # define __wur __attribute_warn_unused_result__ |
| 581 | # endif |
| 582 | #else |
| 583 | # define __attribute_warn_unused_result__ /* empty */ |
| 584 | #endif |
| 585 | #ifndef __wur |
| 586 | # define __wur /* Ignore */ |
| 587 | #endif |
| 588 | |
| 589 | /* Forces a function to be always inlined. */ |
| 590 | #if __GNUC_PREREQ (3,2) || __glibc_has_attribute (__always_inline__) |
| 591 | /* The Linux kernel defines __always_inline in stddef.h (283d7573), and |
| 592 | it conflicts with this definition. Therefore undefine it first to |
| 593 | allow either header to be included first. */ |
| 594 | # undef __always_inline |
| 595 | # define __always_inline __inline __attribute__ ((__always_inline__)) |
| 596 | #else |
| 597 | # undef __always_inline |
| 598 | # define __always_inline __inline |
| 599 | #endif |
| 600 | |
| 601 | /* Associate error messages with the source location of the call site rather |
| 602 | than with the source location inside the function. */ |
| 603 | #if __GNUC_PREREQ (4,3) || __glibc_has_attribute (__artificial__) |
| 604 | # define __attribute_artificial__ __attribute__ ((__artificial__)) |
| 605 | #else |
| 606 | # define __attribute_artificial__ /* Ignore */ |
| 607 | #endif |
| 608 | |
| 609 | /* GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99 |
| 610 | inline semantics, unless -fgnu89-inline is used. Using __GNUC_STDC_INLINE__ |
| 611 | or __GNUC_GNU_INLINE is not a good enough check for gcc because gcc versions |
| 612 | older than 4.3 may define these macros and still not guarantee GNU inlining |
| 613 | semantics. |
| 614 | |
| 615 | clang++ identifies itself as gcc-4.2, but has support for GNU inlining |
| 616 | semantics, that can be checked for by using the __GNUC_STDC_INLINE_ and |
| 617 | __GNUC_GNU_INLINE__ macro definitions. */ |
| 618 | #if (!defined __cplusplus || __GNUC_PREREQ (4,3) \ |
| 619 | || (defined __clang__ && (defined __GNUC_STDC_INLINE__ \ |
| 620 | || defined __GNUC_GNU_INLINE__))) |
| 621 | # if defined __GNUC_STDC_INLINE__ || defined __cplusplus |
| 622 | # define __extern_inline extern __inline __attribute__ ((__gnu_inline__)) |
| 623 | # define __extern_always_inline \ |
| 624 | extern __always_inline __attribute__ ((__gnu_inline__)) |
| 625 | # else |
| 626 | # define __extern_inline extern __inline |
| 627 | # define __extern_always_inline extern __always_inline |
| 628 | # endif |
| 629 | #endif |
| 630 | |
| 631 | #ifdef __extern_always_inline |
| 632 | # define __fortify_function __extern_always_inline __attribute_artificial__ |
| 633 | #endif |
| 634 | |
| 635 | /* GCC 4.3 and above allow passing all anonymous arguments of an |
| 636 | __extern_always_inline function to some other vararg function. */ |
| 637 | #if __GNUC_PREREQ (4,3) |
| 638 | # define __va_arg_pack() __builtin_va_arg_pack () |
| 639 | # define __va_arg_pack_len() __builtin_va_arg_pack_len () |
| 640 | #endif |
| 641 | |
| 642 | /* It is possible to compile containing GCC extensions even if GCC is |
| 643 | run in pedantic mode if the uses are carefully marked using the |
| 644 | `__extension__' keyword. But this is not generally available before |
| 645 | version 2.8. */ |
| 646 | #if !(__GNUC_PREREQ (2,8) || defined __clang__) |
| 647 | # define __extension__ /* Ignore */ |
| 648 | #endif |
| 649 | |
| 650 | /* __restrict is known in EGCS 1.2 and above, and in clang. |
| 651 | It works also in C++ mode (outside of arrays), but only when spelled |
| 652 | as '__restrict', not 'restrict'. */ |
| 653 | #if !(__GNUC_PREREQ (2,92) || __clang_major__ >= 3) |
| 654 | # if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L |
| 655 | # define __restrict restrict |
| 656 | # else |
| 657 | # define __restrict /* Ignore */ |
| 658 | # endif |
| 659 | #endif |
| 660 | |
| 661 | /* ISO C99 also allows to declare arrays as non-overlapping. The syntax is |
| 662 | array_name[restrict] |
| 663 | GCC 3.1 and clang support this. |
| 664 | This syntax is not usable in C++ mode. */ |
| 665 | #if (__GNUC_PREREQ (3,1) || __clang_major__ >= 3) && !defined __cplusplus |
| 666 | # define __restrict_arr __restrict |
| 667 | #else |
| 668 | # ifdef __GNUC__ |
| 669 | # define __restrict_arr /* Not supported in old GCC. */ |
| 670 | # else |
| 671 | # if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L |
| 672 | # define __restrict_arr restrict |
| 673 | # else |
| 674 | /* Some other non-C99 compiler. */ |
| 675 | # define __restrict_arr /* Not supported. */ |
| 676 | # endif |
| 677 | # endif |
| 678 | #endif |
| 679 | |
| 680 | #if (__GNUC__ >= 3) || __glibc_has_builtin (__builtin_expect) |
| 681 | # define __glibc_unlikely(cond) __builtin_expect ((cond), 0) |
| 682 | # define __glibc_likely(cond) __builtin_expect ((cond), 1) |
| 683 | #else |
| 684 | # define __glibc_unlikely(cond) (cond) |
| 685 | # define __glibc_likely(cond) (cond) |
| 686 | #endif |
| 687 | |
| 688 | #if (!defined _Noreturn \ |
| 689 | && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \ |
| 690 | && !(__GNUC_PREREQ (4,7) \ |
| 691 | || (3 < __clang_major__ + (5 <= __clang_minor__)))) |
| 692 | # if __GNUC_PREREQ (2,8) |
| 693 | # define _Noreturn __attribute__ ((__noreturn__)) |
| 694 | # else |
| 695 | # define _Noreturn |
| 696 | # endif |
| 697 | #endif |
| 698 | |
| 699 | #if __GNUC_PREREQ (8, 0) |
| 700 | /* Describes a char array whose address can safely be passed as the first |
| 701 | argument to strncpy and strncat, as the char array is not necessarily |
| 702 | a NUL-terminated string. */ |
| 703 | # define __attribute_nonstring__ __attribute__ ((__nonstring__)) |
| 704 | #else |
| 705 | # define __attribute_nonstring__ |
| 706 | #endif |
| 707 | |
| 708 | /* Undefine (also defined in libc-symbols.h). */ |
| 709 | #undef __attribute_copy__ |
| 710 | #if __GNUC_PREREQ (9, 0) |
| 711 | /* Copies attributes from the declaration or type referenced by |
| 712 | the argument. */ |
| 713 | # define __attribute_copy__(arg) __attribute__ ((__copy__ (arg))) |
| 714 | #else |
| 715 | # define __attribute_copy__(arg) |
| 716 | #endif |
| 717 | |
| 718 | #if (!defined _Static_assert && !defined __cplusplus \ |
| 719 | && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \ |
| 720 | && (!(__GNUC_PREREQ (4, 6) || __clang_major__ >= 4) \ |
| 721 | || defined __STRICT_ANSI__)) |
| 722 | # define _Static_assert(expr, diagnostic) \ |
| 723 | extern int (*__Static_assert_function (void)) \ |
| 724 | [!!sizeof (struct { int __error_if_negative: (expr) ? 2 : -1; })] |
| 725 | #endif |
| 726 | |
| 727 | /* Gnulib avoids including these, as they don't work on non-glibc or |
| 728 | older glibc platforms. */ |
| 729 | #ifndef __GNULIB_CDEFS |
| 730 | # include <bits/wordsize.h> |
| 731 | # include <bits/long-double.h> |
| 732 | #endif |
| 733 | |
| 734 | #if __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1 |
| 735 | # ifdef __REDIRECT |
| 736 | |
| 737 | /* Alias name defined automatically. */ |
| 738 | # define __LDBL_REDIR(name, proto) ... unused__ldbl_redir |
| 739 | # define __LDBL_REDIR_DECL(name) \ |
| 740 | extern __typeof (name) name __asm (__ASMNAME ("__" #name "ieee128")); |
| 741 | # define __REDIRECT_LDBL(name, proto, alias) \ |
| 742 | name proto __asm (__ASMNAME ("__" #alias "ieee128")) |
| 743 | |
| 744 | /* Alias name defined automatically, with leading underscores. */ |
| 745 | # define __LDBL_REDIR2_DECL(name) \ |
| 746 | extern __typeof (__##name) __##name \ |
| 747 | __asm (__ASMNAME ("__" #name "ieee128")); |
| 748 | |
| 749 | /* Alias name defined manually. */ |
| 750 | # define __LDBL_REDIR1(name, proto, alias) ... unused__ldbl_redir1 |
| 751 | # define __LDBL_REDIR1_DECL(name, alias) \ |
| 752 | extern __typeof (name) name __asm (__ASMNAME (#alias)); |
| 753 | |
| 754 | # define __LDBL_REDIR1_NTH(name, proto, alias) \ |
| 755 | __REDIRECT_NTH (name, proto, alias) |
| 756 | # define __REDIRECT_NTH_LDBL(name, proto, alias) \ |
| 757 | __LDBL_REDIR1_NTH (name, proto, __##alias##ieee128) |
| 758 | |
| 759 | /* Unused. */ |
| 760 | # define __LDBL_REDIR_NTH(name, proto) ... unused__ldbl_redir_nth |
| 761 | |
| 762 | # else |
| 763 | _Static_assert (0, "IEEE 128-bits long double requires redirection on this platform" ); |
| 764 | # endif |
| 765 | #elif defined __LONG_DOUBLE_MATH_OPTIONAL && defined __NO_LONG_DOUBLE_MATH |
| 766 | # define __LDBL_COMPAT 1 |
| 767 | # ifdef __REDIRECT |
| 768 | # define __LDBL_REDIR1(name, proto, alias) __REDIRECT (name, proto, alias) |
| 769 | # define __LDBL_REDIR(name, proto) \ |
| 770 | __LDBL_REDIR1 (name, proto, __nldbl_##name) |
| 771 | # define __LDBL_REDIR1_NTH(name, proto, alias) __REDIRECT_NTH (name, proto, alias) |
| 772 | # define __LDBL_REDIR_NTH(name, proto) \ |
| 773 | __LDBL_REDIR1_NTH (name, proto, __nldbl_##name) |
| 774 | # define __LDBL_REDIR2_DECL(name) \ |
| 775 | extern __typeof (__##name) __##name __asm (__ASMNAME ("__nldbl___" #name)); |
| 776 | # define __LDBL_REDIR1_DECL(name, alias) \ |
| 777 | extern __typeof (name) name __asm (__ASMNAME (#alias)); |
| 778 | # define __LDBL_REDIR_DECL(name) \ |
| 779 | extern __typeof (name) name __asm (__ASMNAME ("__nldbl_" #name)); |
| 780 | # define __REDIRECT_LDBL(name, proto, alias) \ |
| 781 | __LDBL_REDIR1 (name, proto, __nldbl_##alias) |
| 782 | # define __REDIRECT_NTH_LDBL(name, proto, alias) \ |
| 783 | __LDBL_REDIR1_NTH (name, proto, __nldbl_##alias) |
| 784 | # endif |
| 785 | #endif |
| 786 | #if (!defined __LDBL_COMPAT && __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 0) \ |
| 787 | || !defined __REDIRECT |
| 788 | # define __LDBL_REDIR1(name, proto, alias) name proto |
| 789 | # define __LDBL_REDIR(name, proto) name proto |
| 790 | # define __LDBL_REDIR1_NTH(name, proto, alias) name proto __THROW |
| 791 | # define __LDBL_REDIR_NTH(name, proto) name proto __THROW |
| 792 | # define __LDBL_REDIR2_DECL(name) |
| 793 | # define __LDBL_REDIR_DECL(name) |
| 794 | # ifdef __REDIRECT |
| 795 | # define __REDIRECT_LDBL(name, proto, alias) __REDIRECT (name, proto, alias) |
| 796 | # define __REDIRECT_NTH_LDBL(name, proto, alias) \ |
| 797 | __REDIRECT_NTH (name, proto, alias) |
| 798 | # endif |
| 799 | #endif |
| 800 | |
| 801 | /* __glibc_macro_warning (MESSAGE) issues warning MESSAGE. This is |
| 802 | intended for use in preprocessor macros. |
| 803 | |
| 804 | Note: MESSAGE must be a _single_ string; concatenation of string |
| 805 | literals is not supported. */ |
| 806 | #if __GNUC_PREREQ (4,8) || __glibc_clang_prereq (3,5) |
| 807 | # define __glibc_macro_warning1(message) _Pragma (#message) |
| 808 | # define __glibc_macro_warning(message) \ |
| 809 | __glibc_macro_warning1 (GCC warning message) |
| 810 | #else |
| 811 | # define __glibc_macro_warning(msg) |
| 812 | #endif |
| 813 | |
| 814 | /* Generic selection (ISO C11) is a C-only feature, available in GCC |
| 815 | since version 4.9. Previous versions do not provide generic |
| 816 | selection, even though they might set __STDC_VERSION__ to 201112L, |
| 817 | when in -std=c11 mode. Thus, we must check for !defined __GNUC__ |
| 818 | when testing __STDC_VERSION__ for generic selection support. |
| 819 | On the other hand, Clang also defines __GNUC__, so a clang-specific |
| 820 | check is required to enable the use of generic selection. */ |
| 821 | #if !defined __cplusplus \ |
| 822 | && (__GNUC_PREREQ (4, 9) \ |
| 823 | || __glibc_has_extension (c_generic_selections) \ |
| 824 | || (!defined __GNUC__ && defined __STDC_VERSION__ \ |
| 825 | && __STDC_VERSION__ >= 201112L)) |
| 826 | # define __HAVE_GENERIC_SELECTION 1 |
| 827 | #else |
| 828 | # define __HAVE_GENERIC_SELECTION 0 |
| 829 | #endif |
| 830 | |
| 831 | #if __GNUC_PREREQ (10, 0) |
| 832 | /* Designates a 1-based positional argument ref-index of pointer type |
| 833 | that can be used to access size-index elements of the pointed-to |
| 834 | array according to access mode, or at least one element when |
| 835 | size-index is not provided: |
| 836 | access (access-mode, <ref-index> [, <size-index>]) */ |
| 837 | # define __attr_access(x) __attribute__ ((__access__ x)) |
| 838 | /* For _FORTIFY_SOURCE == 3 we use __builtin_dynamic_object_size, which may |
| 839 | use the access attribute to get object sizes from function definition |
| 840 | arguments, so we can't use them on functions we fortify. Drop the access |
| 841 | attribute for such functions. */ |
| 842 | # if __USE_FORTIFY_LEVEL == 3 |
| 843 | # define __fortified_attr_access(a, o, s) |
| 844 | # else |
| 845 | # define __fortified_attr_access(a, o, s) __attr_access ((a, o, s)) |
| 846 | # endif |
| 847 | # if __GNUC_PREREQ (11, 0) |
| 848 | # define __attr_access_none(argno) __attribute__ ((__access__ (__none__, argno))) |
| 849 | # else |
| 850 | # define __attr_access_none(argno) |
| 851 | # endif |
| 852 | #else |
| 853 | # define __fortified_attr_access(a, o, s) |
| 854 | # define __attr_access(x) |
| 855 | # define __attr_access_none(argno) |
| 856 | #endif |
| 857 | |
| 858 | #if __GNUC_PREREQ (11, 0) |
| 859 | /* Designates dealloc as a function to call to deallocate objects |
| 860 | allocated by the declared function. */ |
| 861 | # define __attr_dealloc(dealloc, argno) \ |
| 862 | __attribute__ ((__malloc__ (dealloc, argno))) |
| 863 | # define __attr_dealloc_free __attr_dealloc (__builtin_free, 1) |
| 864 | #else |
| 865 | # define __attr_dealloc(dealloc, argno) |
| 866 | # define __attr_dealloc_free |
| 867 | #endif |
| 868 | |
| 869 | /* Specify that a function such as setjmp or vfork may return |
| 870 | twice. */ |
| 871 | #if __GNUC_PREREQ (4, 1) |
| 872 | # define __attribute_returns_twice__ __attribute__ ((__returns_twice__)) |
| 873 | #else |
| 874 | # define __attribute_returns_twice__ /* Ignore. */ |
| 875 | #endif |
| 876 | |
| 877 | /* Mark struct types as aliasable. Restricted to compilers that |
| 878 | support forward declarations of structs in the presence of the |
| 879 | attribute. */ |
| 880 | #if __GNUC_PREREQ (7, 1) || defined __clang__ |
| 881 | # define __attribute_struct_may_alias__ __attribute__ ((__may_alias__)) |
| 882 | #else |
| 883 | # define __attribute_struct_may_alias__ |
| 884 | #endif |
| 885 | |
| 886 | #endif /* sys/cdefs.h */ |
| 887 | |