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