1 /* System definitions for code taken from the GNU C Library
3 Copyright 2017-2021 Free Software Foundation, Inc.
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.
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.
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/>. */
19 /* Written by Paul Eggert. */
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:
26 # include <libc-config.h>
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. */
35 /* On glibc this includes <features.h> and <sys/cdefs.h> and #defines
36 _FEATURES_H, __WORDSIZE, and __set_errno. On FreeBSD 11 it
37 includes <sys/cdefs.h> which defines __nonnull. Elsewhere it
41 /* From glibc <errno.h>. */
43 # define __set_errno(val) (errno = (val))
46 /* From glibc <features.h>. */
49 # if defined __GNUC__ && defined __GNUC_MINOR__
50 # define __GNUC_PREREQ(maj, min) ((maj) < __GNUC__ + ((min) <= __GNUC_MINOR__))
52 # define __GNUC_PREREQ(maj, min) 0
56 #ifndef __glibc_clang_prereq
57 # if defined __clang_major__ && defined __clang_minor__
58 # ifdef __apple_build_version__
59 /* Apple for some reason renumbers __clang_major__ and __clang_minor__.
60 Gnulib code uses only __glibc_clang_prereq (3, 5); map it to
61 6000000 <= __apple_build_version__. Support for other calls to
62 __glibc_clang_prereq can be added here as needed. */
63 # define __glibc_clang_prereq(maj, min) \
64 ((maj) == 3 && (min) == 5 ? 6000000 <= __apple_build_version__ : 0)
66 # define __glibc_clang_prereq(maj, min) \
67 ((maj) < __clang_major__ + ((min) <= __clang_minor__))
70 # define __glibc_clang_prereq(maj, min) 0
74 #ifndef __attribute_maybe_unused__
75 /* <sys/cdefs.h> either does not exist, or is too old for Gnulib.
76 Prepare to include <cdefs.h>, which is Gnulib's version of a
77 more-recent glibc <sys/cdefs.h>. */
79 /* Define _FEATURES_H so that <cdefs.h> does not include <features.h>. */
81 # define _FEATURES_H 1
83 /* Define __WORDSIZE so that <cdefs.h> does not attempt to include
84 nonexistent files. Make it a syntax error, since Gnulib does not
85 use __WORDSIZE now, and if Gnulib uses it later the syntax error
86 will let us know that __WORDSIZE needs configuring. */
88 # define __WORDSIZE %%%
90 /* Undef the macros unconditionally defined by our copy of glibc
91 <sys/cdefs.h>, so that they do not clash with any system-defined
99 # undef __HAVE_GENERIC_SELECTION
100 # undef __LDBL_COMPAT
102 # undef __LDBL_REDIR1
103 # undef __LDBL_REDIR1_DECL
104 # undef __LDBL_REDIR1_NTH
105 # undef __LDBL_REDIR2_DECL
106 # undef __LDBL_REDIR_DECL
107 # undef __LDBL_REDIR_NTH
113 # undef __REDIRECT_LDBL
114 # undef __REDIRECT_NTH
115 # undef __REDIRECT_NTHNL
116 # undef __REDIRECT_NTH_LDBL
120 # undef __attr_access
121 # undef __attribute__
122 # undef __attribute_alloc_size__
123 # undef __attribute_artificial__
124 # undef __attribute_const__
125 # undef __attribute_deprecated__
126 # undef __attribute_deprecated_msg__
127 # undef __attribute_format_arg__
128 # undef __attribute_format_strfmon__
129 # undef __attribute_malloc__
130 # undef __attribute_noinline__
131 # undef __attribute_nonstring__
132 # undef __attribute_pure__
133 # undef __attribute_returns_twice__
134 # undef __attribute_used__
135 # undef __attribute_warn_unused_result__
139 # undef __extension__
140 # undef __extern_always_inline
141 # undef __extern_inline
143 # undef __fortify_function
144 # undef __glibc_c99_flexarr_available
145 # undef __glibc_has_attribute
146 # undef __glibc_has_builtin
147 # undef __glibc_has_extension
148 # undef __glibc_macro_warning
149 # undef __glibc_macro_warning1
150 # undef __glibc_objsize
151 # undef __glibc_objsize0
152 # undef __glibc_unlikely
156 # undef __restrict_arr
157 # undef __va_arg_pack
158 # undef __va_arg_pack_len
161 /* Include our copy of glibc <sys/cdefs.h>. */
164 /* <cdefs.h> __inline is too pessimistic for non-GCC. */
166 # ifndef HAVE___INLINE
167 # if 199901 <= __STDC_VERSION__ || defined inline
168 # define __inline inline
174 #endif /* defined __glibc_likely */
177 /* A substitute for glibc <libc-symbols.h>, good enough for Gnulib. */
178 #define attribute_hidden
179 #define libc_hidden_proto(name)
180 #define libc_hidden_def(name)
181 #define libc_hidden_weak(name)
182 #define libc_hidden_ver(local, name)
183 #define strong_alias(name, aliasname)
184 #define weak_alias(name, aliasname)
186 /* A substitute for glibc <shlib-compat.h>, good enough for Gnulib. */
187 #define SHLIB_COMPAT(lib, introduced, obsoleted) 0
188 #define compat_symbol(lib, local, symbol, version) extern int dummy
189 #define versioned_symbol(lib, local, symbol, version) extern int dummy