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