| 1 |
/* System definitions for code taken from the GNU C Library |
| 2 |
|
| 3 |
Copyright 2017-2024 Free Software Foundation, Inc. |
| 4 |
|
| 5 |
This program 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 |
This program 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 this program; if not, see |
| 17 |
<https://www.gnu.org/licenses/>. */ |
| 18 |
|
| 19 |
/* Written by Paul Eggert. */ |
| 20 |
|
| 21 |
/* This is intended to be a good-enough substitute for glibc system |
| 22 |
macros like those defined in <sys/cdefs.h>, so that Gnulib code |
| 23 |
shared with glibc can do this as the first #include: |
| 24 |
|
| 25 |
#ifndef _LIBC |
| 26 |
# include <libc-config.h> |
| 27 |
#endif |
| 28 |
|
| 29 |
When compiled as part of glibc this is a no-op; when compiled as |
| 30 |
part of Gnulib this includes Gnulib's <config.h> and defines macros |
| 31 |
that glibc library code would normally assume. |
| 32 |
|
| 33 |
Note: This header file MUST NOT be included by public header files |
| 34 |
of Gnulib. */ |
| 35 |
|
| 36 |
#include <config.h> |
| 37 |
|
| 38 |
/* On glibc this includes <features.h> and <sys/cdefs.h> and #defines |
| 39 |
_FEATURES_H, __WORDSIZE, and __set_errno. On FreeBSD 11 and |
| 40 |
DragonFlyBSD 5.9 it includes <sys/cdefs.h> which defines __nonnull. |
| 41 |
Elsewhere it is harmless. */ |
| 42 |
#include <errno.h> |
| 43 |
|
| 44 |
/* From glibc <errno.h>. */ |
| 45 |
#ifndef __set_errno |
| 46 |
# define __set_errno(val) (errno = (val)) |
| 47 |
#endif |
| 48 |
|
| 49 |
/* From glibc <features.h>. */ |
| 50 |
|
| 51 |
#if defined __clang__ |
| 52 |
/* clang really only groks GNU C 4.2, regardless of its value of __GNUC__. */ |
| 53 |
# undef __GNUC_PREREQ |
| 54 |
# define __GNUC_PREREQ(maj, min) ((maj) < 4 + ((min) <= 2)) |
| 55 |
#endif |
| 56 |
#ifndef __GNUC_PREREQ |
| 57 |
# if defined __GNUC__ && defined __GNUC_MINOR__ |
| 58 |
# define __GNUC_PREREQ(maj, min) ((maj) < __GNUC__ + ((min) <= __GNUC_MINOR__)) |
| 59 |
# else |
| 60 |
# define __GNUC_PREREQ(maj, min) 0 |
| 61 |
# endif |
| 62 |
#endif |
| 63 |
|
| 64 |
#ifndef __glibc_clang_prereq |
| 65 |
# if defined __clang_major__ && defined __clang_minor__ |
| 66 |
# ifdef __apple_build_version__ |
| 67 |
/* Apple for some reason renumbers __clang_major__ and __clang_minor__. |
| 68 |
Gnulib code uses only __glibc_clang_prereq (3, 5); map it to |
| 69 |
6000000 <= __apple_build_version__. Support for other calls to |
| 70 |
__glibc_clang_prereq can be added here as needed. */ |
| 71 |
# define __glibc_clang_prereq(maj, min) \ |
| 72 |
((maj) == 3 && (min) == 5 ? 6000000 <= __apple_build_version__ : 0) |
| 73 |
# else |
| 74 |
# define __glibc_clang_prereq(maj, min) \ |
| 75 |
((maj) < __clang_major__ + ((min) <= __clang_minor__)) |
| 76 |
# endif |
| 77 |
# else |
| 78 |
# define __glibc_clang_prereq(maj, min) 0 |
| 79 |
# endif |
| 80 |
#endif |
| 81 |
|
| 82 |
#ifndef __attribute_nonnull__ |
| 83 |
/* <sys/cdefs.h> either does not exist, or is too old for Gnulib. |
| 84 |
Prepare to include <cdefs.h>, which is Gnulib's version of a |
| 85 |
more-recent glibc <sys/cdefs.h>. */ |
| 86 |
|
| 87 |
/* Define _FEATURES_H so that <cdefs.h> does not include <features.h>. */ |
| 88 |
# ifndef _FEATURES_H |
| 89 |
# define _FEATURES_H 1 |
| 90 |
# endif |
| 91 |
/* Define __GNULIB_CDEFS so that <cdefs.h> does not attempt to include |
| 92 |
nonexistent files. */ |
| 93 |
# define __GNULIB_CDEFS |
| 94 |
/* Undef the macros unconditionally defined by our copy of glibc |
| 95 |
<sys/cdefs.h>, so that they do not clash with any system-defined |
| 96 |
versions. */ |
| 97 |
# undef _SYS_CDEFS_H |
| 98 |
# undef __ASMNAME |
| 99 |
# undef __ASMNAME2 |
| 100 |
# undef __BEGIN_DECLS |
| 101 |
# undef __CONCAT |
| 102 |
# undef __END_DECLS |
| 103 |
# undef __HAVE_GENERIC_SELECTION |
| 104 |
# undef __LDBL_COMPAT |
| 105 |
# undef __LDBL_REDIR |
| 106 |
# undef __LDBL_REDIR1 |
| 107 |
# undef __LDBL_REDIR1_DECL |
| 108 |
# undef __LDBL_REDIR1_NTH |
| 109 |
# undef __LDBL_REDIR2_DECL |
| 110 |
# undef __LDBL_REDIR_DECL |
| 111 |
# undef __LDBL_REDIR_NTH |
| 112 |
# undef __LEAF |
| 113 |
# undef __LEAF_ATTR |
| 114 |
# undef __NTH |
| 115 |
# undef __NTHNL |
| 116 |
# undef __REDIRECT |
| 117 |
# undef __REDIRECT_LDBL |
| 118 |
# undef __REDIRECT_NTH |
| 119 |
# undef __REDIRECT_NTHNL |
| 120 |
# undef __REDIRECT_NTH_LDBL |
| 121 |
# undef __STRING |
| 122 |
# undef __THROW |
| 123 |
# undef __THROWNL |
| 124 |
# undef __attr_access |
| 125 |
# undef __attr_access_none |
| 126 |
# undef __attr_dealloc |
| 127 |
# undef __attr_dealloc_free |
| 128 |
# undef __attribute__ |
| 129 |
# undef __attribute_alloc_align__ |
| 130 |
# undef __attribute_alloc_size__ |
| 131 |
# undef __attribute_artificial__ |
| 132 |
# undef __attribute_const__ |
| 133 |
# undef __attribute_deprecated__ |
| 134 |
# undef __attribute_deprecated_msg__ |
| 135 |
# undef __attribute_format_arg__ |
| 136 |
# undef __attribute_format_strfmon__ |
| 137 |
# undef __attribute_malloc__ |
| 138 |
# undef __attribute_maybe_unused__ |
| 139 |
# undef __attribute_noinline__ |
| 140 |
# undef __attribute_nonstring__ |
| 141 |
# undef __attribute_pure__ |
| 142 |
# undef __attribute_returns_twice__ |
| 143 |
# undef __attribute_used__ |
| 144 |
# undef __attribute_warn_unused_result__ |
| 145 |
# undef __errordecl |
| 146 |
# undef __extension__ |
| 147 |
# undef __extern_always_inline |
| 148 |
# undef __extern_inline |
| 149 |
# undef __flexarr |
| 150 |
# undef __fortified_attr_access |
| 151 |
# undef __fortify_function |
| 152 |
# undef __glibc_c99_flexarr_available |
| 153 |
# undef __glibc_has_attribute |
| 154 |
# undef __glibc_has_builtin |
| 155 |
# undef __glibc_has_extension |
| 156 |
# undef __glibc_likely |
| 157 |
# undef __glibc_macro_warning |
| 158 |
# undef __glibc_macro_warning1 |
| 159 |
# undef __glibc_unlikely |
| 160 |
# undef __inline |
| 161 |
# undef __ptr_t |
| 162 |
# undef __restrict |
| 163 |
# undef __restrict_arr |
| 164 |
# undef __va_arg_pack |
| 165 |
# undef __va_arg_pack_len |
| 166 |
# undef __warnattr |
| 167 |
# undef __wur |
| 168 |
# ifndef __GNULIB_CDEFS |
| 169 |
# undef __bos |
| 170 |
# undef __bos0 |
| 171 |
# undef __glibc_fortify |
| 172 |
# undef __glibc_fortify_n |
| 173 |
# undef __glibc_objsize |
| 174 |
# undef __glibc_objsize0 |
| 175 |
# undef __glibc_safe_len_cond |
| 176 |
# undef __glibc_safe_or_unknown_len |
| 177 |
# undef __glibc_unsafe_len |
| 178 |
# undef __glibc_unsigned_or_positive |
| 179 |
# endif |
| 180 |
|
| 181 |
/* Include our copy of glibc <sys/cdefs.h>. */ |
| 182 |
# include <cdefs.h> |
| 183 |
|
| 184 |
/* <cdefs.h> __inline is too pessimistic for non-GCC. */ |
| 185 |
# undef __inline |
| 186 |
# ifndef HAVE___INLINE |
| 187 |
# if 199901 <= __STDC_VERSION__ || defined inline |
| 188 |
# define __inline inline |
| 189 |
# else |
| 190 |
# define __inline |
| 191 |
# endif |
| 192 |
# endif |
| 193 |
|
| 194 |
#endif /* defined __glibc_likely */ |
| 195 |
|
| 196 |
|
| 197 |
/* A substitute for glibc <libc-symbols.h>, good enough for Gnulib. */ |
| 198 |
#define attribute_hidden |
| 199 |
#define libc_hidden_proto(name) |
| 200 |
#define libc_hidden_def(name) |
| 201 |
#define libc_hidden_weak(name) |
| 202 |
#define libc_hidden_ver(local, name) |
| 203 |
#define strong_alias(name, aliasname) |
| 204 |
#define weak_alias(name, aliasname) |
| 205 |
|
| 206 |
/* A substitute for glibc <shlib-compat.h>, good enough for Gnulib. */ |
| 207 |
#define SHLIB_COMPAT(lib, introduced, obsoleted) 0 |
| 208 |
#define compat_symbol(lib, local, symbol, version) extern int dummy |
| 209 |
#define versioned_symbol(lib, local, symbol, version) extern int dummy |