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_ci 46570af302Sopenharmony_ci_Noreturn void abort (void); 47570af302Sopenharmony_ci_Noreturn void __cfi_fail_report (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_ciunsigned int arc4random(void); 80570af302Sopenharmony_ciunsigned int arc4random_uniform(unsigned int); 81570af302Sopenharmony_civoid arc4random_buf(void *, size_t); 82570af302Sopenharmony_ci 83570af302Sopenharmony_ci#define EXIT_FAILURE 1 84570af302Sopenharmony_ci#define EXIT_SUCCESS 0 85570af302Sopenharmony_ci 86570af302Sopenharmony_cisize_t __ctype_get_mb_cur_max(void); 87570af302Sopenharmony_ci#define MB_CUR_MAX (__ctype_get_mb_cur_max()) 88570af302Sopenharmony_ci 89570af302Sopenharmony_ci#define RAND_MAX (0x7fffffff) 90570af302Sopenharmony_ci 91570af302Sopenharmony_ci 92570af302Sopenharmony_ci#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ 93570af302Sopenharmony_ci || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ 94570af302Sopenharmony_ci || defined(_BSD_SOURCE) 95570af302Sopenharmony_ci 96570af302Sopenharmony_ci#define WNOHANG 1 97570af302Sopenharmony_ci#define WUNTRACED 2 98570af302Sopenharmony_ci 99570af302Sopenharmony_ci#define WEXITSTATUS(s) (((s) & 0xff00) >> 8) 100570af302Sopenharmony_ci#define WTERMSIG(s) ((s) & 0x7f) 101570af302Sopenharmony_ci#define WSTOPSIG(s) WEXITSTATUS(s) 102570af302Sopenharmony_ci#define WIFEXITED(s) (!WTERMSIG(s)) 103570af302Sopenharmony_ci#define WIFSTOPPED(s) ((short)((((s)&0xffff)*0x10001U)>>8) > 0x7f00) 104570af302Sopenharmony_ci#define WIFSIGNALED(s) (((s)&0xffff)-1U < 0xffu) 105570af302Sopenharmony_ci 106570af302Sopenharmony_ciint posix_memalign (void **, size_t, size_t); 107570af302Sopenharmony_ciint setenv (const char *, const char *, int); 108570af302Sopenharmony_ciint unsetenv (const char *); 109570af302Sopenharmony_ciint mkstemp (char *); 110570af302Sopenharmony_ciint mkostemp (char *, int); 111570af302Sopenharmony_cichar *mkdtemp (char *); 112570af302Sopenharmony_ciint getsubopt (char **, char *const *, char **); 113570af302Sopenharmony_ciint rand_r (unsigned *); 114570af302Sopenharmony_ci 115570af302Sopenharmony_ci#endif 116570af302Sopenharmony_ci 117570af302Sopenharmony_ci 118570af302Sopenharmony_ci#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ 119570af302Sopenharmony_ci || defined(_BSD_SOURCE) 120570af302Sopenharmony_cichar *realpath (const char *__restrict, char *__restrict); 121570af302Sopenharmony_cilong int random (void); 122570af302Sopenharmony_civoid srandom (unsigned int); 123570af302Sopenharmony_cichar *initstate (unsigned int, char *, size_t); 124570af302Sopenharmony_cichar *setstate (char *); 125570af302Sopenharmony_ciint putenv (char *); 126570af302Sopenharmony_ciint posix_openpt (int); 127570af302Sopenharmony_ciint grantpt (int); 128570af302Sopenharmony_ciint unlockpt (int); 129570af302Sopenharmony_cichar *ptsname (int); 130570af302Sopenharmony_cichar *l64a (long); 131570af302Sopenharmony_cilong a64l (const char *); 132570af302Sopenharmony_civoid setkey (const char *); 133570af302Sopenharmony_cidouble drand48 (void); 134570af302Sopenharmony_cidouble erand48 (unsigned short [3]); 135570af302Sopenharmony_cilong int lrand48 (void); 136570af302Sopenharmony_cilong int nrand48 (unsigned short [3]); 137570af302Sopenharmony_cilong mrand48 (void); 138570af302Sopenharmony_cilong jrand48 (unsigned short [3]); 139570af302Sopenharmony_civoid srand48 (long); 140570af302Sopenharmony_ciunsigned short *seed48 (unsigned short [3]); 141570af302Sopenharmony_civoid lcong48 (unsigned short [7]); 142570af302Sopenharmony_ci#endif 143570af302Sopenharmony_ci 144570af302Sopenharmony_ci#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) 145570af302Sopenharmony_ci#include <alloca.h> 146570af302Sopenharmony_cichar *mktemp (char *); 147570af302Sopenharmony_ciint mkstemps (char *, int); 148570af302Sopenharmony_ciint mkostemps (char *, int, int); 149570af302Sopenharmony_civoid *valloc (size_t); 150570af302Sopenharmony_civoid *memalign(size_t, size_t); 151570af302Sopenharmony_ciint getloadavg(double *, int); 152570af302Sopenharmony_ciint clearenv(void); 153570af302Sopenharmony_ci#define WCOREDUMP(s) ((s) & 0x80) 154570af302Sopenharmony_ci#define WIFCONTINUED(s) ((s) == 0xffff) 155570af302Sopenharmony_civoid *reallocarray (void *, size_t, size_t); 156570af302Sopenharmony_civoid qsort_r (void *, size_t, size_t, int (*)(const void *, const void *, void *), void *); 157570af302Sopenharmony_ci#endif 158570af302Sopenharmony_ci 159570af302Sopenharmony_ci#ifdef _GNU_SOURCE 160570af302Sopenharmony_ciint ptsname_r(int, char *, size_t); 161570af302Sopenharmony_cichar *ecvt(double, int, int *, int *); 162570af302Sopenharmony_cichar *fcvt(double, int, int *, int *); 163570af302Sopenharmony_cichar *gcvt(double, int, char *); 164570af302Sopenharmony_cichar *secure_getenv(const char *); 165570af302Sopenharmony_cistruct __locale_struct; 166570af302Sopenharmony_cifloat strtof_l(const char *__restrict, char **__restrict, struct __locale_struct *); 167570af302Sopenharmony_cidouble strtod_l(const char *__restrict, char **__restrict, struct __locale_struct *); 168570af302Sopenharmony_cilong double strtold_l(const char *__restrict, char **__restrict, struct __locale_struct *); 169570af302Sopenharmony_ci#endif 170570af302Sopenharmony_ci 171570af302Sopenharmony_ci#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) 172570af302Sopenharmony_ci#define mkstemp64 mkstemp 173570af302Sopenharmony_ci#define mkostemp64 mkostemp 174570af302Sopenharmony_ci#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) 175570af302Sopenharmony_ci#define mkstemps64 mkstemps 176570af302Sopenharmony_ci#define mkostemps64 mkostemps 177570af302Sopenharmony_ci#endif 178570af302Sopenharmony_ci#endif 179570af302Sopenharmony_ci 180570af302Sopenharmony_ci#ifndef __LITEOS__ 181570af302Sopenharmony_ci#include <fortify/stdlib.h> 182570af302Sopenharmony_ci#endif 183570af302Sopenharmony_ci#ifdef __cplusplus 184570af302Sopenharmony_ci} 185570af302Sopenharmony_ci#endif 186570af302Sopenharmony_ci 187570af302Sopenharmony_ci#endif 188