1 | #ifndef _STDLIB_H |
2 | |
3 | #ifndef _ISOMAC |
4 | # include <stddef.h> |
5 | #endif |
6 | |
7 | /* Workaround PR90731 with GCC 9 when using ldbl redirects in C++. */ |
8 | #include <bits/floatn.h> |
9 | #if defined __cplusplus && __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1 |
10 | # if __GNUC_PREREQ (9, 0) && !__GNUC_PREREQ (9, 3) |
11 | # pragma GCC system_header |
12 | # endif |
13 | #endif |
14 | |
15 | #include <stdlib/stdlib.h> |
16 | |
17 | /* Now define the internal interfaces. */ |
18 | #if !defined _ISOMAC |
19 | # include <sys/stat.h> |
20 | |
21 | # include <rtld-malloc.h> |
22 | |
23 | extern __typeof (strtol_l) __strtol_l; |
24 | extern __typeof (strtoul_l) __strtoul_l; |
25 | extern __typeof (strtoll_l) __strtoll_l; |
26 | extern __typeof (strtoull_l) __strtoull_l; |
27 | extern __typeof (strtod_l) __strtod_l; |
28 | extern __typeof (strtof_l) __strtof_l; |
29 | extern __typeof (strtold_l) __strtold_l; |
30 | libc_hidden_proto (__strtol_l) |
31 | libc_hidden_proto (__strtoul_l) |
32 | libc_hidden_proto (__strtoll_l) |
33 | libc_hidden_proto (__strtoull_l) |
34 | libc_hidden_proto (__strtod_l) |
35 | libc_hidden_proto (__strtof_l) |
36 | libc_hidden_proto (__strtold_l) |
37 | |
38 | libc_hidden_proto (exit) |
39 | libc_hidden_proto (abort) |
40 | libc_hidden_proto (getenv) |
41 | extern __typeof (secure_getenv) __libc_secure_getenv; |
42 | libc_hidden_proto (__libc_secure_getenv) |
43 | libc_hidden_proto (bsearch) |
44 | libc_hidden_proto (qsort) |
45 | extern __typeof (qsort_r) __qsort_r; |
46 | libc_hidden_proto (__qsort_r) |
47 | libc_hidden_proto (lrand48_r) |
48 | libc_hidden_proto (wctomb) |
49 | |
50 | extern long int __random (void) attribute_hidden; |
51 | extern void __srandom (unsigned int __seed); |
52 | extern char *__initstate (unsigned int __seed, char *__statebuf, |
53 | size_t __statelen); |
54 | extern char *__setstate (char *__statebuf); |
55 | extern int __random_r (struct random_data *__buf, int32_t *__result) |
56 | attribute_hidden; |
57 | extern int __srandom_r (unsigned int __seed, struct random_data *__buf) |
58 | attribute_hidden; |
59 | extern int __initstate_r (unsigned int __seed, char *__statebuf, |
60 | size_t __statelen, struct random_data *__buf) |
61 | attribute_hidden; |
62 | extern int __setstate_r (char *__statebuf, struct random_data *__buf) |
63 | attribute_hidden; |
64 | extern int __rand_r (unsigned int *__seed); |
65 | extern int __erand48_r (unsigned short int __xsubi[3], |
66 | struct drand48_data *__buffer, double *__result) |
67 | attribute_hidden; |
68 | extern int __nrand48_r (unsigned short int __xsubi[3], |
69 | struct drand48_data *__buffer, |
70 | long int *__result) attribute_hidden; |
71 | extern int __jrand48_r (unsigned short int __xsubi[3], |
72 | struct drand48_data *__buffer, |
73 | long int *__result) attribute_hidden; |
74 | extern int __srand48_r (long int __seedval, |
75 | struct drand48_data *__buffer) attribute_hidden; |
76 | extern int __seed48_r (unsigned short int __seed16v[3], |
77 | struct drand48_data *__buffer) attribute_hidden; |
78 | extern int __lcong48_r (unsigned short int __param[7], |
79 | struct drand48_data *__buffer) attribute_hidden; |
80 | |
81 | /* Internal function to compute next state of the generator. */ |
82 | extern int __drand48_iterate (unsigned short int __xsubi[3], |
83 | struct drand48_data *__buffer) |
84 | attribute_hidden; |
85 | |
86 | /* Global state for non-reentrant functions. Defined in drand48-iter.c. */ |
87 | extern struct drand48_data __libc_drand48_data attribute_hidden; |
88 | |
89 | extern int __setenv (const char *__name, const char *__value, int __replace) |
90 | attribute_hidden; |
91 | extern int __unsetenv (const char *__name) attribute_hidden; |
92 | extern int __clearenv (void) attribute_hidden; |
93 | extern char *__mktemp (char *__template) __THROW __nonnull ((1)); |
94 | libc_hidden_proto (__mktemp) |
95 | extern char *__canonicalize_file_name (const char *__name); |
96 | extern char *__realpath (const char *__name, char *__resolved); |
97 | libc_hidden_proto (__realpath) |
98 | extern int __ptsname_r (int __fd, char *__buf, size_t __buflen) |
99 | attribute_hidden; |
100 | # ifndef _ISOMAC |
101 | extern int __ptsname_internal (int fd, char *buf, size_t buflen, |
102 | struct stat64 *stp) attribute_hidden; |
103 | # endif |
104 | extern int __getpt (void); |
105 | extern int __posix_openpt (int __oflag) attribute_hidden; |
106 | |
107 | extern int __add_to_environ (const char *name, const char *value, |
108 | const char *combines, int replace) |
109 | attribute_hidden; |
110 | extern void _quicksort (void *const pbase, size_t total_elems, |
111 | size_t size, __compar_d_fn_t cmp, void *arg); |
112 | |
113 | extern int __on_exit (void (*__func) (int __status, void *__arg), void *__arg); |
114 | |
115 | extern int __cxa_atexit (void (*func) (void *), void *arg, void *d); |
116 | libc_hidden_proto (__cxa_atexit); |
117 | |
118 | extern int __cxa_thread_atexit_impl (void (*func) (void *), void *arg, |
119 | void *d); |
120 | extern void __call_tls_dtors (void) |
121 | #ifndef SHARED |
122 | __attribute__ ((weak)) |
123 | #endif |
124 | ; |
125 | libc_hidden_proto (__call_tls_dtors) |
126 | |
127 | extern void __cxa_finalize (void *d); |
128 | |
129 | extern int __posix_memalign (void **memptr, size_t alignment, size_t size); |
130 | |
131 | extern void *__libc_memalign (size_t alignment, size_t size) |
132 | __attribute_malloc__; |
133 | |
134 | extern void *__libc_reallocarray (void *__ptr, size_t __nmemb, size_t __size) |
135 | __THROW __attribute_warn_unused_result__; |
136 | libc_hidden_proto (__libc_reallocarray) |
137 | |
138 | extern int __libc_system (const char *line); |
139 | |
140 | extern __typeof (getpt) __getpt; |
141 | extern __typeof (ptsname_r) __ptsname_r; |
142 | libc_hidden_proto (__getpt) |
143 | libc_hidden_proto (__ptsname_r) |
144 | libc_hidden_proto (grantpt) |
145 | libc_hidden_proto (unlockpt) |
146 | |
147 | __typeof (arc4random) __arc4random; |
148 | libc_hidden_proto (__arc4random); |
149 | __typeof (arc4random_buf) __arc4random_buf; |
150 | libc_hidden_proto (__arc4random_buf); |
151 | __typeof (arc4random_uniform) __arc4random_uniform; |
152 | libc_hidden_proto (__arc4random_uniform); |
153 | extern void __arc4random_buf_internal (void *buffer, size_t len) |
154 | attribute_hidden; |
155 | |
156 | extern double __strtod_internal (const char *__restrict __nptr, |
157 | char **__restrict __endptr, int __group) |
158 | __THROW __nonnull ((1)) __wur; |
159 | extern float __strtof_internal (const char *__restrict __nptr, |
160 | char **__restrict __endptr, int __group) |
161 | __THROW __nonnull ((1)) __wur; |
162 | extern long double __strtold_internal (const char *__restrict __nptr, |
163 | char **__restrict __endptr, |
164 | int __group) |
165 | __THROW __nonnull ((1)) __wur; |
166 | extern long int __strtol_internal (const char *__restrict __nptr, |
167 | char **__restrict __endptr, |
168 | int __base, int __group) |
169 | __THROW __nonnull ((1)) __wur; |
170 | extern unsigned long int __strtoul_internal (const char *__restrict __nptr, |
171 | char **__restrict __endptr, |
172 | int __base, int __group) |
173 | __THROW __nonnull ((1)) __wur; |
174 | __extension__ |
175 | extern long long int __strtoll_internal (const char *__restrict __nptr, |
176 | char **__restrict __endptr, |
177 | int __base, int __group) |
178 | __THROW __nonnull ((1)) __wur; |
179 | __extension__ |
180 | extern unsigned long long int __strtoull_internal (const char * |
181 | __restrict __nptr, |
182 | char **__restrict __endptr, |
183 | int __base, int __group) |
184 | __THROW __nonnull ((1)) __wur; |
185 | libc_hidden_proto (__strtof_internal) |
186 | libc_hidden_proto (__strtod_internal) |
187 | libc_hidden_proto (__strtold_internal) |
188 | libc_hidden_proto (__strtol_internal) |
189 | libc_hidden_proto (__strtoll_internal) |
190 | libc_hidden_proto (__strtoul_internal) |
191 | libc_hidden_proto (__strtoull_internal) |
192 | |
193 | extern double ____strtod_l_internal (const char *__restrict __nptr, |
194 | char **__restrict __endptr, int __group, |
195 | locale_t __loc); |
196 | extern float ____strtof_l_internal (const char *__restrict __nptr, |
197 | char **__restrict __endptr, int __group, |
198 | locale_t __loc); |
199 | extern long double ____strtold_l_internal (const char *__restrict __nptr, |
200 | char **__restrict __endptr, |
201 | int __group, locale_t __loc); |
202 | extern long int ____strtol_l_internal (const char *__restrict __nptr, |
203 | char **__restrict __endptr, |
204 | int __base, int __group, |
205 | locale_t __loc); |
206 | extern unsigned long int ____strtoul_l_internal (const char * |
207 | __restrict __nptr, |
208 | char **__restrict __endptr, |
209 | int __base, int __group, |
210 | locale_t __loc); |
211 | __extension__ |
212 | extern long long int ____strtoll_l_internal (const char *__restrict __nptr, |
213 | char **__restrict __endptr, |
214 | int __base, int __group, |
215 | locale_t __loc); |
216 | __extension__ |
217 | extern unsigned long long int ____strtoull_l_internal (const char * |
218 | __restrict __nptr, |
219 | char ** |
220 | __restrict __endptr, |
221 | int __base, int __group, |
222 | locale_t __loc); |
223 | |
224 | libc_hidden_proto (____strtof_l_internal) |
225 | libc_hidden_proto (____strtod_l_internal) |
226 | libc_hidden_proto (____strtold_l_internal) |
227 | libc_hidden_proto (____strtol_l_internal) |
228 | libc_hidden_proto (____strtoll_l_internal) |
229 | libc_hidden_proto (____strtoul_l_internal) |
230 | libc_hidden_proto (____strtoull_l_internal) |
231 | |
232 | #include <bits/floatn.h> |
233 | libc_hidden_proto (strtof) |
234 | libc_hidden_proto (strtod) |
235 | #if __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 0 |
236 | libc_hidden_proto (strtold) |
237 | #endif |
238 | libc_hidden_proto (strtol) |
239 | libc_hidden_proto (strtoll) |
240 | libc_hidden_proto (strtoul) |
241 | libc_hidden_proto (strtoull) |
242 | |
243 | libc_hidden_proto (atoi) |
244 | |
245 | extern float __strtof_nan (const char *, char **, char); |
246 | extern double __strtod_nan (const char *, char **, char); |
247 | extern long double __strtold_nan (const char *, char **, char); |
248 | extern float __wcstof_nan (const wchar_t *, wchar_t **, wchar_t); |
249 | extern double __wcstod_nan (const wchar_t *, wchar_t **, wchar_t); |
250 | extern long double __wcstold_nan (const wchar_t *, wchar_t **, wchar_t); |
251 | |
252 | libc_hidden_proto (__strtof_nan) |
253 | libc_hidden_proto (__strtod_nan) |
254 | libc_hidden_proto (__strtold_nan) |
255 | libc_hidden_proto (__wcstof_nan) |
256 | libc_hidden_proto (__wcstod_nan) |
257 | libc_hidden_proto (__wcstold_nan) |
258 | |
259 | /* Enable _FloatN bits as needed. */ |
260 | #include <bits/floatn.h> |
261 | |
262 | #if __HAVE_DISTINCT_FLOAT128 |
263 | extern __typeof (strtof128_l) __strtof128_l; |
264 | |
265 | libc_hidden_proto (__strtof128_l) |
266 | libc_hidden_proto (strtof128) |
267 | |
268 | extern _Float128 __strtof128_nan (const char *, char **, char); |
269 | extern _Float128 __wcstof128_nan (const wchar_t *, wchar_t **, wchar_t); |
270 | |
271 | libc_hidden_proto (__strtof128_nan) |
272 | libc_hidden_proto (__wcstof128_nan) |
273 | |
274 | extern _Float128 __strtof128_internal (const char *__restrict __nptr, |
275 | char **__restrict __endptr, |
276 | int __group); |
277 | libc_hidden_proto (__strtof128_internal) |
278 | |
279 | extern _Float128 ____strtof128_l_internal (const char *__restrict __nptr, |
280 | char **__restrict __endptr, |
281 | int __group, locale_t __loc); |
282 | |
283 | libc_hidden_proto (____strtof128_l_internal) |
284 | #endif |
285 | |
286 | extern char *__ecvt (double __value, int __ndigit, int *__restrict __decpt, |
287 | int *__restrict __sign); |
288 | extern char *__fcvt (double __value, int __ndigit, int *__restrict __decpt, |
289 | int *__restrict __sign); |
290 | extern char *__gcvt (double __value, int __ndigit, char *__buf); |
291 | extern int __ecvt_r (double __value, int __ndigit, int *__restrict __decpt, |
292 | int *__restrict __sign, char *__restrict __buf, |
293 | size_t __len); |
294 | libc_hidden_proto (__ecvt_r) |
295 | extern int __fcvt_r (double __value, int __ndigit, int *__restrict __decpt, |
296 | int *__restrict __sign, char *__restrict __buf, |
297 | size_t __len); |
298 | libc_hidden_proto (__fcvt_r) |
299 | extern char *__qecvt (long double __value, int __ndigit, |
300 | int *__restrict __decpt, int *__restrict __sign); |
301 | extern char *__qfcvt (long double __value, int __ndigit, |
302 | int *__restrict __decpt, int *__restrict __sign); |
303 | extern char *__qgcvt (long double __value, int __ndigit, char *__buf); |
304 | extern int __qecvt_r (long double __value, int __ndigit, |
305 | int *__restrict __decpt, int *__restrict __sign, |
306 | char *__restrict __buf, size_t __len); |
307 | libc_hidden_proto (__qecvt_r) |
308 | extern int __qfcvt_r (long double __value, int __ndigit, |
309 | int *__restrict __decpt, int *__restrict __sign, |
310 | char *__restrict __buf, size_t __len); |
311 | libc_hidden_proto (__qfcvt_r) |
312 | |
313 | # if IS_IN (libc) |
314 | # undef MB_CUR_MAX |
315 | # define MB_CUR_MAX (_NL_CURRENT_WORD (LC_CTYPE, _NL_CTYPE_MB_CUR_MAX)) |
316 | # endif |
317 | |
318 | struct abort_msg_s |
319 | { |
320 | unsigned int size; |
321 | char msg[0]; |
322 | }; |
323 | extern struct abort_msg_s *__abort_msg; |
324 | libc_hidden_proto (__abort_msg) |
325 | |
326 | # if IS_IN (rtld) |
327 | extern __typeof (unsetenv) unsetenv attribute_hidden; |
328 | extern __typeof (__strtoul_internal) __strtoul_internal attribute_hidden; |
329 | # endif |
330 | |
331 | #endif |
332 | |
333 | #endif /* include/stdlib.h */ |
334 | |