Commit | Line | Data |
---|---|---|
c0c3707f CB |
1 | /* System definitions for code taken from the GNU C Library |
2 | ||
9c9d63b1 | 3 | Copyright 2017-2021 Free Software Foundation, Inc. |
c0c3707f CB |
4 | |
5 | This program is free software; you can redistribute it and/or | |
6 | modify it under the terms of the GNU General Public | |
7 | License as published by the Free Software Foundation; either | |
8 | version 3 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 | General Public License for more details. | |
14 | ||
15 | You should have received a copy of the GNU 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 | #include <config.h> | |
34 | ||
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 | |
38 | is harmless. */ | |
39 | #include <errno.h> | |
40 | ||
41 | /* From glibc <errno.h>. */ | |
42 | #ifndef __set_errno | |
43 | # define __set_errno(val) (errno = (val)) | |
44 | #endif | |
45 | ||
46 | /* From glibc <features.h>. */ | |
47 | ||
48 | #ifndef __GNUC_PREREQ | |
49 | # if defined __GNUC__ && defined __GNUC_MINOR__ | |
50 | # define __GNUC_PREREQ(maj, min) ((maj) < __GNUC__ + ((min) <= __GNUC_MINOR__)) | |
51 | # else | |
52 | # define __GNUC_PREREQ(maj, min) 0 | |
53 | # endif | |
54 | #endif | |
55 | ||
56 | #ifndef __glibc_clang_prereq | |
57 | # if defined __clang_major__ && defined __clang_minor__ | |
5df4cba6 SM |
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) | |
65 | # else | |
66 | # define __glibc_clang_prereq(maj, min) \ | |
67 | ((maj) < __clang_major__ + ((min) <= __clang_minor__)) | |
68 | # endif | |
c0c3707f CB |
69 | # else |
70 | # define __glibc_clang_prereq(maj, min) 0 | |
71 | # endif | |
72 | #endif | |
73 | ||
9c9d63b1 PM |
74 | #ifndef __glibc_likely |
75 | /* <sys/cdefs.h> either does not exist, or predates glibc commit | |
76 | 2012-12-28T06:33:01Z!siddhesh@redhat.com | |
77 | (91998e449e0ce758db55aecf2abc3ee510fcbc8f) | |
78 | and so does not suffice for Gnulib. Prepare to include <cdefs.h>, | |
79 | which is Gnulib's copy of a more-recent glibc <sys/cdefs.h>. */ | |
c0c3707f CB |
80 | |
81 | /* Define _FEATURES_H so that <cdefs.h> does not include <features.h>. */ | |
9c9d63b1 PM |
82 | # ifndef _FEATURES_H |
83 | # define _FEATURES_H 1 | |
84 | # endif | |
c0c3707f CB |
85 | /* Define __WORDSIZE so that <cdefs.h> does not attempt to include |
86 | nonexistent files. Make it a syntax error, since Gnulib does not | |
87 | use __WORDSIZE now, and if Gnulib uses it later the syntax error | |
88 | will let us know that __WORDSIZE needs configuring. */ | |
9c9d63b1 PM |
89 | # ifndef __WORDSIZE |
90 | # define __WORDSIZE %%% | |
91 | # endif | |
c0c3707f CB |
92 | /* Undef the macros unconditionally defined by our copy of glibc |
93 | <sys/cdefs.h>, so that they do not clash with any system-defined | |
94 | versions. */ | |
9c9d63b1 PM |
95 | # undef _SYS_CDEFS_H |
96 | # undef __ASMNAME | |
97 | # undef __ASMNAME2 | |
98 | # undef __BEGIN_DECLS | |
99 | # undef __CONCAT | |
100 | # undef __END_DECLS | |
101 | # undef __HAVE_GENERIC_SELECTION | |
102 | # undef __LDBL_COMPAT | |
103 | # undef __LDBL_REDIR | |
104 | # undef __LDBL_REDIR1 | |
105 | # undef __LDBL_REDIR1_DECL | |
106 | # undef __LDBL_REDIR1_NTH | |
107 | # undef __LDBL_REDIR2_DECL | |
108 | # undef __LDBL_REDIR_DECL | |
109 | # undef __LDBL_REDIR_NTH | |
110 | # undef __LEAF | |
111 | # undef __LEAF_ATTR | |
112 | # undef __NTH | |
113 | # undef __NTHNL | |
114 | # undef __REDIRECT | |
115 | # undef __REDIRECT_LDBL | |
116 | # undef __REDIRECT_NTH | |
117 | # undef __REDIRECT_NTHNL | |
118 | # undef __REDIRECT_NTH_LDBL | |
119 | # undef __STRING | |
120 | # undef __THROW | |
121 | # undef __THROWNL | |
122 | # undef __attr_access | |
123 | # undef __attribute__ | |
124 | # undef __attribute_alloc_size__ | |
125 | # undef __attribute_artificial__ | |
126 | # undef __attribute_const__ | |
127 | # undef __attribute_deprecated__ | |
128 | # undef __attribute_deprecated_msg__ | |
129 | # undef __attribute_format_arg__ | |
130 | # undef __attribute_format_strfmon__ | |
131 | # undef __attribute_malloc__ | |
132 | # undef __attribute_noinline__ | |
133 | # undef __attribute_nonstring__ | |
134 | # undef __attribute_pure__ | |
135 | # undef __attribute_returns_twice__ | |
136 | # undef __attribute_used__ | |
137 | # undef __attribute_warn_unused_result__ | |
138 | # undef __bos | |
139 | # undef __bos0 | |
140 | # undef __errordecl | |
141 | # undef __extension__ | |
142 | # undef __extern_always_inline | |
143 | # undef __extern_inline | |
144 | # undef __flexarr | |
145 | # undef __fortify_function | |
146 | # undef __glibc_c99_flexarr_available | |
147 | # undef __glibc_clang_has_attribute | |
148 | # undef __glibc_clang_has_builtin | |
149 | # undef __glibc_clang_has_extension | |
150 | # undef __glibc_macro_warning | |
151 | # undef __glibc_macro_warning1 | |
152 | # undef __glibc_objsize | |
153 | # undef __glibc_objsize0 | |
154 | # undef __glibc_unlikely | |
155 | # undef __inline | |
156 | # undef __ptr_t | |
157 | # undef __restrict | |
158 | # undef __restrict_arr | |
159 | # undef __va_arg_pack | |
160 | # undef __va_arg_pack_len | |
161 | # undef __warnattr | |
c0c3707f CB |
162 | |
163 | /* Include our copy of glibc <sys/cdefs.h>. */ | |
9c9d63b1 | 164 | # include <cdefs.h> |
c0c3707f CB |
165 | |
166 | /* <cdefs.h> __inline is too pessimistic for non-GCC. */ | |
9c9d63b1 PM |
167 | # undef __inline |
168 | # ifndef HAVE___INLINE | |
169 | # if 199901 <= __STDC_VERSION__ || defined inline | |
170 | # define __inline inline | |
171 | # else | |
172 | # define __inline | |
173 | # endif | |
c0c3707f | 174 | # endif |
9c9d63b1 PM |
175 | |
176 | #endif /* defined __glibc_likely */ | |
c0c3707f CB |
177 | |
178 | ||
179 | /* A substitute for glibc <libc-symbols.h>, good enough for Gnulib. */ | |
180 | #define attribute_hidden | |
9c9d63b1 | 181 | #define libc_hidden_proto(name) |
c0c3707f CB |
182 | #define libc_hidden_def(name) |
183 | #define libc_hidden_weak(name) | |
184 | #define libc_hidden_ver(local, name) | |
185 | #define strong_alias(name, aliasname) | |
186 | #define weak_alias(name, aliasname) | |
187 | ||
188 | /* A substitute for glibc <shlib-compat.h>, good enough for Gnulib. */ | |
189 | #define SHLIB_COMPAT(lib, introduced, obsoleted) 0 | |
698be2d8 CB |
190 | #define compat_symbol(lib, local, symbol, version) extern int dummy |
191 | #define versioned_symbol(lib, local, symbol, version) extern int dummy |