160 lines · plain
1// -*- C++ -*-2//===----------------------------------------------------------------------===//3//4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.5// See https://llvm.org/LICENSE.txt for license information.6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception7//8//===----------------------------------------------------------------------===//9 10#ifndef _LIBCPP_CSTDLIB11#define _LIBCPP_CSTDLIB12 13/*14 cstdlib synopsis15 16Macros:17 18 EXIT_FAILURE19 EXIT_SUCCESS20 MB_CUR_MAX21 NULL22 RAND_MAX23 24namespace std25{26 27Types:28 29 size_t30 div_t31 ldiv_t32 lldiv_t // C9933 34double atof (const char* nptr);35int atoi (const char* nptr);36long atol (const char* nptr);37long long atoll(const char* nptr); // C9938double strtod (const char* restrict nptr, char** restrict endptr);39float strtof (const char* restrict nptr, char** restrict endptr); // C9940long double strtold (const char* restrict nptr, char** restrict endptr); // C9941long strtol (const char* restrict nptr, char** restrict endptr, int base);42long long strtoll (const char* restrict nptr, char** restrict endptr, int base); // C9943unsigned long strtoul (const char* restrict nptr, char** restrict endptr, int base);44unsigned long long strtoull(const char* restrict nptr, char** restrict endptr, int base); // C9945int rand(void);46void srand(unsigned int seed);47void* calloc(size_t nmemb, size_t size);48void free(void* ptr);49void* malloc(size_t size);50void* realloc(void* ptr, size_t size);51void abort(void);52int atexit(void (*func)(void));53void exit(int status);54void _Exit(int status);55char* getenv(const char* name);56int system(const char* string);57void* bsearch(const void* key, const void* base, size_t nmemb, size_t size,58 int (*compar)(const void *, const void *));59void qsort(void* base, size_t nmemb, size_t size,60 int (*compar)(const void *, const void *));61int abs( int j);62long abs( long j);63long long abs(long long j); // C++0X64long labs( long j);65long long llabs(long long j); // C9966div_t div( int numer, int denom);67ldiv_t div( long numer, long denom);68lldiv_t div(long long numer, long long denom); // C++0X69ldiv_t ldiv( long numer, long denom);70lldiv_t lldiv(long long numer, long long denom); // C9971int mblen(const char* s, size_t n);72int mbtowc(wchar_t* restrict pwc, const char* restrict s, size_t n);73int wctomb(char* s, wchar_t wchar);74size_t mbstowcs(wchar_t* restrict pwcs, const char* restrict s, size_t n);75size_t wcstombs(char* restrict s, const wchar_t* restrict pwcs, size_t n);76int at_quick_exit(void (*func)(void)) // C++1177void quick_exit(int status); // C++1178void *aligned_alloc(size_t alignment, size_t size); // C1179 80} // std81 82*/83 84#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)85# include <__cxx03/cstdlib>86#else87# include <__config>88# include <__cstddef/size_t.h>89 90# include <stdlib.h>91 92# ifndef _LIBCPP_STDLIB_H93# error <cstdlib> tried including <stdlib.h> but didn't find libc++'s <stdlib.h> header. \94 This usually means that your header search paths are not configured properly. \95 The header search paths should contain the C++ Standard Library headers before \96 any C Standard Library, and you are probably using compiler flags that make that \97 not be the case.98# endif99 100# if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)101# pragma GCC system_header102# endif103 104_LIBCPP_BEGIN_NAMESPACE_STD105 106using ::div_t _LIBCPP_USING_IF_EXISTS;107using ::ldiv_t _LIBCPP_USING_IF_EXISTS;108using ::lldiv_t _LIBCPP_USING_IF_EXISTS;109using ::atof _LIBCPP_USING_IF_EXISTS;110using ::atoi _LIBCPP_USING_IF_EXISTS;111using ::atol _LIBCPP_USING_IF_EXISTS;112using ::atoll _LIBCPP_USING_IF_EXISTS;113using ::strtod _LIBCPP_USING_IF_EXISTS;114using ::strtof _LIBCPP_USING_IF_EXISTS;115using ::strtold _LIBCPP_USING_IF_EXISTS;116using ::strtol _LIBCPP_USING_IF_EXISTS;117using ::strtoll _LIBCPP_USING_IF_EXISTS;118using ::strtoul _LIBCPP_USING_IF_EXISTS;119using ::strtoull _LIBCPP_USING_IF_EXISTS;120using ::rand _LIBCPP_USING_IF_EXISTS;121using ::srand _LIBCPP_USING_IF_EXISTS;122using ::calloc _LIBCPP_USING_IF_EXISTS;123using ::free _LIBCPP_USING_IF_EXISTS;124using ::malloc _LIBCPP_USING_IF_EXISTS;125using ::realloc _LIBCPP_USING_IF_EXISTS;126using ::abort _LIBCPP_USING_IF_EXISTS;127using ::atexit _LIBCPP_USING_IF_EXISTS;128using ::exit _LIBCPP_USING_IF_EXISTS;129using ::_Exit _LIBCPP_USING_IF_EXISTS;130using ::getenv _LIBCPP_USING_IF_EXISTS;131using ::system _LIBCPP_USING_IF_EXISTS;132using ::bsearch _LIBCPP_USING_IF_EXISTS;133using ::qsort _LIBCPP_USING_IF_EXISTS;134using ::abs _LIBCPP_USING_IF_EXISTS;135using ::labs _LIBCPP_USING_IF_EXISTS;136using ::llabs _LIBCPP_USING_IF_EXISTS;137using ::div _LIBCPP_USING_IF_EXISTS;138using ::ldiv _LIBCPP_USING_IF_EXISTS;139using ::lldiv _LIBCPP_USING_IF_EXISTS;140using ::mblen _LIBCPP_USING_IF_EXISTS;141# if _LIBCPP_HAS_WIDE_CHARACTERS142using ::mbtowc _LIBCPP_USING_IF_EXISTS;143using ::wctomb _LIBCPP_USING_IF_EXISTS;144using ::mbstowcs _LIBCPP_USING_IF_EXISTS;145using ::wcstombs _LIBCPP_USING_IF_EXISTS;146# endif147# if !defined(_LIBCPP_CXX03_LANG)148using ::at_quick_exit _LIBCPP_USING_IF_EXISTS;149using ::quick_exit _LIBCPP_USING_IF_EXISTS;150# endif151# if _LIBCPP_STD_VER >= 17152using ::aligned_alloc _LIBCPP_USING_IF_EXISTS;153# endif154 155_LIBCPP_END_NAMESPACE_STD156 157#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)158 159#endif // _LIBCPP_CSTDLIB160