1570af302Sopenharmony_ci#ifndef _STDLIB_H 2570af302Sopenharmony_ci#define _STDLIB_H 3570af302Sopenharmony_ci 4570af302Sopenharmony_ci#ifdef __cplusplus 5570af302Sopenharmony_ciextern "C" { 6570af302Sopenharmony_ci#endif 7570af302Sopenharmony_ci 8570af302Sopenharmony_ci#include <features.h> 9570af302Sopenharmony_ci 10570af302Sopenharmony_ci#ifdef __cplusplus 11570af302Sopenharmony_ci#define NULL 0L 12570af302Sopenharmony_ci#else 13570af302Sopenharmony_ci#define NULL ((void*)0) 14570af302Sopenharmony_ci#endif 15570af302Sopenharmony_ci 16570af302Sopenharmony_ci#define __NEED_size_t 17570af302Sopenharmony_ci#define __NEED_wchar_t 18570af302Sopenharmony_ci 19570af302Sopenharmony_ci#include <bits/alltypes.h> 20570af302Sopenharmony_ci 21570af302Sopenharmony_ciint atoi (const char *); 22570af302Sopenharmony_cilong atol (const char *); 23570af302Sopenharmony_cilong long atoll (const char *); 24570af302Sopenharmony_cidouble atof (const char *); 25570af302Sopenharmony_ci 26570af302Sopenharmony_cifloat strtof (const char *__restrict, char **__restrict); 27570af302Sopenharmony_cidouble strtod (const char *__restrict, char **__restrict); 28570af302Sopenharmony_cilong double strtold (const char *__restrict, char **__restrict); 29570af302Sopenharmony_ci 30570af302Sopenharmony_cilong strtol (const char *__restrict, char **__restrict, int); 31570af302Sopenharmony_ciunsigned long strtoul (const char *__restrict, char **__restrict, int); 32570af302Sopenharmony_cilong long strtoll (const char *__restrict, char **__restrict, int); 33570af302Sopenharmony_ciunsigned long long strtoull (const char *__restrict, char **__restrict, int); 34570af302Sopenharmony_ci 35570af302Sopenharmony_ciint rand (void); 36570af302Sopenharmony_civoid srand (unsigned); 37570af302Sopenharmony_ci 38570af302Sopenharmony_civoid *malloc (size_t); 39570af302Sopenharmony_civoid *calloc (size_t, size_t); 40570af302Sopenharmony_civoid *realloc (void *, size_t); 41570af302Sopenharmony_civoid free (void *); 42570af302Sopenharmony_civoid *aligned_alloc(size_t, size_t); 43570af302Sopenharmony_civoid *zalloc(size_t size); 44570af302Sopenharmony_ci 45570af302Sopenharmony_ci_Noreturn void abort (void); 46570af302Sopenharmony_ciint atexit (void (*) (void)); 47570af302Sopenharmony_ci_Noreturn void exit (int); 48570af302Sopenharmony_ci_Noreturn void _Exit (int); 49570af302Sopenharmony_ciint at_quick_exit (void (*) (void)); 50570af302Sopenharmony_ci_Noreturn void quick_exit (int); 51570af302Sopenharmony_ci 52570af302Sopenharmony_cichar *getenv (const char *); 53570af302Sopenharmony_ci 54570af302Sopenharmony_ciint system (const char *); 55570af302Sopenharmony_ci 56570af302Sopenharmony_civoid *bsearch (const void *, const void *, size_t, size_t, int (*)(const void *, const void *)); 57570af302Sopenharmony_civoid qsort (void *, size_t, size_t, int (*)(const void *, const void *)); 58570af302Sopenharmony_ci 59570af302Sopenharmony_ciint abs (int); 60570af302Sopenharmony_cilong labs (long); 61570af302Sopenharmony_cilong long llabs (long long); 62570af302Sopenharmony_ci 63570af302Sopenharmony_citypedef struct { int quot, rem; } div_t; 64570af302Sopenharmony_citypedef struct { long quot, rem; } ldiv_t; 65570af302Sopenharmony_citypedef struct { long long quot, rem; } lldiv_t; 66570af302Sopenharmony_ci 67570af302Sopenharmony_cidiv_t div (int, int); 68570af302Sopenharmony_cildiv_t ldiv (long, long); 69570af302Sopenharmony_cilldiv_t lldiv (long long, long long); 70570af302Sopenharmony_ci 71570af302Sopenharmony_ciint mblen (const char *, size_t); 72570af302Sopenharmony_ciint mbtowc (wchar_t *__restrict, const char *__restrict, size_t); 73570af302Sopenharmony_ciint wctomb (char *, wchar_t); 74570af302Sopenharmony_cisize_t mbstowcs (wchar_t *__restrict, const char *__restrict, size_t); 75570af302Sopenharmony_cisize_t wcstombs (char *__restrict, const wchar_t *__restrict, size_t); 76570af302Sopenharmony_ci 77570af302Sopenharmony_ci#define EXIT_FAILURE 1 78570af302Sopenharmony_ci#define EXIT_SUCCESS 0 79570af302Sopenharmony_ci 80570af302Sopenharmony_cisize_t __ctype_get_mb_cur_max(void); 81570af302Sopenharmony_ci#define MB_CUR_MAX (__ctype_get_mb_cur_max()) 82570af302Sopenharmony_ci 83570af302Sopenharmony_ci#define RAND_MAX (0x7fffffff) 84570af302Sopenharmony_ci 85570af302Sopenharmony_ci 86570af302Sopenharmony_ci#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ 87570af302Sopenharmony_ci || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ 88570af302Sopenharmony_ci || defined(_BSD_SOURCE) 89570af302Sopenharmony_ci 90570af302Sopenharmony_ci#define WNOHANG 1 91570af302Sopenharmony_ci#define WUNTRACED 2 92570af302Sopenharmony_ci 93570af302Sopenharmony_ci#define WEXITSTATUS(s) (((s) & 0xff00) >> 8) 94570af302Sopenharmony_ci#define WTERMSIG(s) ((s) & 0x7f) 95570af302Sopenharmony_ci#define WSTOPSIG(s) WEXITSTATUS(s) 96570af302Sopenharmony_ci#define WIFEXITED(s) (!WTERMSIG(s)) 97570af302Sopenharmony_ci#define WIFSTOPPED(s) ((short)((((s)&0xffff)*0x10001)>>8) > 0x7f00) 98570af302Sopenharmony_ci#define WIFSIGNALED(s) (((s)&0xffff)-1U < 0xffu) 99570af302Sopenharmony_ci 100570af302Sopenharmony_ciint posix_memalign (void **, size_t, size_t); 101570af302Sopenharmony_ciint setenv (const char *, const char *, int); 102570af302Sopenharmony_ciint unsetenv (const char *); 103570af302Sopenharmony_ciint mkstemp (char *); 104570af302Sopenharmony_ciint mkostemp (char *, int); 105570af302Sopenharmony_cichar *mkdtemp (char *); 106570af302Sopenharmony_ciint getsubopt (char **, char *const *, char **); 107570af302Sopenharmony_ciint rand_r (unsigned *); 108570af302Sopenharmony_ci 109570af302Sopenharmony_ci#endif 110570af302Sopenharmony_ci 111570af302Sopenharmony_ci 112570af302Sopenharmony_ci#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ 113570af302Sopenharmony_ci || defined(_BSD_SOURCE) 114570af302Sopenharmony_cichar *realpath (const char *__restrict, char *__restrict); 115570af302Sopenharmony_cilong int random (void); 116570af302Sopenharmony_civoid srandom (unsigned int); 117570af302Sopenharmony_cichar *initstate (unsigned int, char *, size_t); 118570af302Sopenharmony_cichar *setstate (char *); 119570af302Sopenharmony_ciint putenv (char *); 120570af302Sopenharmony_ciint posix_openpt (int); 121570af302Sopenharmony_ciint grantpt (int); 122570af302Sopenharmony_ciint unlockpt (int); 123570af302Sopenharmony_cichar *ptsname (int); 124570af302Sopenharmony_cichar *l64a (long); 125570af302Sopenharmony_cilong a64l (const char *); 126570af302Sopenharmony_civoid setkey (const char *); 127570af302Sopenharmony_cidouble drand48 (void); 128570af302Sopenharmony_cidouble erand48 (unsigned short [3]); 129570af302Sopenharmony_cilong int lrand48 (void); 130570af302Sopenharmony_cilong int nrand48 (unsigned short [3]); 131570af302Sopenharmony_cilong mrand48 (void); 132570af302Sopenharmony_cilong jrand48 (unsigned short [3]); 133570af302Sopenharmony_civoid srand48 (long); 134570af302Sopenharmony_ciunsigned short *seed48 (unsigned short [3]); 135570af302Sopenharmony_civoid lcong48 (unsigned short [7]); 136570af302Sopenharmony_ci#endif 137570af302Sopenharmony_ci 138570af302Sopenharmony_ci#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) 139570af302Sopenharmony_ci#include <alloca.h> 140570af302Sopenharmony_cichar *mktemp (char *); 141570af302Sopenharmony_ciint mkstemps (char *, int); 142570af302Sopenharmony_ciint mkostemps (char *, int, int); 143570af302Sopenharmony_civoid *valloc (size_t); 144570af302Sopenharmony_civoid *memalign(size_t, size_t); 145570af302Sopenharmony_ciint getloadavg(double *, int); 146570af302Sopenharmony_ciint clearenv(void); 147570af302Sopenharmony_ci#define WCOREDUMP(s) ((s) & 0x80) 148570af302Sopenharmony_ci#define WIFCONTINUED(s) ((s) == 0xffff) 149570af302Sopenharmony_civoid *reallocarray (void *, size_t, size_t); 150570af302Sopenharmony_civoid qsort_r (void *, size_t, size_t, int (*)(const void *, const void *, void *), void *); 151570af302Sopenharmony_ci#endif 152570af302Sopenharmony_ci 153570af302Sopenharmony_ci#ifdef _GNU_SOURCE 154570af302Sopenharmony_ciint ptsname_r(int, char *, size_t); 155570af302Sopenharmony_cichar *ecvt(double, int, int *, int *); 156570af302Sopenharmony_cichar *fcvt(double, int, int *, int *); 157570af302Sopenharmony_cichar *gcvt(double, int, char *); 158570af302Sopenharmony_cichar *secure_getenv(const char *); 159570af302Sopenharmony_cistruct __locale_struct; 160570af302Sopenharmony_cifloat strtof_l(const char *__restrict, char **__restrict, struct __locale_struct *); 161570af302Sopenharmony_cidouble strtod_l(const char *__restrict, char **__restrict, struct __locale_struct *); 162570af302Sopenharmony_cilong double strtold_l(const char *__restrict, char **__restrict, struct __locale_struct *); 163570af302Sopenharmony_ci#endif 164570af302Sopenharmony_ci 165570af302Sopenharmony_ci#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) 166570af302Sopenharmony_ci#define mkstemp64 mkstemp 167570af302Sopenharmony_ci#define mkostemp64 mkostemp 168570af302Sopenharmony_ci#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) 169570af302Sopenharmony_ci#define mkstemps64 mkstemps 170570af302Sopenharmony_ci#define mkostemps64 mkostemps 171570af302Sopenharmony_ci#endif 172570af302Sopenharmony_ci#endif 173570af302Sopenharmony_ci 174570af302Sopenharmony_ci#ifdef __cplusplus 175570af302Sopenharmony_ci} 176570af302Sopenharmony_ci#endif 177570af302Sopenharmony_ci 178570af302Sopenharmony_ci#endif 179