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