|
Dan Čermák |
d092d2 |
/* Copyright (C) 1992-2022 Free Software Foundation, Inc.
|
|
Dan Čermák |
d092d2 |
Copyright The GNU Toolchain Authors.
|
|
Dan Čermák |
d092d2 |
This file is part of the GNU C Library.
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
The GNU C Library is free software; you can redistribute it and/or
|
|
Dan Čermák |
d092d2 |
modify it under the terms of the GNU Lesser General Public
|
|
Dan Čermák |
d092d2 |
License as published by the Free Software Foundation; either
|
|
Dan Čermák |
d092d2 |
version 2.1 of the License, or (at your option) any later version.
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Dan Čermák |
d092d2 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Dan Čermák |
d092d2 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Dan Čermák |
d092d2 |
Lesser General Public License for more details.
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
You should have received a copy of the GNU Lesser General Public
|
|
Dan Čermák |
d092d2 |
License along with the GNU C Library; if not, see
|
|
Dan Čermák |
d092d2 |
<https://www.gnu.org/licenses/>. */
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
#ifndef _SYS_CDEFS_H
|
|
Dan Čermák |
d092d2 |
#define _SYS_CDEFS_H 1
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
/* We are almost always included from features.h. */
|
|
Dan Čermák |
d092d2 |
#ifndef _FEATURES_H
|
|
Dan Čermák |
d092d2 |
# include <features.h>
|
|
Dan Čermák |
d092d2 |
#endif
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
/* The GNU libc does not support any K&R compilers or the traditional mode
|
|
Dan Čermák |
d092d2 |
of ISO C compilers anymore. Check for some of the combinations not
|
|
Dan Čermák |
d092d2 |
supported anymore. */
|
|
Dan Čermák |
d092d2 |
#if defined __GNUC__ && !defined __STDC__
|
|
Dan Čermák |
d092d2 |
# error "You need a ISO C conforming compiler to use the glibc headers"
|
|
Dan Čermák |
d092d2 |
#endif
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
/* Some user header file might have defined this before. */
|
|
Dan Čermák |
d092d2 |
#undef __P
|
|
Dan Čermák |
d092d2 |
#undef __PMT
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
/* Compilers that lack __has_attribute may object to
|
|
Dan Čermák |
d092d2 |
#if defined __has_attribute && __has_attribute (...)
|
|
Dan Čermák |
d092d2 |
even though they do not need to evaluate the right-hand side of the &&.
|
|
Dan Čermák |
d092d2 |
Similarly for __has_builtin, etc. */
|
|
Dan Čermák |
d092d2 |
#if (defined __has_attribute \
|
|
Dan Čermák |
d092d2 |
&& (!defined __clang_minor__ \
|
|
Dan Čermák |
d092d2 |
|| (defined __apple_build_version__ \
|
|
Dan Čermák |
d092d2 |
? 6000000 <= __apple_build_version__ \
|
|
Dan Čermák |
d092d2 |
: 3 < __clang_major__ + (5 <= __clang_minor__))))
|
|
Dan Čermák |
d092d2 |
# define __glibc_has_attribute(attr) __has_attribute (attr)
|
|
Dan Čermák |
d092d2 |
#else
|
|
Dan Čermák |
d092d2 |
# define __glibc_has_attribute(attr) 0
|
|
Dan Čermák |
d092d2 |
#endif
|
|
Dan Čermák |
d092d2 |
#ifdef __has_builtin
|
|
Dan Čermák |
d092d2 |
# define __glibc_has_builtin(name) __has_builtin (name)
|
|
Dan Čermák |
d092d2 |
#else
|
|
Dan Čermák |
d092d2 |
# define __glibc_has_builtin(name) 0
|
|
Dan Čermák |
d092d2 |
#endif
|
|
Dan Čermák |
d092d2 |
#ifdef __has_extension
|
|
Dan Čermák |
d092d2 |
# define __glibc_has_extension(ext) __has_extension (ext)
|
|
Dan Čermák |
d092d2 |
#else
|
|
Dan Čermák |
d092d2 |
# define __glibc_has_extension(ext) 0
|
|
Dan Čermák |
d092d2 |
#endif
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
#if defined __GNUC__ || defined __clang__
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
/* All functions, except those with callbacks or those that
|
|
Dan Čermák |
d092d2 |
synchronize memory, are leaf functions. */
|
|
Dan Čermák |
d092d2 |
# if __GNUC_PREREQ (4, 6) && !defined _LIBC
|
|
Dan Čermák |
d092d2 |
# define __LEAF , __leaf__
|
|
Dan Čermák |
d092d2 |
# define __LEAF_ATTR __attribute__ ((__leaf__))
|
|
Dan Čermák |
d092d2 |
# else
|
|
Dan Čermák |
d092d2 |
# define __LEAF
|
|
Dan Čermák |
d092d2 |
# define __LEAF_ATTR
|
|
Dan Čermák |
d092d2 |
# endif
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
/* GCC can always grok prototypes. For C++ programs we add throw()
|
|
Dan Čermák |
d092d2 |
to help it optimize the function calls. But this only works with
|
|
Dan Čermák |
d092d2 |
gcc 2.8.x and egcs. For gcc 3.4 and up we even mark C functions
|
|
Dan Čermák |
d092d2 |
as non-throwing using a function attribute since programs can use
|
|
Dan Čermák |
d092d2 |
the -fexceptions options for C code as well. */
|
|
Dan Čermák |
d092d2 |
# if !defined __cplusplus \
|
|
Dan Čermák |
d092d2 |
&& (__GNUC_PREREQ (3, 4) || __glibc_has_attribute (__nothrow__))
|
|
Dan Čermák |
d092d2 |
# define __THROW __attribute__ ((__nothrow__ __LEAF))
|
|
Dan Čermák |
d092d2 |
# define __THROWNL __attribute__ ((__nothrow__))
|
|
Dan Čermák |
d092d2 |
# define __NTH(fct) __attribute__ ((__nothrow__ __LEAF)) fct
|
|
Dan Čermák |
d092d2 |
# define __NTHNL(fct) __attribute__ ((__nothrow__)) fct
|
|
Dan Čermák |
d092d2 |
# else
|
|
Dan Čermák |
d092d2 |
# if defined __cplusplus && (__GNUC_PREREQ (2,8) || __clang_major >= 4)
|
|
Dan Čermák |
d092d2 |
# if __cplusplus >= 201103L
|
|
Dan Čermák |
d092d2 |
# define __THROW noexcept (true)
|
|
Dan Čermák |
d092d2 |
# else
|
|
Dan Čermák |
d092d2 |
# define __THROW throw ()
|
|
Dan Čermák |
d092d2 |
# endif
|
|
Dan Čermák |
d092d2 |
# define __THROWNL __THROW
|
|
Dan Čermák |
d092d2 |
# define __NTH(fct) __LEAF_ATTR fct __THROW
|
|
Dan Čermák |
d092d2 |
# define __NTHNL(fct) fct __THROW
|
|
Dan Čermák |
d092d2 |
# else
|
|
Dan Čermák |
d092d2 |
# define __THROW
|
|
Dan Čermák |
d092d2 |
# define __THROWNL
|
|
Dan Čermák |
d092d2 |
# define __NTH(fct) fct
|
|
Dan Čermák |
d092d2 |
# define __NTHNL(fct) fct
|
|
Dan Čermák |
d092d2 |
# endif
|
|
Dan Čermák |
d092d2 |
# endif
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
#else /* Not GCC or clang. */
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
# if (defined __cplusplus \
|
|
Dan Čermák |
d092d2 |
|| (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L))
|
|
Dan Čermák |
d092d2 |
# define __inline inline
|
|
Dan Čermák |
d092d2 |
# else
|
|
Dan Čermák |
d092d2 |
# define __inline /* No inline functions. */
|
|
Dan Čermák |
d092d2 |
# endif
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
# define __THROW
|
|
Dan Čermák |
d092d2 |
# define __THROWNL
|
|
Dan Čermák |
d092d2 |
# define __NTH(fct) fct
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
#endif /* GCC || clang. */
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
/* These two macros are not used in glibc anymore. They are kept here
|
|
Dan Čermák |
d092d2 |
only because some other projects expect the macros to be defined. */
|
|
Dan Čermák |
d092d2 |
#define __P(args) args
|
|
Dan Čermák |
d092d2 |
#define __PMT(args) args
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
/* For these things, GCC behaves the ANSI way normally,
|
|
Dan Čermák |
d092d2 |
and the non-ANSI way under -traditional. */
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
#define __CONCAT(x,y) x ## y
|
|
Dan Čermák |
d092d2 |
#define __STRING(x) #x
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
/* This is not a typedef so `const __ptr_t' does the right thing. */
|
|
Dan Čermák |
d092d2 |
#define __ptr_t void *
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
/* C++ needs to know that types and declarations are C, not C++. */
|
|
Dan Čermák |
d092d2 |
#ifdef __cplusplus
|
|
Dan Čermák |
d092d2 |
# define __BEGIN_DECLS extern "C" {
|
|
Dan Čermák |
d092d2 |
# define __END_DECLS }
|
|
Dan Čermák |
d092d2 |
#else
|
|
Dan Čermák |
d092d2 |
# define __BEGIN_DECLS
|
|
Dan Čermák |
d092d2 |
# define __END_DECLS
|
|
Dan Čermák |
d092d2 |
#endif
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
/* Fortify support. */
|
|
Dan Čermák |
d092d2 |
#define __bos(ptr) __builtin_object_size (ptr, __USE_FORTIFY_LEVEL > 1)
|
|
Dan Čermák |
d092d2 |
#define __bos0(ptr) __builtin_object_size (ptr, 0)
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
/* Use __builtin_dynamic_object_size at _FORTIFY_SOURCE=3 when available. */
|
|
Dan Čermák |
d092d2 |
#if __USE_FORTIFY_LEVEL == 3 && (__glibc_clang_prereq (9, 0) \
|
|
Dan Čermák |
d092d2 |
|| __GNUC_PREREQ (12, 0))
|
|
Dan Čermák |
d092d2 |
# define __glibc_objsize0(__o) __builtin_dynamic_object_size (__o, 0)
|
|
Dan Čermák |
d092d2 |
# define __glibc_objsize(__o) __builtin_dynamic_object_size (__o, 1)
|
|
Dan Čermák |
d092d2 |
#else
|
|
Dan Čermák |
d092d2 |
# define __glibc_objsize0(__o) __bos0 (__o)
|
|
Dan Čermák |
d092d2 |
# define __glibc_objsize(__o) __bos (__o)
|
|
Dan Čermák |
d092d2 |
#endif
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
/* Compile time conditions to choose between the regular, _chk and _chk_warn
|
|
Dan Čermák |
d092d2 |
variants. These conditions should get evaluated to constant and optimized
|
|
Dan Čermák |
d092d2 |
away. */
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
#define __glibc_safe_len_cond(__l, __s, __osz) ((__l) <= (__osz) / (__s))
|
|
Dan Čermák |
d092d2 |
#define __glibc_unsigned_or_positive(__l) \
|
|
Dan Čermák |
d092d2 |
((__typeof (__l)) 0 < (__typeof (__l)) -1 \
|
|
Dan Čermák |
d092d2 |
|| (__builtin_constant_p (__l) && (__l) > 0))
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
/* Length is known to be safe at compile time if the __L * __S <= __OBJSZ
|
|
Dan Čermák |
665fa9 |
condition can be folded to a constant and if it is true, or unknown (-1) */
|
|
Dan Čermák |
d092d2 |
#define __glibc_safe_or_unknown_len(__l, __s, __osz) \
|
|
Dan Čermák |
665fa9 |
((__osz) == (__SIZE_TYPE__) -1 \
|
|
Dan Čermák |
665fa9 |
|| (__glibc_unsigned_or_positive (__l) \
|
|
Dan Čermák |
665fa9 |
&& __builtin_constant_p (__glibc_safe_len_cond ((__SIZE_TYPE__) (__l), \
|
|
Dan Čermák |
665fa9 |
(__s), (__osz))) \
|
|
Dan Čermák |
665fa9 |
&& __glibc_safe_len_cond ((__SIZE_TYPE__) (__l), (__s), (__osz))))
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
/* Conversely, we know at compile time that the length is unsafe if the
|
|
Dan Čermák |
d092d2 |
__L * __S <= __OBJSZ condition can be folded to a constant and if it is
|
|
Dan Čermák |
d092d2 |
false. */
|
|
Dan Čermák |
d092d2 |
#define __glibc_unsafe_len(__l, __s, __osz) \
|
|
Dan Čermák |
d092d2 |
(__glibc_unsigned_or_positive (__l) \
|
|
Dan Čermák |
d092d2 |
&& __builtin_constant_p (__glibc_safe_len_cond ((__SIZE_TYPE__) (__l), \
|
|
Dan Čermák |
d092d2 |
__s, __osz)) \
|
|
Dan Čermák |
d092d2 |
&& !__glibc_safe_len_cond ((__SIZE_TYPE__) (__l), __s, __osz))
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
/* Fortify function f. __f_alias, __f_chk and __f_chk_warn must be
|
|
Dan Čermák |
d092d2 |
declared. */
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
#define __glibc_fortify(f, __l, __s, __osz, ...) \
|
|
Dan Čermák |
d092d2 |
(__glibc_safe_or_unknown_len (__l, __s, __osz) \
|
|
Dan Čermák |
d092d2 |
? __ ## f ## _alias (__VA_ARGS__) \
|
|
Dan Čermák |
d092d2 |
: (__glibc_unsafe_len (__l, __s, __osz) \
|
|
Dan Čermák |
d092d2 |
? __ ## f ## _chk_warn (__VA_ARGS__, __osz) \
|
|
Dan Čermák |
d092d2 |
: __ ## f ## _chk (__VA_ARGS__, __osz))) \
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
/* Fortify function f, where object size argument passed to f is the number of
|
|
Dan Čermák |
d092d2 |
elements and not total size. */
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
#define __glibc_fortify_n(f, __l, __s, __osz, ...) \
|
|
Dan Čermák |
d092d2 |
(__glibc_safe_or_unknown_len (__l, __s, __osz) \
|
|
Dan Čermák |
d092d2 |
? __ ## f ## _alias (__VA_ARGS__) \
|
|
Dan Čermák |
d092d2 |
: (__glibc_unsafe_len (__l, __s, __osz) \
|
|
Dan Čermák |
d092d2 |
? __ ## f ## _chk_warn (__VA_ARGS__, (__osz) / (__s)) \
|
|
Dan Čermák |
d092d2 |
: __ ## f ## _chk (__VA_ARGS__, (__osz) / (__s)))) \
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
#if __GNUC_PREREQ (4,3)
|
|
Dan Čermák |
d092d2 |
# define __warnattr(msg) __attribute__((__warning__ (msg)))
|
|
Dan Čermák |
d092d2 |
# define __errordecl(name, msg) \
|
|
Dan Čermák |
d092d2 |
extern void name (void) __attribute__((__error__ (msg)))
|
|
Dan Čermák |
d092d2 |
#else
|
|
Dan Čermák |
d092d2 |
# define __warnattr(msg)
|
|
Dan Čermák |
d092d2 |
# define __errordecl(name, msg) extern void name (void)
|
|
Dan Čermák |
d092d2 |
#endif
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
/* Support for flexible arrays.
|
|
Dan Čermák |
d092d2 |
Headers that should use flexible arrays only if they're "real"
|
|
Dan Čermák |
d092d2 |
(e.g. only if they won't affect sizeof()) should test
|
|
Dan Čermák |
d092d2 |
#if __glibc_c99_flexarr_available. */
|
|
Dan Čermák |
d092d2 |
#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L && !defined __HP_cc
|
|
Dan Čermák |
d092d2 |
# define __flexarr []
|
|
Dan Čermák |
d092d2 |
# define __glibc_c99_flexarr_available 1
|
|
Dan Čermák |
d092d2 |
#elif __GNUC_PREREQ (2,97) || defined __clang__
|
|
Dan Čermák |
d092d2 |
/* GCC 2.97 and clang support C99 flexible array members as an extension,
|
|
Dan Čermák |
d092d2 |
even when in C89 mode or compiling C++ (any version). */
|
|
Dan Čermák |
d092d2 |
# define __flexarr []
|
|
Dan Čermák |
d092d2 |
# define __glibc_c99_flexarr_available 1
|
|
Dan Čermák |
d092d2 |
#elif defined __GNUC__
|
|
Dan Čermák |
d092d2 |
/* Pre-2.97 GCC did not support C99 flexible arrays but did have
|
|
Dan Čermák |
d092d2 |
an equivalent extension with slightly different notation. */
|
|
Dan Čermák |
d092d2 |
# define __flexarr [0]
|
|
Dan Čermák |
d092d2 |
# define __glibc_c99_flexarr_available 1
|
|
Dan Čermák |
d092d2 |
#else
|
|
Dan Čermák |
d092d2 |
/* Some other non-C99 compiler. Approximate with [1]. */
|
|
Dan Čermák |
d092d2 |
# define __flexarr [1]
|
|
Dan Čermák |
d092d2 |
# define __glibc_c99_flexarr_available 0
|
|
Dan Čermák |
d092d2 |
#endif
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
/* __asm__ ("xyz") is used throughout the headers to rename functions
|
|
Dan Čermák |
d092d2 |
at the assembly language level. This is wrapped by the __REDIRECT
|
|
Dan Čermák |
d092d2 |
macro, in order to support compilers that can do this some other
|
|
Dan Čermák |
d092d2 |
way. When compilers don't support asm-names at all, we have to do
|
|
Dan Čermák |
d092d2 |
preprocessor tricks instead (which don't have exactly the right
|
|
Dan Čermák |
d092d2 |
semantics, but it's the best we can do).
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
Example:
|
|
Dan Čermák |
d092d2 |
int __REDIRECT(setpgrp, (__pid_t pid, __pid_t pgrp), setpgid); */
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
#if (defined __GNUC__ && __GNUC__ >= 2) || (__clang_major__ >= 4)
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
# define __REDIRECT(name, proto, alias) name proto __asm__ (__ASMNAME (#alias))
|
|
Dan Čermák |
d092d2 |
# ifdef __cplusplus
|
|
Dan Čermák |
d092d2 |
# define __REDIRECT_NTH(name, proto, alias) \
|
|
Dan Čermák |
d092d2 |
name proto __THROW __asm__ (__ASMNAME (#alias))
|
|
Dan Čermák |
d092d2 |
# define __REDIRECT_NTHNL(name, proto, alias) \
|
|
Dan Čermák |
d092d2 |
name proto __THROWNL __asm__ (__ASMNAME (#alias))
|
|
Dan Čermák |
d092d2 |
# else
|
|
Dan Čermák |
d092d2 |
# define __REDIRECT_NTH(name, proto, alias) \
|
|
Dan Čermák |
d092d2 |
name proto __asm__ (__ASMNAME (#alias)) __THROW
|
|
Dan Čermák |
d092d2 |
# define __REDIRECT_NTHNL(name, proto, alias) \
|
|
Dan Čermák |
d092d2 |
name proto __asm__ (__ASMNAME (#alias)) __THROWNL
|
|
Dan Čermák |
d092d2 |
# endif
|
|
Dan Čermák |
d092d2 |
# define __ASMNAME(cname) __ASMNAME2 (__USER_LABEL_PREFIX__, cname)
|
|
Dan Čermák |
d092d2 |
# define __ASMNAME2(prefix, cname) __STRING (prefix) cname
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
/*
|
|
Dan Čermák |
d092d2 |
#elif __SOME_OTHER_COMPILER__
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
# define __REDIRECT(name, proto, alias) name proto; \
|
|
Dan Čermák |
d092d2 |
_Pragma("let " #name " = " #alias)
|
|
Dan Čermák |
d092d2 |
*/
|
|
Dan Čermák |
d092d2 |
#endif
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
/* GCC and clang have various useful declarations that can be made with
|
|
Dan Čermák |
d092d2 |
the '__attribute__' syntax. All of the ways we use this do fine if
|
|
Dan Čermák |
d092d2 |
they are omitted for compilers that don't understand it. */
|
|
Dan Čermák |
d092d2 |
#if !(defined __GNUC__ || defined __clang__)
|
|
Dan Čermák |
d092d2 |
# define __attribute__(xyz) /* Ignore */
|
|
Dan Čermák |
d092d2 |
#endif
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
/* At some point during the gcc 2.96 development the `malloc' attribute
|
|
Dan Čermák |
d092d2 |
for functions was introduced. We don't want to use it unconditionally
|
|
Dan Čermák |
d092d2 |
(although this would be possible) since it generates warnings. */
|
|
Dan Čermák |
d092d2 |
#if __GNUC_PREREQ (2,96) || __glibc_has_attribute (__malloc__)
|
|
Dan Čermák |
d092d2 |
# define __attribute_malloc__ __attribute__ ((__malloc__))
|
|
Dan Čermák |
d092d2 |
#else
|
|
Dan Čermák |
d092d2 |
# define __attribute_malloc__ /* Ignore */
|
|
Dan Čermák |
d092d2 |
#endif
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
/* Tell the compiler which arguments to an allocation function
|
|
Dan Čermák |
d092d2 |
indicate the size of the allocation. */
|
|
Dan Čermák |
d092d2 |
#if __GNUC_PREREQ (4, 3)
|
|
Dan Čermák |
d092d2 |
# define __attribute_alloc_size__(params) \
|
|
Dan Čermák |
d092d2 |
__attribute__ ((__alloc_size__ params))
|
|
Dan Čermák |
d092d2 |
#else
|
|
Dan Čermák |
d092d2 |
# define __attribute_alloc_size__(params) /* Ignore. */
|
|
Dan Čermák |
d092d2 |
#endif
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
/* Tell the compiler which argument to an allocation function
|
|
Dan Čermák |
d092d2 |
indicates the alignment of the allocation. */
|
|
Dan Čermák |
d092d2 |
#if __GNUC_PREREQ (4, 9) || __glibc_has_attribute (__alloc_align__)
|
|
Dan Čermák |
d092d2 |
# define __attribute_alloc_align__(param) \
|
|
Dan Čermák |
d092d2 |
__attribute__ ((__alloc_align__ param))
|
|
Dan Čermák |
d092d2 |
#else
|
|
Dan Čermák |
d092d2 |
# define __attribute_alloc_align__(param) /* Ignore. */
|
|
Dan Čermák |
d092d2 |
#endif
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
/* At some point during the gcc 2.96 development the `pure' attribute
|
|
Dan Čermák |
d092d2 |
for functions was introduced. We don't want to use it unconditionally
|
|
Dan Čermák |
d092d2 |
(although this would be possible) since it generates warnings. */
|
|
Dan Čermák |
d092d2 |
#if __GNUC_PREREQ (2,96) || __glibc_has_attribute (__pure__)
|
|
Dan Čermák |
d092d2 |
# define __attribute_pure__ __attribute__ ((__pure__))
|
|
Dan Čermák |
d092d2 |
#else
|
|
Dan Čermák |
d092d2 |
# define __attribute_pure__ /* Ignore */
|
|
Dan Čermák |
d092d2 |
#endif
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
/* This declaration tells the compiler that the value is constant. */
|
|
Dan Čermák |
d092d2 |
#if __GNUC_PREREQ (2,5) || __glibc_has_attribute (__const__)
|
|
Dan Čermák |
d092d2 |
# define __attribute_const__ __attribute__ ((__const__))
|
|
Dan Čermák |
d092d2 |
#else
|
|
Dan Čermák |
d092d2 |
# define __attribute_const__ /* Ignore */
|
|
Dan Čermák |
d092d2 |
#endif
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
#if __GNUC_PREREQ (2,7) || __glibc_has_attribute (__unused__)
|
|
Dan Čermák |
d092d2 |
# define __attribute_maybe_unused__ __attribute__ ((__unused__))
|
|
Dan Čermák |
d092d2 |
#else
|
|
Dan Čermák |
d092d2 |
# define __attribute_maybe_unused__ /* Ignore */
|
|
Dan Čermák |
d092d2 |
#endif
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
/* At some point during the gcc 3.1 development the `used' attribute
|
|
Dan Čermák |
d092d2 |
for functions was introduced. We don't want to use it unconditionally
|
|
Dan Čermák |
d092d2 |
(although this would be possible) since it generates warnings. */
|
|
Dan Čermák |
d092d2 |
#if __GNUC_PREREQ (3,1) || __glibc_has_attribute (__used__)
|
|
Dan Čermák |
d092d2 |
# define __attribute_used__ __attribute__ ((__used__))
|
|
Dan Čermák |
d092d2 |
# define __attribute_noinline__ __attribute__ ((__noinline__))
|
|
Dan Čermák |
d092d2 |
#else
|
|
Dan Čermák |
d092d2 |
# define __attribute_used__ __attribute__ ((__unused__))
|
|
Dan Čermák |
d092d2 |
# define __attribute_noinline__ /* Ignore */
|
|
Dan Čermák |
d092d2 |
#endif
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
/* Since version 3.2, gcc allows marking deprecated functions. */
|
|
Dan Čermák |
d092d2 |
#if __GNUC_PREREQ (3,2) || __glibc_has_attribute (__deprecated__)
|
|
Dan Čermák |
d092d2 |
# define __attribute_deprecated__ __attribute__ ((__deprecated__))
|
|
Dan Čermák |
d092d2 |
#else
|
|
Dan Čermák |
d092d2 |
# define __attribute_deprecated__ /* Ignore */
|
|
Dan Čermák |
d092d2 |
#endif
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
/* Since version 4.5, gcc also allows one to specify the message printed
|
|
Dan Čermák |
d092d2 |
when a deprecated function is used. clang claims to be gcc 4.2, but
|
|
Dan Čermák |
d092d2 |
may also support this feature. */
|
|
Dan Čermák |
d092d2 |
#if __GNUC_PREREQ (4,5) \
|
|
Dan Čermák |
d092d2 |
|| __glibc_has_extension (__attribute_deprecated_with_message__)
|
|
Dan Čermák |
d092d2 |
# define __attribute_deprecated_msg__(msg) \
|
|
Dan Čermák |
d092d2 |
__attribute__ ((__deprecated__ (msg)))
|
|
Dan Čermák |
d092d2 |
#else
|
|
Dan Čermák |
d092d2 |
# define __attribute_deprecated_msg__(msg) __attribute_deprecated__
|
|
Dan Čermák |
d092d2 |
#endif
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
/* At some point during the gcc 2.8 development the `format_arg' attribute
|
|
Dan Čermák |
d092d2 |
for functions was introduced. We don't want to use it unconditionally
|
|
Dan Čermák |
d092d2 |
(although this would be possible) since it generates warnings.
|
|
Dan Čermák |
d092d2 |
If several `format_arg' attributes are given for the same function, in
|
|
Dan Čermák |
d092d2 |
gcc-3.0 and older, all but the last one are ignored. In newer gccs,
|
|
Dan Čermák |
d092d2 |
all designated arguments are considered. */
|
|
Dan Čermák |
d092d2 |
#if __GNUC_PREREQ (2,8) || __glibc_has_attribute (__format_arg__)
|
|
Dan Čermák |
d092d2 |
# define __attribute_format_arg__(x) __attribute__ ((__format_arg__ (x)))
|
|
Dan Čermák |
d092d2 |
#else
|
|
Dan Čermák |
d092d2 |
# define __attribute_format_arg__(x) /* Ignore */
|
|
Dan Čermák |
d092d2 |
#endif
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
/* At some point during the gcc 2.97 development the `strfmon' format
|
|
Dan Čermák |
d092d2 |
attribute for functions was introduced. We don't want to use it
|
|
Dan Čermák |
d092d2 |
unconditionally (although this would be possible) since it
|
|
Dan Čermák |
d092d2 |
generates warnings. */
|
|
Dan Čermák |
d092d2 |
#if __GNUC_PREREQ (2,97) || __glibc_has_attribute (__format__)
|
|
Dan Čermák |
d092d2 |
# define __attribute_format_strfmon__(a,b) \
|
|
Dan Čermák |
d092d2 |
__attribute__ ((__format__ (__strfmon__, a, b)))
|
|
Dan Čermák |
d092d2 |
#else
|
|
Dan Čermák |
d092d2 |
# define __attribute_format_strfmon__(a,b) /* Ignore */
|
|
Dan Čermák |
d092d2 |
#endif
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
/* The nonnull function attribute marks pointer parameters that
|
|
Dan Čermák |
d092d2 |
must not be NULL. This has the name __nonnull in glibc,
|
|
Dan Čermák |
d092d2 |
and __attribute_nonnull__ in files shared with Gnulib to avoid
|
|
Dan Čermák |
d092d2 |
collision with a different __nonnull in DragonFlyBSD 5.9. */
|
|
Dan Čermák |
d092d2 |
#ifndef __attribute_nonnull__
|
|
Dan Čermák |
d092d2 |
# if __GNUC_PREREQ (3,3) || __glibc_has_attribute (__nonnull__)
|
|
Dan Čermák |
d092d2 |
# define __attribute_nonnull__(params) __attribute__ ((__nonnull__ params))
|
|
Dan Čermák |
d092d2 |
# else
|
|
Dan Čermák |
d092d2 |
# define __attribute_nonnull__(params)
|
|
Dan Čermák |
d092d2 |
# endif
|
|
Dan Čermák |
d092d2 |
#endif
|
|
Dan Čermák |
d092d2 |
#ifndef __nonnull
|
|
Dan Čermák |
d092d2 |
# define __nonnull(params) __attribute_nonnull__ (params)
|
|
Dan Čermák |
d092d2 |
#endif
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
/* The returns_nonnull function attribute marks the return type of the function
|
|
Dan Čermák |
d092d2 |
as always being non-null. */
|
|
Dan Čermák |
d092d2 |
#ifndef __returns_nonnull
|
|
Dan Čermák |
d092d2 |
# if __GNUC_PREREQ (4, 9) || __glibc_has_attribute (__returns_nonnull__)
|
|
Dan Čermák |
d092d2 |
# define __returns_nonnull __attribute__ ((__returns_nonnull__))
|
|
Dan Čermák |
d092d2 |
# else
|
|
Dan Čermák |
d092d2 |
# define __returns_nonnull
|
|
Dan Čermák |
d092d2 |
# endif
|
|
Dan Čermák |
d092d2 |
#endif
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
/* If fortification mode, we warn about unused results of certain
|
|
Dan Čermák |
d092d2 |
function calls which can lead to problems. */
|
|
Dan Čermák |
d092d2 |
#if __GNUC_PREREQ (3,4) || __glibc_has_attribute (__warn_unused_result__)
|
|
Dan Čermák |
d092d2 |
# define __attribute_warn_unused_result__ \
|
|
Dan Čermák |
d092d2 |
__attribute__ ((__warn_unused_result__))
|
|
Dan Čermák |
d092d2 |
# if defined __USE_FORTIFY_LEVEL && __USE_FORTIFY_LEVEL > 0
|
|
Dan Čermák |
d092d2 |
# define __wur __attribute_warn_unused_result__
|
|
Dan Čermák |
d092d2 |
# endif
|
|
Dan Čermák |
d092d2 |
#else
|
|
Dan Čermák |
d092d2 |
# define __attribute_warn_unused_result__ /* empty */
|
|
Dan Čermák |
d092d2 |
#endif
|
|
Dan Čermák |
d092d2 |
#ifndef __wur
|
|
Dan Čermák |
d092d2 |
# define __wur /* Ignore */
|
|
Dan Čermák |
d092d2 |
#endif
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
/* Forces a function to be always inlined. */
|
|
Dan Čermák |
d092d2 |
#if __GNUC_PREREQ (3,2) || __glibc_has_attribute (__always_inline__)
|
|
Dan Čermák |
d092d2 |
/* The Linux kernel defines __always_inline in stddef.h (283d7573), and
|
|
Dan Čermák |
d092d2 |
it conflicts with this definition. Therefore undefine it first to
|
|
Dan Čermák |
d092d2 |
allow either header to be included first. */
|
|
Dan Čermák |
d092d2 |
# undef __always_inline
|
|
Dan Čermák |
d092d2 |
# define __always_inline __inline __attribute__ ((__always_inline__))
|
|
Dan Čermák |
d092d2 |
#else
|
|
Dan Čermák |
d092d2 |
# undef __always_inline
|
|
Dan Čermák |
d092d2 |
# define __always_inline __inline
|
|
Dan Čermák |
d092d2 |
#endif
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
/* Associate error messages with the source location of the call site rather
|
|
Dan Čermák |
d092d2 |
than with the source location inside the function. */
|
|
Dan Čermák |
d092d2 |
#if __GNUC_PREREQ (4,3) || __glibc_has_attribute (__artificial__)
|
|
Dan Čermák |
d092d2 |
# define __attribute_artificial__ __attribute__ ((__artificial__))
|
|
Dan Čermák |
d092d2 |
#else
|
|
Dan Čermák |
d092d2 |
# define __attribute_artificial__ /* Ignore */
|
|
Dan Čermák |
d092d2 |
#endif
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
/* GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99
|
|
Dan Čermák |
d092d2 |
inline semantics, unless -fgnu89-inline is used. Using __GNUC_STDC_INLINE__
|
|
Dan Čermák |
d092d2 |
or __GNUC_GNU_INLINE is not a good enough check for gcc because gcc versions
|
|
Dan Čermák |
d092d2 |
older than 4.3 may define these macros and still not guarantee GNU inlining
|
|
Dan Čermák |
d092d2 |
semantics.
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
clang++ identifies itself as gcc-4.2, but has support for GNU inlining
|
|
Dan Čermák |
d092d2 |
semantics, that can be checked for by using the __GNUC_STDC_INLINE_ and
|
|
Dan Čermák |
d092d2 |
__GNUC_GNU_INLINE__ macro definitions. */
|
|
Dan Čermák |
d092d2 |
#if (!defined __cplusplus || __GNUC_PREREQ (4,3) \
|
|
Dan Čermák |
d092d2 |
|| (defined __clang__ && (defined __GNUC_STDC_INLINE__ \
|
|
Dan Čermák |
d092d2 |
|| defined __GNUC_GNU_INLINE__)))
|
|
Dan Čermák |
d092d2 |
# if defined __GNUC_STDC_INLINE__ || defined __cplusplus
|
|
Dan Čermák |
d092d2 |
# define __extern_inline extern __inline __attribute__ ((__gnu_inline__))
|
|
Dan Čermák |
d092d2 |
# define __extern_always_inline \
|
|
Dan Čermák |
d092d2 |
extern __always_inline __attribute__ ((__gnu_inline__))
|
|
Dan Čermák |
d092d2 |
# else
|
|
Dan Čermák |
d092d2 |
# define __extern_inline extern __inline
|
|
Dan Čermák |
d092d2 |
# define __extern_always_inline extern __always_inline
|
|
Dan Čermák |
d092d2 |
# endif
|
|
Dan Čermák |
d092d2 |
#endif
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
#ifdef __extern_always_inline
|
|
Dan Čermák |
d092d2 |
# define __fortify_function __extern_always_inline __attribute_artificial__
|
|
Dan Čermák |
d092d2 |
#endif
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
/* GCC 4.3 and above allow passing all anonymous arguments of an
|
|
Dan Čermák |
d092d2 |
__extern_always_inline function to some other vararg function. */
|
|
Dan Čermák |
d092d2 |
#if __GNUC_PREREQ (4,3)
|
|
Dan Čermák |
d092d2 |
# define __va_arg_pack() __builtin_va_arg_pack ()
|
|
Dan Čermák |
d092d2 |
# define __va_arg_pack_len() __builtin_va_arg_pack_len ()
|
|
Dan Čermák |
d092d2 |
#endif
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
/* It is possible to compile containing GCC extensions even if GCC is
|
|
Dan Čermák |
d092d2 |
run in pedantic mode if the uses are carefully marked using the
|
|
Dan Čermák |
d092d2 |
`__extension__' keyword. But this is not generally available before
|
|
Dan Čermák |
d092d2 |
version 2.8. */
|
|
Dan Čermák |
d092d2 |
#if !(__GNUC_PREREQ (2,8) || defined __clang__)
|
|
Dan Čermák |
d092d2 |
# define __extension__ /* Ignore */
|
|
Dan Čermák |
d092d2 |
#endif
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
/* __restrict is known in EGCS 1.2 and above, and in clang.
|
|
Dan Čermák |
d092d2 |
It works also in C++ mode (outside of arrays), but only when spelled
|
|
Dan Čermák |
d092d2 |
as '__restrict', not 'restrict'. */
|
|
Dan Čermák |
d092d2 |
#if !(__GNUC_PREREQ (2,92) || __clang_major__ >= 3)
|
|
Dan Čermák |
d092d2 |
# if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
|
|
Dan Čermák |
d092d2 |
# define __restrict restrict
|
|
Dan Čermák |
d092d2 |
# else
|
|
Dan Čermák |
d092d2 |
# define __restrict /* Ignore */
|
|
Dan Čermák |
d092d2 |
# endif
|
|
Dan Čermák |
d092d2 |
#endif
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
/* ISO C99 also allows to declare arrays as non-overlapping. The syntax is
|
|
Dan Čermák |
d092d2 |
array_name[restrict]
|
|
Dan Čermák |
d092d2 |
GCC 3.1 and clang support this.
|
|
Dan Čermák |
d092d2 |
This syntax is not usable in C++ mode. */
|
|
Dan Čermák |
d092d2 |
#if (__GNUC_PREREQ (3,1) || __clang_major__ >= 3) && !defined __cplusplus
|
|
Dan Čermák |
d092d2 |
# define __restrict_arr __restrict
|
|
Dan Čermák |
d092d2 |
#else
|
|
Dan Čermák |
d092d2 |
# ifdef __GNUC__
|
|
Dan Čermák |
d092d2 |
# define __restrict_arr /* Not supported in old GCC. */
|
|
Dan Čermák |
d092d2 |
# else
|
|
Dan Čermák |
d092d2 |
# if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L
|
|
Dan Čermák |
d092d2 |
# define __restrict_arr restrict
|
|
Dan Čermák |
d092d2 |
# else
|
|
Dan Čermák |
d092d2 |
/* Some other non-C99 compiler. */
|
|
Dan Čermák |
d092d2 |
# define __restrict_arr /* Not supported. */
|
|
Dan Čermák |
d092d2 |
# endif
|
|
Dan Čermák |
d092d2 |
# endif
|
|
Dan Čermák |
d092d2 |
#endif
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
#if (__GNUC__ >= 3) || __glibc_has_builtin (__builtin_expect)
|
|
Dan Čermák |
d092d2 |
# define __glibc_unlikely(cond) __builtin_expect ((cond), 0)
|
|
Dan Čermák |
d092d2 |
# define __glibc_likely(cond) __builtin_expect ((cond), 1)
|
|
Dan Čermák |
d092d2 |
#else
|
|
Dan Čermák |
d092d2 |
# define __glibc_unlikely(cond) (cond)
|
|
Dan Čermák |
d092d2 |
# define __glibc_likely(cond) (cond)
|
|
Dan Čermák |
d092d2 |
#endif
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
#if (!defined _Noreturn \
|
|
Dan Čermák |
d092d2 |
&& (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \
|
|
Dan Čermák |
d092d2 |
&& !(__GNUC_PREREQ (4,7) \
|
|
Dan Čermák |
d092d2 |
|| (3 < __clang_major__ + (5 <= __clang_minor__))))
|
|
Dan Čermák |
d092d2 |
# if __GNUC_PREREQ (2,8)
|
|
Dan Čermák |
d092d2 |
# define _Noreturn __attribute__ ((__noreturn__))
|
|
Dan Čermák |
d092d2 |
# else
|
|
Dan Čermák |
d092d2 |
# define _Noreturn
|
|
Dan Čermák |
d092d2 |
# endif
|
|
Dan Čermák |
d092d2 |
#endif
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
#if __GNUC_PREREQ (8, 0)
|
|
Dan Čermák |
d092d2 |
/* Describes a char array whose address can safely be passed as the first
|
|
Dan Čermák |
d092d2 |
argument to strncpy and strncat, as the char array is not necessarily
|
|
Dan Čermák |
d092d2 |
a NUL-terminated string. */
|
|
Dan Čermák |
d092d2 |
# define __attribute_nonstring__ __attribute__ ((__nonstring__))
|
|
Dan Čermák |
d092d2 |
#else
|
|
Dan Čermák |
d092d2 |
# define __attribute_nonstring__
|
|
Dan Čermák |
d092d2 |
#endif
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
/* Undefine (also defined in libc-symbols.h). */
|
|
Dan Čermák |
d092d2 |
#undef __attribute_copy__
|
|
Dan Čermák |
d092d2 |
#if __GNUC_PREREQ (9, 0)
|
|
Dan Čermák |
d092d2 |
/* Copies attributes from the declaration or type referenced by
|
|
Dan Čermák |
d092d2 |
the argument. */
|
|
Dan Čermák |
d092d2 |
# define __attribute_copy__(arg) __attribute__ ((__copy__ (arg)))
|
|
Dan Čermák |
d092d2 |
#else
|
|
Dan Čermák |
d092d2 |
# define __attribute_copy__(arg)
|
|
Dan Čermák |
d092d2 |
#endif
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
#if (!defined _Static_assert && !defined __cplusplus \
|
|
Dan Čermák |
d092d2 |
&& (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \
|
|
Dan Čermák |
d092d2 |
&& (!(__GNUC_PREREQ (4, 6) || __clang_major__ >= 4) \
|
|
Dan Čermák |
d092d2 |
|| defined __STRICT_ANSI__))
|
|
Dan Čermák |
d092d2 |
# define _Static_assert(expr, diagnostic) \
|
|
Dan Čermák |
d092d2 |
extern int (*__Static_assert_function (void)) \
|
|
Dan Čermák |
d092d2 |
[!!sizeof (struct { int __error_if_negative: (expr) ? 2 : -1; })]
|
|
Dan Čermák |
d092d2 |
#endif
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
/* Gnulib avoids including these, as they don't work on non-glibc or
|
|
Dan Čermák |
d092d2 |
older glibc platforms. */
|
|
Dan Čermák |
d092d2 |
#ifndef __GNULIB_CDEFS
|
|
Dan Čermák |
d092d2 |
# include <bits/wordsize.h>
|
|
Dan Čermák |
d092d2 |
# include <bits/long-double.h>
|
|
Dan Čermák |
d092d2 |
#endif
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
#if __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1
|
|
Dan Čermák |
d092d2 |
# ifdef __REDIRECT
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
/* Alias name defined automatically. */
|
|
Dan Čermák |
d092d2 |
# define __LDBL_REDIR(name, proto) ... unused__ldbl_redir
|
|
Dan Čermák |
d092d2 |
# define __LDBL_REDIR_DECL(name) \
|
|
Dan Čermák |
d092d2 |
extern __typeof (name) name __asm (__ASMNAME ("__" #name "ieee128"));
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
/* Alias name defined automatically, with leading underscores. */
|
|
Dan Čermák |
d092d2 |
# define __LDBL_REDIR2_DECL(name) \
|
|
Dan Čermák |
d092d2 |
extern __typeof (__##name) __##name \
|
|
Dan Čermák |
d092d2 |
__asm (__ASMNAME ("__" #name "ieee128"));
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
/* Alias name defined manually. */
|
|
Dan Čermák |
d092d2 |
# define __LDBL_REDIR1(name, proto, alias) ... unused__ldbl_redir1
|
|
Dan Čermák |
d092d2 |
# define __LDBL_REDIR1_DECL(name, alias) \
|
|
Dan Čermák |
d092d2 |
extern __typeof (name) name __asm (__ASMNAME (#alias));
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
# define __LDBL_REDIR1_NTH(name, proto, alias) \
|
|
Dan Čermák |
d092d2 |
__REDIRECT_NTH (name, proto, alias)
|
|
Dan Čermák |
d092d2 |
# define __REDIRECT_NTH_LDBL(name, proto, alias) \
|
|
Dan Čermák |
d092d2 |
__LDBL_REDIR1_NTH (name, proto, __##alias##ieee128)
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
/* Unused. */
|
|
Dan Čermák |
d092d2 |
# define __REDIRECT_LDBL(name, proto, alias) ... unused__redirect_ldbl
|
|
Dan Čermák |
d092d2 |
# define __LDBL_REDIR_NTH(name, proto) ... unused__ldbl_redir_nth
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
# else
|
|
Dan Čermák |
d092d2 |
_Static_assert (0, "IEEE 128-bits long double requires redirection on this platform");
|
|
Dan Čermák |
d092d2 |
# endif
|
|
Dan Čermák |
d092d2 |
#elif defined __LONG_DOUBLE_MATH_OPTIONAL && defined __NO_LONG_DOUBLE_MATH
|
|
Dan Čermák |
d092d2 |
# define __LDBL_COMPAT 1
|
|
Dan Čermák |
d092d2 |
# ifdef __REDIRECT
|
|
Dan Čermák |
d092d2 |
# define __LDBL_REDIR1(name, proto, alias) __REDIRECT (name, proto, alias)
|
|
Dan Čermák |
d092d2 |
# define __LDBL_REDIR(name, proto) \
|
|
Dan Čermák |
d092d2 |
__LDBL_REDIR1 (name, proto, __nldbl_##name)
|
|
Dan Čermák |
d092d2 |
# define __LDBL_REDIR1_NTH(name, proto, alias) __REDIRECT_NTH (name, proto, alias)
|
|
Dan Čermák |
d092d2 |
# define __LDBL_REDIR_NTH(name, proto) \
|
|
Dan Čermák |
d092d2 |
__LDBL_REDIR1_NTH (name, proto, __nldbl_##name)
|
|
Dan Čermák |
d092d2 |
# define __LDBL_REDIR2_DECL(name) \
|
|
Dan Čermák |
d092d2 |
extern __typeof (__##name) __##name __asm (__ASMNAME ("__nldbl___" #name));
|
|
Dan Čermák |
d092d2 |
# define __LDBL_REDIR1_DECL(name, alias) \
|
|
Dan Čermák |
d092d2 |
extern __typeof (name) name __asm (__ASMNAME (#alias));
|
|
Dan Čermák |
d092d2 |
# define __LDBL_REDIR_DECL(name) \
|
|
Dan Čermák |
d092d2 |
extern __typeof (name) name __asm (__ASMNAME ("__nldbl_" #name));
|
|
Dan Čermák |
d092d2 |
# define __REDIRECT_LDBL(name, proto, alias) \
|
|
Dan Čermák |
d092d2 |
__LDBL_REDIR1 (name, proto, __nldbl_##alias)
|
|
Dan Čermák |
d092d2 |
# define __REDIRECT_NTH_LDBL(name, proto, alias) \
|
|
Dan Čermák |
d092d2 |
__LDBL_REDIR1_NTH (name, proto, __nldbl_##alias)
|
|
Dan Čermák |
d092d2 |
# endif
|
|
Dan Čermák |
d092d2 |
#endif
|
|
Dan Čermák |
d092d2 |
#if (!defined __LDBL_COMPAT && __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 0) \
|
|
Dan Čermák |
d092d2 |
|| !defined __REDIRECT
|
|
Dan Čermák |
d092d2 |
# define __LDBL_REDIR1(name, proto, alias) name proto
|
|
Dan Čermák |
d092d2 |
# define __LDBL_REDIR(name, proto) name proto
|
|
Dan Čermák |
d092d2 |
# define __LDBL_REDIR1_NTH(name, proto, alias) name proto __THROW
|
|
Dan Čermák |
d092d2 |
# define __LDBL_REDIR_NTH(name, proto) name proto __THROW
|
|
Dan Čermák |
d092d2 |
# define __LDBL_REDIR2_DECL(name)
|
|
Dan Čermák |
d092d2 |
# define __LDBL_REDIR_DECL(name)
|
|
Dan Čermák |
d092d2 |
# ifdef __REDIRECT
|
|
Dan Čermák |
d092d2 |
# define __REDIRECT_LDBL(name, proto, alias) __REDIRECT (name, proto, alias)
|
|
Dan Čermák |
d092d2 |
# define __REDIRECT_NTH_LDBL(name, proto, alias) \
|
|
Dan Čermák |
d092d2 |
__REDIRECT_NTH (name, proto, alias)
|
|
Dan Čermák |
d092d2 |
# endif
|
|
Dan Čermák |
d092d2 |
#endif
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
/* __glibc_macro_warning (MESSAGE) issues warning MESSAGE. This is
|
|
Dan Čermák |
d092d2 |
intended for use in preprocessor macros.
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
Note: MESSAGE must be a _single_ string; concatenation of string
|
|
Dan Čermák |
d092d2 |
literals is not supported. */
|
|
Dan Čermák |
d092d2 |
#if __GNUC_PREREQ (4,8) || __glibc_clang_prereq (3,5)
|
|
Dan Čermák |
d092d2 |
# define __glibc_macro_warning1(message) _Pragma (#message)
|
|
Dan Čermák |
d092d2 |
# define __glibc_macro_warning(message) \
|
|
Dan Čermák |
d092d2 |
__glibc_macro_warning1 (GCC warning message)
|
|
Dan Čermák |
d092d2 |
#else
|
|
Dan Čermák |
d092d2 |
# define __glibc_macro_warning(msg)
|
|
Dan Čermák |
d092d2 |
#endif
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
/* Generic selection (ISO C11) is a C-only feature, available in GCC
|
|
Dan Čermák |
d092d2 |
since version 4.9. Previous versions do not provide generic
|
|
Dan Čermák |
d092d2 |
selection, even though they might set __STDC_VERSION__ to 201112L,
|
|
Dan Čermák |
d092d2 |
when in -std=c11 mode. Thus, we must check for !defined __GNUC__
|
|
Dan Čermák |
d092d2 |
when testing __STDC_VERSION__ for generic selection support.
|
|
Dan Čermák |
d092d2 |
On the other hand, Clang also defines __GNUC__, so a clang-specific
|
|
Dan Čermák |
d092d2 |
check is required to enable the use of generic selection. */
|
|
Dan Čermák |
d092d2 |
#if !defined __cplusplus \
|
|
Dan Čermák |
d092d2 |
&& (__GNUC_PREREQ (4, 9) \
|
|
Dan Čermák |
d092d2 |
|| __glibc_has_extension (c_generic_selections) \
|
|
Dan Čermák |
d092d2 |
|| (!defined __GNUC__ && defined __STDC_VERSION__ \
|
|
Dan Čermák |
d092d2 |
&& __STDC_VERSION__ >= 201112L))
|
|
Dan Čermák |
d092d2 |
# define __HAVE_GENERIC_SELECTION 1
|
|
Dan Čermák |
d092d2 |
#else
|
|
Dan Čermák |
d092d2 |
# define __HAVE_GENERIC_SELECTION 0
|
|
Dan Čermák |
d092d2 |
#endif
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
#if __GNUC_PREREQ (10, 0)
|
|
Dan Čermák |
d092d2 |
/* Designates a 1-based positional argument ref-index of pointer type
|
|
Dan Čermák |
d092d2 |
that can be used to access size-index elements of the pointed-to
|
|
Dan Čermák |
d092d2 |
array according to access mode, or at least one element when
|
|
Dan Čermák |
d092d2 |
size-index is not provided:
|
|
Dan Čermák |
d092d2 |
access (access-mode, <ref-index> [, <size-index>]) */
|
|
Dan Čermák |
d092d2 |
# define __attr_access(x) __attribute__ ((__access__ x))
|
|
Dan Čermák |
d092d2 |
/* For _FORTIFY_SOURCE == 3 we use __builtin_dynamic_object_size, which may
|
|
Dan Čermák |
d092d2 |
use the access attribute to get object sizes from function definition
|
|
Dan Čermák |
d092d2 |
arguments, so we can't use them on functions we fortify. Drop the object
|
|
Dan Čermák |
d092d2 |
size hints for such functions. */
|
|
Dan Čermák |
d092d2 |
# if __USE_FORTIFY_LEVEL == 3
|
|
Dan Čermák |
d092d2 |
# define __fortified_attr_access(a, o, s) __attribute__ ((__access__ (a, o)))
|
|
Dan Čermák |
d092d2 |
# else
|
|
Dan Čermák |
d092d2 |
# define __fortified_attr_access(a, o, s) __attr_access ((a, o, s))
|
|
Dan Čermák |
d092d2 |
# endif
|
|
Dan Čermák |
d092d2 |
# if __GNUC_PREREQ (11, 0)
|
|
Dan Čermák |
d092d2 |
# define __attr_access_none(argno) __attribute__ ((__access__ (__none__, argno)))
|
|
Dan Čermák |
d092d2 |
# else
|
|
Dan Čermák |
d092d2 |
# define __attr_access_none(argno)
|
|
Dan Čermák |
d092d2 |
# endif
|
|
Dan Čermák |
d092d2 |
#else
|
|
Dan Čermák |
d092d2 |
# define __fortified_attr_access(a, o, s)
|
|
Dan Čermák |
d092d2 |
# define __attr_access(x)
|
|
Dan Čermák |
d092d2 |
# define __attr_access_none(argno)
|
|
Dan Čermák |
d092d2 |
#endif
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
#if __GNUC_PREREQ (11, 0)
|
|
Dan Čermák |
d092d2 |
/* Designates dealloc as a function to call to deallocate objects
|
|
Dan Čermák |
d092d2 |
allocated by the declared function. */
|
|
Dan Čermák |
d092d2 |
# define __attr_dealloc(dealloc, argno) \
|
|
Dan Čermák |
d092d2 |
__attribute__ ((__malloc__ (dealloc, argno)))
|
|
Dan Čermák |
d092d2 |
# define __attr_dealloc_free __attr_dealloc (__builtin_free, 1)
|
|
Dan Čermák |
d092d2 |
#else
|
|
Dan Čermák |
d092d2 |
# define __attr_dealloc(dealloc, argno)
|
|
Dan Čermák |
d092d2 |
# define __attr_dealloc_free
|
|
Dan Čermák |
d092d2 |
#endif
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
/* Specify that a function such as setjmp or vfork may return
|
|
Dan Čermák |
d092d2 |
twice. */
|
|
Dan Čermák |
d092d2 |
#if __GNUC_PREREQ (4, 1)
|
|
Dan Čermák |
d092d2 |
# define __attribute_returns_twice__ __attribute__ ((__returns_twice__))
|
|
Dan Čermák |
d092d2 |
#else
|
|
Dan Čermák |
d092d2 |
# define __attribute_returns_twice__ /* Ignore. */
|
|
Dan Čermák |
d092d2 |
#endif
|
|
Dan Čermák |
d092d2 |
|
|
Dan Čermák |
d092d2 |
#endif /* sys/cdefs.h */
|