• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef _STDLIB_H
2 #define _STDLIB_H
3 
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
7 
8 #include <features.h>
9 
10 #if __cplusplus >= 201103L
11 #define NULL nullptr
12 #elif defined(__cplusplus)
13 #define NULL 0L
14 #else
15 #define NULL ((void*)0)
16 #endif
17 
18 #define __NEED_size_t
19 #define __NEED_wchar_t
20 
21 #include <bits/alltypes.h>
22 
23 int atoi (const char *);
24 long atol (const char *);
25 long long atoll (const char *);
26 double atof (const char *);
27 
28 float strtof (const char *__restrict, char **__restrict);
29 double strtod (const char *__restrict, char **__restrict);
30 long double strtold (const char *__restrict, char **__restrict);
31 
32 long strtol (const char *__restrict, char **__restrict, int);
33 unsigned long strtoul (const char *__restrict, char **__restrict, int);
34 long long strtoll (const char *__restrict, char **__restrict, int);
35 unsigned long long strtoull (const char *__restrict, char **__restrict, int);
36 
37 int rand (void);
38 void srand (unsigned);
39 
40 void *malloc (size_t);
41 void *calloc (size_t, size_t);
42 void *realloc (void *, size_t);
43 void free (void *);
44 void *aligned_alloc(size_t, size_t);
45 void *zalloc(size_t);
46 
47 _Noreturn void abort (void);
48 int atexit (void (*) (void));
49 _Noreturn void exit (int);
50 _Noreturn void _Exit (int);
51 int at_quick_exit (void (*) (void));
52 _Noreturn void quick_exit (int);
53 
54 char *getenv (const char *);
55 
56 int system (const char *);
57 
58 void *bsearch (const void *, const void *, size_t, size_t, int (*)(const void *, const void *));
59 void qsort (void *, size_t, size_t, int (*)(const void *, const void *));
60 
61 int abs (int);
62 long labs (long);
63 long long llabs (long long);
64 
65 typedef struct { int quot, rem; } div_t;
66 typedef struct { long quot, rem; } ldiv_t;
67 typedef struct { long long quot, rem; } lldiv_t;
68 
69 div_t div (int, int);
70 ldiv_t ldiv (long, long);
71 lldiv_t lldiv (long long, long long);
72 
73 int mblen (const char *, size_t);
74 int mbtowc (wchar_t *__restrict, const char *__restrict, size_t);
75 int wctomb (char *, wchar_t);
76 size_t mbstowcs (wchar_t *__restrict, const char *__restrict, size_t);
77 size_t wcstombs (char *__restrict, const wchar_t *__restrict, size_t);
78 
79 #define EXIT_FAILURE 1
80 #define EXIT_SUCCESS 0
81 
82 size_t __ctype_get_mb_cur_max(void);
83 #define MB_CUR_MAX (__ctype_get_mb_cur_max())
84 
85 #define RAND_MAX (0x7fffffff)
86 
87 
88 #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
89  || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
90  || defined(_BSD_SOURCE)
91 
92 #define WNOHANG    1
93 #define WUNTRACED  2
94 
95 #define WEXITSTATUS(s) (((s) & 0xff00) >> 8)
96 #define WTERMSIG(s) ((s) & 0x7f)
97 #define WSTOPSIG(s) WEXITSTATUS(s)
98 #define WIFEXITED(s) (!WTERMSIG(s))
99 #define WIFSTOPPED(s) ((short)((((s)&0xffff)*0x10001)>>8) > 0x7f00)
100 #define WIFSIGNALED(s) (((s)&0xffff)-1U < 0xffu)
101 
102 int posix_memalign (void **, size_t, size_t);
103 int setenv (const char *, const char *, int);
104 int unsetenv (const char *);
105 int mkstemp (char *);
106 int mkostemp (char *, int);
107 char *mkdtemp (char *);
108 int getsubopt (char **, char *const *, char **);
109 int rand_r (unsigned *);
110 
111 #endif
112 
113 
114 #if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
115  || defined(_BSD_SOURCE)
116 char *realpath (const char *__restrict, char *__restrict);
117 long int random (void);
118 void srandom (unsigned int);
119 char *initstate (unsigned int, char *, size_t);
120 char *setstate (char *);
121 int putenv (char *);
122 int posix_openpt (int);
123 int grantpt (int);
124 int unlockpt (int);
125 char *ptsname (int);
126 char *l64a (long);
127 long a64l (const char *);
128 void setkey (const char *);
129 double drand48 (void);
130 double erand48 (unsigned short [3]);
131 long int lrand48 (void);
132 long int nrand48 (unsigned short [3]);
133 long mrand48 (void);
134 long jrand48 (unsigned short [3]);
135 void srand48 (long);
136 unsigned short *seed48 (unsigned short [3]);
137 void lcong48 (unsigned short [7]);
138 #endif
139 
140 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
141 #include <alloca.h>
142 char *mktemp (char *);
143 int mkstemps (char *, int);
144 int mkostemps (char *, int, int);
145 void *valloc (size_t);
146 void *memalign(size_t, size_t);
147 int getloadavg(double *, int);
148 int clearenv(void);
149 #define WCOREDUMP(s) ((s) & 0x80)
150 #define WIFCONTINUED(s) ((s) == 0xffff)
151 void *reallocarray (void *, size_t, size_t);
152 void qsort_r (void *, size_t, size_t, int (*)(const void *, const void *, void *), void *);
153 #endif
154 
155 #ifdef _GNU_SOURCE
156 int ptsname_r(int, char *, size_t);
157 char *ecvt(double, int, int *, int *);
158 char *fcvt(double, int, int *, int *);
159 char *gcvt(double, int, char *);
160 char *secure_getenv(const char *);
161 struct __locale_struct;
162 #endif
163 
164 #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
165 #define mkstemp64 mkstemp
166 #define mkostemp64 mkostemp
167 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
168 #define mkstemps64 mkstemps
169 #define mkostemps64 mkostemps
170 #endif
171 #endif
172 
173 #ifdef __cplusplus
174 }
175 #endif
176 
177 #endif
178