| [aad342c] | 1 | /* The header stdlib.h declare an assortment of useful functions
|
|---|
| 2 | * and to define the macros and types that help you use them.
|
|---|
| 3 | */
|
|---|
| 4 |
|
|---|
| 5 | #ifndef _STDLIB_
|
|---|
| 6 | #define _STDLIB_
|
|---|
| 7 |
|
|---|
| 8 | /* Types */
|
|---|
| 9 |
|
|---|
| 10 | typedef unsigned long int size_t;
|
|---|
| 11 |
|
|---|
| 12 | typedef int wchar_t;
|
|---|
| 13 |
|
|---|
| 14 | typedef struct _div_t {
|
|---|
| 15 | int quot;
|
|---|
| 16 | int rem;
|
|---|
| 17 | } div_t;
|
|---|
| 18 |
|
|---|
| 19 | typedef struct _ldiv_t {
|
|---|
| 20 | long int quot;
|
|---|
| 21 | long int rem;
|
|---|
| 22 | } ldiv_t;
|
|---|
| 23 |
|
|---|
| 24 | typedef struct _lldiv_t {
|
|---|
| 25 | long long int quot;
|
|---|
| 26 | long long int rem;
|
|---|
| 27 | } lldiv_t;
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 | /* Constants defined */
|
|---|
| 31 | #ifndef NULL
|
|---|
| 32 | #define NULL ((void*)0)
|
|---|
| 33 | #endif
|
|---|
| 34 |
|
|---|
| 35 | #define EXIT_FAILURE 1
|
|---|
| 36 |
|
|---|
| 37 | #define EXIT_SUCCESS 0
|
|---|
| 38 |
|
|---|
| 39 | #define MB_CUR_MAX 2
|
|---|
| 40 |
|
|---|
| 41 | #define RAND_MAX 9999999
|
|---|
| 42 |
|
|---|
| 43 | /* Functions defined */
|
|---|
| 44 |
|
|---|
| 45 | $system double atof(const char *nptr);
|
|---|
| 46 |
|
|---|
| 47 | int atoi(const char *nptr);
|
|---|
| 48 |
|
|---|
| 49 | long int atol(const char *nptr);
|
|---|
| 50 |
|
|---|
| 51 | long long int atoll(const char *nptr);
|
|---|
| 52 |
|
|---|
| 53 | double strtod(const char * restrict nptr,
|
|---|
| 54 | char ** restrict endptr);
|
|---|
| 55 |
|
|---|
| 56 | float strtof(const char * restrict nptr,
|
|---|
| 57 | char ** restrict endptr);
|
|---|
| 58 |
|
|---|
| 59 | long double strtold(const char * restrict nptr,
|
|---|
| 60 | char ** restrict endptr);
|
|---|
| 61 |
|
|---|
| 62 | long int strtol(const char * restrict nptr,
|
|---|
| 63 | char ** restrict endptr, int base);
|
|---|
| 64 |
|
|---|
| 65 | long long int strtoll(const char * restrict nptr,
|
|---|
| 66 | char ** restrict endptr, int base);
|
|---|
| 67 |
|
|---|
| 68 | unsigned long int strtoul(
|
|---|
| 69 | const char * restrict nptr,
|
|---|
| 70 | char ** restrict endptr, int base);
|
|---|
| 71 |
|
|---|
| 72 | unsigned long long int strtoull(
|
|---|
| 73 | const char * restrict nptr,
|
|---|
| 74 | char ** restrict endptr, int base);
|
|---|
| 75 |
|
|---|
| 76 | int rand(void);
|
|---|
| 77 |
|
|---|
| 78 | void srand(unsigned int seed);
|
|---|
| 79 |
|
|---|
| 80 | long int random(void);
|
|---|
| 81 |
|
|---|
| 82 | void srandom(unsigned int seed);
|
|---|
| 83 |
|
|---|
| 84 | void *aligned_alloc(size_t alignment, size_t size);
|
|---|
| 85 |
|
|---|
| 86 | void *calloc(size_t nmemb, size_t size);
|
|---|
| 87 |
|
|---|
| 88 | void free(void *ptr);
|
|---|
| 89 |
|
|---|
| 90 | void *malloc(size_t size);
|
|---|
| 91 |
|
|---|
| 92 | void *realloc(void *ptr, size_t size);
|
|---|
| 93 |
|
|---|
| 94 | _Noreturn void abort(void);
|
|---|
| 95 |
|
|---|
| 96 | int atexit(void (*func)(void));
|
|---|
| 97 |
|
|---|
| 98 | int at_quick_exit(void (*func)(void));
|
|---|
| 99 |
|
|---|
| 100 | void exit(int status);
|
|---|
| 101 |
|
|---|
| 102 | _Noreturn void _Exit(int status);
|
|---|
| 103 |
|
|---|
| 104 | char *getenv(const char *name);
|
|---|
| 105 |
|
|---|
| 106 | _Noreturn void quick_exit(int status);
|
|---|
| 107 |
|
|---|
| 108 | int system(const char *string);
|
|---|
| 109 |
|
|---|
| 110 | void *bsearch(const void *key, const void *base,
|
|---|
| 111 | size_t nmemb, size_t size,
|
|---|
| 112 | int (*compar)(const void *, const void *));
|
|---|
| 113 |
|
|---|
| 114 | void qsort(void *base, size_t nmemb, size_t size,
|
|---|
| 115 | int (*compar)(const void *, const void *));
|
|---|
| 116 |
|
|---|
| 117 | int abs(int j);
|
|---|
| 118 |
|
|---|
| 119 | long int labs(long int j);
|
|---|
| 120 |
|
|---|
| 121 | long long int llabs(long long int j);
|
|---|
| 122 |
|
|---|
| 123 | div_t div(int numer, int denom);
|
|---|
| 124 |
|
|---|
| 125 | ldiv_t ldiv(long int numer, long int denom);
|
|---|
| 126 |
|
|---|
| 127 | lldiv_t lldiv(long long int numer,
|
|---|
| 128 | long long int denom);
|
|---|
| 129 |
|
|---|
| 130 | int mblen(const char *s, size_t n);
|
|---|
| 131 |
|
|---|
| 132 | int mbtowc(wchar_t * restrict pwc,
|
|---|
| 133 | const char * restrict s, size_t n);
|
|---|
| 134 |
|
|---|
| 135 | int wctomb(char *s, wchar_t wchar);
|
|---|
| 136 |
|
|---|
| 137 | size_t mbstowcs(wchar_t * restrict pwcs,
|
|---|
| 138 | const char * restrict s, size_t n);
|
|---|
| 139 |
|
|---|
| 140 | size_t wcstombs(char * restrict s,
|
|---|
| 141 | const wchar_t * restrict pwcs, size_t n);
|
|---|
| 142 |
|
|---|
| 143 | #define __STDC_WANT_LIB_EXT1__ 1
|
|---|
| 144 |
|
|---|
| 145 | typedef int errno_t;
|
|---|
| 146 |
|
|---|
| 147 | typedef size_t rsize_t;
|
|---|
| 148 |
|
|---|
| 149 | typedef void (*constraint_handler_t)(
|
|---|
| 150 | const char * restrict msg,
|
|---|
| 151 | void * restrict ptr,
|
|---|
| 152 | errno_t error);
|
|---|
| 153 |
|
|---|
| 154 |
|
|---|
| 155 | constraint_handler_t set_constraint_handler_s(
|
|---|
| 156 | constraint_handler_t handler);
|
|---|
| 157 |
|
|---|
| 158 | void abort_handler_s(
|
|---|
| 159 | const char * restrict msg,
|
|---|
| 160 | void * restrict ptr,
|
|---|
| 161 | errno_t error);
|
|---|
| 162 |
|
|---|
| 163 | void ignore_handler_s(
|
|---|
| 164 | const char * restrict msg,
|
|---|
| 165 | void * restrict ptr,
|
|---|
| 166 | errno_t error);
|
|---|
| 167 |
|
|---|
| 168 | errno_t getenv_s(size_t * restrict len,
|
|---|
| 169 | char * restrict value, rsize_t maxsize,
|
|---|
| 170 | const char * restrict name);
|
|---|
| 171 |
|
|---|
| 172 | void *bsearch_s(const void *key, const void *base,
|
|---|
| 173 | rsize_t nmemb, rsize_t size,
|
|---|
| 174 | int (*compar)(const void *k, const void *y,
|
|---|
| 175 | void *context),
|
|---|
| 176 | void *context);
|
|---|
| 177 |
|
|---|
| 178 | errno_t qsort_s(void *base, rsize_t nmemb, rsize_t size,
|
|---|
| 179 | int (*compar)(const void *x, const void *y,
|
|---|
| 180 | void *context),
|
|---|
| 181 | void *context);
|
|---|
| 182 |
|
|---|
| 183 | errno_t wctomb_s(int * restrict status,
|
|---|
| 184 | char * restrict s,
|
|---|
| 185 | rsize_t smax,
|
|---|
| 186 | wchar_t wc);
|
|---|
| 187 |
|
|---|
| 188 | errno_t mbstowcs_s(size_t * restrict retval,
|
|---|
| 189 | wchar_t * restrict dst, rsize_t dstmax,
|
|---|
| 190 | const char * restrict src, rsize_t len);
|
|---|
| 191 |
|
|---|
| 192 | errno_t wcstombs_s(size_t * restrict retval,
|
|---|
| 193 | char * restrict dst, rsize_t dstmax,
|
|---|
| 194 | const wchar_t * restrict src, rsize_t len);
|
|---|
| 195 |
|
|---|
| 196 | #ifdef _LINUX
|
|---|
| 197 | int rand_r(unsigned int *seedp);
|
|---|
| 198 | int posix_memalign(void **memptr, size_t alignment, size_t size);
|
|---|
| 199 | #endif
|
|---|
| 200 |
|
|---|
| 201 | #endif
|
|---|