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

source code of glibc/include/stdlib.h