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