1570af302Sopenharmony_ci#ifndef _STDLIB_H
2570af302Sopenharmony_ci#define _STDLIB_H
3570af302Sopenharmony_ci
4570af302Sopenharmony_ci#ifdef __cplusplus
5570af302Sopenharmony_ciextern "C" {
6570af302Sopenharmony_ci#endif
7570af302Sopenharmony_ci
8570af302Sopenharmony_ci#include <features.h>
9570af302Sopenharmony_ci
10570af302Sopenharmony_ci#if __cplusplus >= 201103L
11570af302Sopenharmony_ci#define NULL nullptr
12570af302Sopenharmony_ci#elif defined(__cplusplus)
13570af302Sopenharmony_ci#define NULL 0L
14570af302Sopenharmony_ci#else
15570af302Sopenharmony_ci#define NULL ((void*)0)
16570af302Sopenharmony_ci#endif
17570af302Sopenharmony_ci
18570af302Sopenharmony_ci#define __NEED_size_t
19570af302Sopenharmony_ci#define __NEED_wchar_t
20570af302Sopenharmony_ci
21570af302Sopenharmony_ci#include <bits/alltypes.h>
22570af302Sopenharmony_ci
23570af302Sopenharmony_ciint atoi (const char *);
24570af302Sopenharmony_cilong atol (const char *);
25570af302Sopenharmony_cilong long atoll (const char *);
26570af302Sopenharmony_cidouble atof (const char *);
27570af302Sopenharmony_ci
28570af302Sopenharmony_cifloat strtof (const char *__restrict, char **__restrict);
29570af302Sopenharmony_cidouble strtod (const char *__restrict, char **__restrict);
30570af302Sopenharmony_cilong double strtold (const char *__restrict, char **__restrict);
31570af302Sopenharmony_ci
32570af302Sopenharmony_cilong strtol (const char *__restrict, char **__restrict, int);
33570af302Sopenharmony_ciunsigned long strtoul (const char *__restrict, char **__restrict, int);
34570af302Sopenharmony_cilong long strtoll (const char *__restrict, char **__restrict, int);
35570af302Sopenharmony_ciunsigned long long strtoull (const char *__restrict, char **__restrict, int);
36570af302Sopenharmony_ci
37570af302Sopenharmony_ciint rand (void);
38570af302Sopenharmony_civoid srand (unsigned);
39570af302Sopenharmony_ci
40570af302Sopenharmony_civoid *malloc (size_t);
41570af302Sopenharmony_civoid *calloc (size_t, size_t);
42570af302Sopenharmony_civoid *realloc (void *, size_t);
43570af302Sopenharmony_civoid free (void *);
44570af302Sopenharmony_civoid *aligned_alloc(size_t, size_t);
45570af302Sopenharmony_ci
46570af302Sopenharmony_ci_Noreturn void abort (void);
47570af302Sopenharmony_ciint atexit (void (*) (void));
48570af302Sopenharmony_ci_Noreturn void exit (int);
49570af302Sopenharmony_ci_Noreturn void _Exit (int);
50570af302Sopenharmony_ciint at_quick_exit (void (*) (void));
51570af302Sopenharmony_ci_Noreturn void quick_exit (int);
52570af302Sopenharmony_ci
53570af302Sopenharmony_cichar *getenv (const char *);
54570af302Sopenharmony_ci
55570af302Sopenharmony_ciint system (const char *);
56570af302Sopenharmony_ci
57570af302Sopenharmony_civoid *bsearch (const void *, const void *, size_t, size_t, int (*)(const void *, const void *));
58570af302Sopenharmony_civoid qsort (void *, size_t, size_t, int (*)(const void *, const void *));
59570af302Sopenharmony_ci
60570af302Sopenharmony_ciint abs (int);
61570af302Sopenharmony_cilong labs (long);
62570af302Sopenharmony_cilong long llabs (long long);
63570af302Sopenharmony_ci
64570af302Sopenharmony_citypedef struct { int quot, rem; } div_t;
65570af302Sopenharmony_citypedef struct { long quot, rem; } ldiv_t;
66570af302Sopenharmony_citypedef struct { long long quot, rem; } lldiv_t;
67570af302Sopenharmony_ci
68570af302Sopenharmony_cidiv_t div (int, int);
69570af302Sopenharmony_cildiv_t ldiv (long, long);
70570af302Sopenharmony_cilldiv_t lldiv (long long, long long);
71570af302Sopenharmony_ci
72570af302Sopenharmony_ciint mblen (const char *, size_t);
73570af302Sopenharmony_ciint mbtowc (wchar_t *__restrict, const char *__restrict, size_t);
74570af302Sopenharmony_ciint wctomb (char *, wchar_t);
75570af302Sopenharmony_cisize_t mbstowcs (wchar_t *__restrict, const char *__restrict, size_t);
76570af302Sopenharmony_cisize_t wcstombs (char *__restrict, const wchar_t *__restrict, size_t);
77570af302Sopenharmony_ci
78570af302Sopenharmony_ciunsigned int arc4random(void);
79570af302Sopenharmony_ciunsigned int arc4random_uniform(unsigned int);
80570af302Sopenharmony_civoid arc4random_buf(void *, size_t);
81570af302Sopenharmony_ci
82570af302Sopenharmony_ci#define EXIT_FAILURE 1
83570af302Sopenharmony_ci#define EXIT_SUCCESS 0
84570af302Sopenharmony_ci
85570af302Sopenharmony_cisize_t __ctype_get_mb_cur_max(void);
86570af302Sopenharmony_ci#define MB_CUR_MAX (__ctype_get_mb_cur_max())
87570af302Sopenharmony_ci
88570af302Sopenharmony_ci#define RAND_MAX (0x7fffffff)
89570af302Sopenharmony_ci
90570af302Sopenharmony_ci
91570af302Sopenharmony_ci#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
92570af302Sopenharmony_ci || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
93570af302Sopenharmony_ci || defined(_BSD_SOURCE)
94570af302Sopenharmony_ci
95570af302Sopenharmony_ci#define WNOHANG    1
96570af302Sopenharmony_ci#define WUNTRACED  2
97570af302Sopenharmony_ci
98570af302Sopenharmony_ci#define WEXITSTATUS(s) (((s) & 0xff00) >> 8)
99570af302Sopenharmony_ci#define WTERMSIG(s) ((s) & 0x7f)
100570af302Sopenharmony_ci#define WSTOPSIG(s) WEXITSTATUS(s)
101570af302Sopenharmony_ci#define WIFEXITED(s) (!WTERMSIG(s))
102570af302Sopenharmony_ci#define WIFSTOPPED(s) ((short)((((s)&0xffff)*0x10001)>>8) > 0x7f00)
103570af302Sopenharmony_ci#define WIFSIGNALED(s) (((s)&0xffff)-1U < 0xffu)
104570af302Sopenharmony_ci
105570af302Sopenharmony_ciint posix_memalign (void **, size_t, size_t);
106570af302Sopenharmony_ciint setenv (const char *, const char *, int);
107570af302Sopenharmony_ciint unsetenv (const char *);
108570af302Sopenharmony_ciint mkstemp (char *);
109570af302Sopenharmony_ciint mkostemp (char *, int);
110570af302Sopenharmony_cichar *mkdtemp (char *);
111570af302Sopenharmony_ciint getsubopt (char **, char *const *, char **);
112570af302Sopenharmony_ciint rand_r (unsigned *);
113570af302Sopenharmony_ci
114570af302Sopenharmony_ci#endif
115570af302Sopenharmony_ci
116570af302Sopenharmony_ci
117570af302Sopenharmony_ci#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
118570af302Sopenharmony_ci || defined(_BSD_SOURCE)
119570af302Sopenharmony_cichar *realpath (const char *__restrict, char *__restrict);
120570af302Sopenharmony_cilong int random (void);
121570af302Sopenharmony_civoid srandom (unsigned int);
122570af302Sopenharmony_cichar *initstate (unsigned int, char *, size_t);
123570af302Sopenharmony_cichar *setstate (char *);
124570af302Sopenharmony_ciint putenv (char *);
125570af302Sopenharmony_ciint posix_openpt (int);
126570af302Sopenharmony_ciint grantpt (int);
127570af302Sopenharmony_ciint unlockpt (int);
128570af302Sopenharmony_cichar *ptsname (int);
129570af302Sopenharmony_cichar *l64a (long);
130570af302Sopenharmony_cilong a64l (const char *);
131570af302Sopenharmony_civoid setkey (const char *);
132570af302Sopenharmony_cidouble drand48 (void);
133570af302Sopenharmony_cidouble erand48 (unsigned short [3]);
134570af302Sopenharmony_cilong int lrand48 (void);
135570af302Sopenharmony_cilong int nrand48 (unsigned short [3]);
136570af302Sopenharmony_cilong mrand48 (void);
137570af302Sopenharmony_cilong jrand48 (unsigned short [3]);
138570af302Sopenharmony_civoid srand48 (long);
139570af302Sopenharmony_ciunsigned short *seed48 (unsigned short [3]);
140570af302Sopenharmony_civoid lcong48 (unsigned short [7]);
141570af302Sopenharmony_ci#endif
142570af302Sopenharmony_ci
143570af302Sopenharmony_ci#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
144570af302Sopenharmony_ci#include <alloca.h>
145570af302Sopenharmony_cichar *mktemp (char *);
146570af302Sopenharmony_ciint mkstemps (char *, int);
147570af302Sopenharmony_ciint mkostemps (char *, int, int);
148570af302Sopenharmony_civoid *valloc (size_t);
149570af302Sopenharmony_civoid *memalign(size_t, size_t);
150570af302Sopenharmony_ciint getloadavg(double *, int);
151570af302Sopenharmony_ciint clearenv(void);
152570af302Sopenharmony_ci#define WCOREDUMP(s) ((s) & 0x80)
153570af302Sopenharmony_ci#define WIFCONTINUED(s) ((s) == 0xffff)
154570af302Sopenharmony_civoid *reallocarray (void *, size_t, size_t);
155570af302Sopenharmony_civoid qsort_r (void *, size_t, size_t, int (*)(const void *, const void *, void *), void *);
156570af302Sopenharmony_ci#endif
157570af302Sopenharmony_ci
158570af302Sopenharmony_ci#ifdef _GNU_SOURCE
159570af302Sopenharmony_ciint ptsname_r(int, char *, size_t);
160570af302Sopenharmony_cichar *ecvt(double, int, int *, int *);
161570af302Sopenharmony_cichar *fcvt(double, int, int *, int *);
162570af302Sopenharmony_cichar *gcvt(double, int, char *);
163570af302Sopenharmony_cichar *secure_getenv(const char *);
164570af302Sopenharmony_cistruct __locale_struct;
165570af302Sopenharmony_cifloat strtof_l(const char *__restrict, char **__restrict, struct __locale_struct *);
166570af302Sopenharmony_cidouble strtod_l(const char *__restrict, char **__restrict, struct __locale_struct *);
167570af302Sopenharmony_cilong double strtold_l(const char *__restrict, char **__restrict, struct __locale_struct *);
168570af302Sopenharmony_ci#endif
169570af302Sopenharmony_ci
170570af302Sopenharmony_ci#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
171570af302Sopenharmony_ci#define mkstemp64 mkstemp
172570af302Sopenharmony_ci#define mkostemp64 mkostemp
173570af302Sopenharmony_ci#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
174570af302Sopenharmony_ci#define mkstemps64 mkstemps
175570af302Sopenharmony_ci#define mkostemps64 mkostemps
176570af302Sopenharmony_ci#endif
177570af302Sopenharmony_ci#endif
178570af302Sopenharmony_ci
179570af302Sopenharmony_ci#include <fortify/stdlib.h>
180570af302Sopenharmony_ci
181570af302Sopenharmony_ci#ifdef __cplusplus
182570af302Sopenharmony_ci}
183570af302Sopenharmony_ci#endif
184570af302Sopenharmony_ci
185570af302Sopenharmony_ci#endif
186