1*0b57cec5SDimitry Andric // -*- C++ -*- 2*0b57cec5SDimitry Andric //===--------------------------- stdlib.h ---------------------------------===// 3*0b57cec5SDimitry Andric // 4*0b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 5*0b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information. 6*0b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7*0b57cec5SDimitry Andric // 8*0b57cec5SDimitry Andric //===----------------------------------------------------------------------===// 9*0b57cec5SDimitry Andric 10*0b57cec5SDimitry Andric #if defined(__need_malloc_and_calloc) || defined(_LIBCPP_STDLIB_INCLUDE_NEXT) 11*0b57cec5SDimitry Andric 12*0b57cec5SDimitry Andric #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 13*0b57cec5SDimitry Andric #pragma GCC system_header 14*0b57cec5SDimitry Andric #endif 15*0b57cec5SDimitry Andric 16*0b57cec5SDimitry Andric #if defined(_LIBCPP_STDLIB_INCLUDE_NEXT) 17*0b57cec5SDimitry Andric #undef _LIBCPP_STDLIB_INCLUDE_NEXT 18*0b57cec5SDimitry Andric #endif 19*0b57cec5SDimitry Andric 20*0b57cec5SDimitry Andric #include_next <stdlib.h> 21*0b57cec5SDimitry Andric 22*0b57cec5SDimitry Andric #elif !defined(_LIBCPP_STDLIB_H) 23*0b57cec5SDimitry Andric #define _LIBCPP_STDLIB_H 24*0b57cec5SDimitry Andric 25*0b57cec5SDimitry Andric /* 26*0b57cec5SDimitry Andric stdlib.h synopsis 27*0b57cec5SDimitry Andric 28*0b57cec5SDimitry Andric Macros: 29*0b57cec5SDimitry Andric 30*0b57cec5SDimitry Andric EXIT_FAILURE 31*0b57cec5SDimitry Andric EXIT_SUCCESS 32*0b57cec5SDimitry Andric MB_CUR_MAX 33*0b57cec5SDimitry Andric NULL 34*0b57cec5SDimitry Andric RAND_MAX 35*0b57cec5SDimitry Andric 36*0b57cec5SDimitry Andric Types: 37*0b57cec5SDimitry Andric 38*0b57cec5SDimitry Andric size_t 39*0b57cec5SDimitry Andric div_t 40*0b57cec5SDimitry Andric ldiv_t 41*0b57cec5SDimitry Andric lldiv_t // C99 42*0b57cec5SDimitry Andric 43*0b57cec5SDimitry Andric double atof (const char* nptr); 44*0b57cec5SDimitry Andric int atoi (const char* nptr); 45*0b57cec5SDimitry Andric long atol (const char* nptr); 46*0b57cec5SDimitry Andric long long atoll(const char* nptr); // C99 47*0b57cec5SDimitry Andric double strtod (const char* restrict nptr, char** restrict endptr); 48*0b57cec5SDimitry Andric float strtof (const char* restrict nptr, char** restrict endptr); // C99 49*0b57cec5SDimitry Andric long double strtold (const char* restrict nptr, char** restrict endptr); // C99 50*0b57cec5SDimitry Andric long strtol (const char* restrict nptr, char** restrict endptr, int base); 51*0b57cec5SDimitry Andric long long strtoll (const char* restrict nptr, char** restrict endptr, int base); // C99 52*0b57cec5SDimitry Andric unsigned long strtoul (const char* restrict nptr, char** restrict endptr, int base); 53*0b57cec5SDimitry Andric unsigned long long strtoull(const char* restrict nptr, char** restrict endptr, int base); // C99 54*0b57cec5SDimitry Andric int rand(void); 55*0b57cec5SDimitry Andric void srand(unsigned int seed); 56*0b57cec5SDimitry Andric void* calloc(size_t nmemb, size_t size); 57*0b57cec5SDimitry Andric void free(void* ptr); 58*0b57cec5SDimitry Andric void* malloc(size_t size); 59*0b57cec5SDimitry Andric void* realloc(void* ptr, size_t size); 60*0b57cec5SDimitry Andric void abort(void); 61*0b57cec5SDimitry Andric int atexit(void (*func)(void)); 62*0b57cec5SDimitry Andric void exit(int status); 63*0b57cec5SDimitry Andric void _Exit(int status); 64*0b57cec5SDimitry Andric char* getenv(const char* name); 65*0b57cec5SDimitry Andric int system(const char* string); 66*0b57cec5SDimitry Andric void* bsearch(const void* key, const void* base, size_t nmemb, size_t size, 67*0b57cec5SDimitry Andric int (*compar)(const void *, const void *)); 68*0b57cec5SDimitry Andric void qsort(void* base, size_t nmemb, size_t size, 69*0b57cec5SDimitry Andric int (*compar)(const void *, const void *)); 70*0b57cec5SDimitry Andric int abs( int j); 71*0b57cec5SDimitry Andric long abs( long j); 72*0b57cec5SDimitry Andric long long abs(long long j); // C++0X 73*0b57cec5SDimitry Andric long labs( long j); 74*0b57cec5SDimitry Andric long long llabs(long long j); // C99 75*0b57cec5SDimitry Andric div_t div( int numer, int denom); 76*0b57cec5SDimitry Andric ldiv_t div( long numer, long denom); 77*0b57cec5SDimitry Andric lldiv_t div(long long numer, long long denom); // C++0X 78*0b57cec5SDimitry Andric ldiv_t ldiv( long numer, long denom); 79*0b57cec5SDimitry Andric lldiv_t lldiv(long long numer, long long denom); // C99 80*0b57cec5SDimitry Andric int mblen(const char* s, size_t n); 81*0b57cec5SDimitry Andric int mbtowc(wchar_t* restrict pwc, const char* restrict s, size_t n); 82*0b57cec5SDimitry Andric int wctomb(char* s, wchar_t wchar); 83*0b57cec5SDimitry Andric size_t mbstowcs(wchar_t* restrict pwcs, const char* restrict s, size_t n); 84*0b57cec5SDimitry Andric size_t wcstombs(char* restrict s, const wchar_t* restrict pwcs, size_t n); 85*0b57cec5SDimitry Andric int at_quick_exit(void (*func)(void)) // C++11 86*0b57cec5SDimitry Andric void quick_exit(int status); // C++11 87*0b57cec5SDimitry Andric void *aligned_alloc(size_t alignment, size_t size); // C11 88*0b57cec5SDimitry Andric 89*0b57cec5SDimitry Andric */ 90*0b57cec5SDimitry Andric 91*0b57cec5SDimitry Andric #include <__config> 92*0b57cec5SDimitry Andric 93*0b57cec5SDimitry Andric #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 94*0b57cec5SDimitry Andric #pragma GCC system_header 95*0b57cec5SDimitry Andric #endif 96*0b57cec5SDimitry Andric 97*0b57cec5SDimitry Andric #include_next <stdlib.h> 98*0b57cec5SDimitry Andric 99*0b57cec5SDimitry Andric #ifdef __cplusplus 100*0b57cec5SDimitry Andric #include <math.h> 101*0b57cec5SDimitry Andric #endif // __cplusplus 102*0b57cec5SDimitry Andric 103*0b57cec5SDimitry Andric #endif // _LIBCPP_STDLIB_H 104