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