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