1// -*- C++ -*- 2//===--------------------------- cstdlib ----------------------------------===// 3// 4// The LLVM Compiler Infrastructure 5// 6// This file is dual licensed under the MIT and the University of Illinois Open 7// Source Licenses. See LICENSE.TXT for details. 8// 9//===----------------------------------------------------------------------===// 10 11#ifndef _LIBCPP_CSTDLIB 12#define _LIBCPP_CSTDLIB 13 14/* 15 cstdlib synopsis 16 17Macros: 18 19 EXIT_FAILURE 20 EXIT_SUCCESS 21 MB_CUR_MAX 22 NULL 23 RAND_MAX 24 25namespace std 26{ 27 28Types: 29 30 size_t 31 div_t 32 ldiv_t 33 lldiv_t // C99 34 35double atof (const char* nptr); 36int atoi (const char* nptr); 37long atol (const char* nptr); 38long long atoll(const char* nptr); // C99 39double strtod (const char* restrict nptr, char** restrict endptr); 40float strtof (const char* restrict nptr, char** restrict endptr); // C99 41long double strtold (const char* restrict nptr, char** restrict endptr); // C99 42long strtol (const char* restrict nptr, char** restrict endptr, int base); 43long long strtoll (const char* restrict nptr, char** restrict endptr, int base); // C99 44unsigned long strtoul (const char* restrict nptr, char** restrict endptr, int base); 45unsigned long long strtoull(const char* restrict nptr, char** restrict endptr, int base); // C99 46int rand(void); 47void srand(unsigned int seed); 48void* calloc(size_t nmemb, size_t size); 49void free(void* ptr); 50void* malloc(size_t size); 51void* realloc(void* ptr, size_t size); 52void abort(void); 53int atexit(void (*func)(void)); 54void exit(int status); 55void _Exit(int status); 56char* getenv(const char* name); 57int system(const char* string); 58void* bsearch(const void* key, const void* base, size_t nmemb, size_t size, 59 int (*compar)(const void *, const void *)); 60void qsort(void* base, size_t nmemb, size_t size, 61 int (*compar)(const void *, const void *)); 62int abs( int j); 63long abs( long j); 64long long abs(long long j); // C++0X 65long labs( long j); 66long long llabs(long long j); // C99 67div_t div( int numer, int denom); 68ldiv_t div( long numer, long denom); 69lldiv_t div(long long numer, long long denom); // C++0X 70ldiv_t ldiv( long numer, long denom); 71lldiv_t lldiv(long long numer, long long denom); // C99 72int mblen(const char* s, size_t n); 73int mbtowc(wchar_t* restrict pwc, const char* restrict s, size_t n); 74int wctomb(char* s, wchar_t wchar); 75size_t mbstowcs(wchar_t* restrict pwcs, const char* restrict s, size_t n); 76size_t wcstombs(char* restrict s, const wchar_t* restrict pwcs, size_t n); 77int at_quick_exit(void (*func)(void)) // C++11 78void quick_exit(int status); // C++11 79void *aligned_alloc(size_t alignment, size_t size); // C11 80 81} // std 82 83*/ 84 85#include <__config> 86#include <stdlib.h> 87 88#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 89#pragma GCC system_header 90#endif 91 92_LIBCPP_BEGIN_NAMESPACE_STD 93 94using ::size_t; 95using ::div_t; 96using ::ldiv_t; 97#ifndef _LIBCPP_HAS_NO_LONG_LONG 98using ::lldiv_t; 99#endif // _LIBCPP_HAS_NO_LONG_LONG 100using ::atof; 101using ::atoi; 102using ::atol; 103#ifndef _LIBCPP_HAS_NO_LONG_LONG 104using ::atoll; 105#endif // _LIBCPP_HAS_NO_LONG_LONG 106using ::strtod; 107using ::strtof; 108using ::strtold; 109using ::strtol; 110#ifndef _LIBCPP_HAS_NO_LONG_LONG 111using ::strtoll; 112#endif // _LIBCPP_HAS_NO_LONG_LONG 113using ::strtoul; 114#ifndef _LIBCPP_HAS_NO_LONG_LONG 115using ::strtoull; 116#endif // _LIBCPP_HAS_NO_LONG_LONG 117using ::rand; 118using ::srand; 119using ::calloc; 120using ::free; 121using ::malloc; 122using ::realloc; 123using ::abort; 124using ::atexit; 125using ::exit; 126using ::_Exit; 127using ::getenv; 128using ::system; 129using ::bsearch; 130using ::qsort; 131using ::abs; 132using ::labs; 133#ifndef _LIBCPP_HAS_NO_LONG_LONG 134using ::llabs; 135#endif // _LIBCPP_HAS_NO_LONG_LONG 136using ::div; 137using ::ldiv; 138#ifndef _LIBCPP_HAS_NO_LONG_LONG 139using ::lldiv; 140#endif // _LIBCPP_HAS_NO_LONG_LONG 141#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS 142using ::mblen; 143using ::mbtowc; 144using ::wctomb; 145#endif 146using ::mbstowcs; 147using ::wcstombs; 148#ifdef _LIBCPP_HAS_QUICK_EXIT 149using ::at_quick_exit; 150using ::quick_exit; 151#endif 152#ifdef _LIBCPP_HAS_C11_FEATURES 153using ::aligned_alloc; 154#endif 155 156_LIBCPP_END_NAMESPACE_STD 157 158#endif // _LIBCPP_CSTDLIB 159