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

source code of glibc/include/stdlib.h