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