10b57cec5SDimitry Andric// -*- C++ -*- 20b57cec5SDimitry Andric//===--------------------------- cstdlib ----------------------------------===// 30b57cec5SDimitry Andric// 40b57cec5SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 50b57cec5SDimitry Andric// See https://llvm.org/LICENSE.txt for license information. 60b57cec5SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 70b57cec5SDimitry Andric// 80b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 90b57cec5SDimitry Andric 100b57cec5SDimitry Andric#ifndef _LIBCPP_CSTDLIB 110b57cec5SDimitry Andric#define _LIBCPP_CSTDLIB 120b57cec5SDimitry Andric 130b57cec5SDimitry Andric/* 140b57cec5SDimitry Andric cstdlib synopsis 150b57cec5SDimitry Andric 160b57cec5SDimitry AndricMacros: 170b57cec5SDimitry Andric 180b57cec5SDimitry Andric EXIT_FAILURE 190b57cec5SDimitry Andric EXIT_SUCCESS 200b57cec5SDimitry Andric MB_CUR_MAX 210b57cec5SDimitry Andric NULL 220b57cec5SDimitry Andric RAND_MAX 230b57cec5SDimitry Andric 240b57cec5SDimitry Andricnamespace std 250b57cec5SDimitry Andric{ 260b57cec5SDimitry Andric 270b57cec5SDimitry AndricTypes: 280b57cec5SDimitry Andric 290b57cec5SDimitry Andric size_t 300b57cec5SDimitry Andric div_t 310b57cec5SDimitry Andric ldiv_t 320b57cec5SDimitry Andric lldiv_t // C99 330b57cec5SDimitry Andric 340b57cec5SDimitry Andricdouble atof (const char* nptr); 350b57cec5SDimitry Andricint atoi (const char* nptr); 360b57cec5SDimitry Andriclong atol (const char* nptr); 370b57cec5SDimitry Andriclong long atoll(const char* nptr); // C99 380b57cec5SDimitry Andricdouble strtod (const char* restrict nptr, char** restrict endptr); 390b57cec5SDimitry Andricfloat strtof (const char* restrict nptr, char** restrict endptr); // C99 400b57cec5SDimitry Andriclong double strtold (const char* restrict nptr, char** restrict endptr); // C99 410b57cec5SDimitry Andriclong strtol (const char* restrict nptr, char** restrict endptr, int base); 420b57cec5SDimitry Andriclong long strtoll (const char* restrict nptr, char** restrict endptr, int base); // C99 430b57cec5SDimitry Andricunsigned long strtoul (const char* restrict nptr, char** restrict endptr, int base); 440b57cec5SDimitry Andricunsigned long long strtoull(const char* restrict nptr, char** restrict endptr, int base); // C99 450b57cec5SDimitry Andricint rand(void); 460b57cec5SDimitry Andricvoid srand(unsigned int seed); 470b57cec5SDimitry Andricvoid* calloc(size_t nmemb, size_t size); 480b57cec5SDimitry Andricvoid free(void* ptr); 490b57cec5SDimitry Andricvoid* malloc(size_t size); 500b57cec5SDimitry Andricvoid* realloc(void* ptr, size_t size); 510b57cec5SDimitry Andricvoid abort(void); 520b57cec5SDimitry Andricint atexit(void (*func)(void)); 530b57cec5SDimitry Andricvoid exit(int status); 540b57cec5SDimitry Andricvoid _Exit(int status); 550b57cec5SDimitry Andricchar* getenv(const char* name); 560b57cec5SDimitry Andricint system(const char* string); 570b57cec5SDimitry Andricvoid* bsearch(const void* key, const void* base, size_t nmemb, size_t size, 580b57cec5SDimitry Andric int (*compar)(const void *, const void *)); 590b57cec5SDimitry Andricvoid qsort(void* base, size_t nmemb, size_t size, 600b57cec5SDimitry Andric int (*compar)(const void *, const void *)); 610b57cec5SDimitry Andricint abs( int j); 620b57cec5SDimitry Andriclong abs( long j); 630b57cec5SDimitry Andriclong long abs(long long j); // C++0X 640b57cec5SDimitry Andriclong labs( long j); 650b57cec5SDimitry Andriclong long llabs(long long j); // C99 660b57cec5SDimitry Andricdiv_t div( int numer, int denom); 670b57cec5SDimitry Andricldiv_t div( long numer, long denom); 680b57cec5SDimitry Andriclldiv_t div(long long numer, long long denom); // C++0X 690b57cec5SDimitry Andricldiv_t ldiv( long numer, long denom); 700b57cec5SDimitry Andriclldiv_t lldiv(long long numer, long long denom); // C99 710b57cec5SDimitry Andricint mblen(const char* s, size_t n); 720b57cec5SDimitry Andricint mbtowc(wchar_t* restrict pwc, const char* restrict s, size_t n); 730b57cec5SDimitry Andricint wctomb(char* s, wchar_t wchar); 740b57cec5SDimitry Andricsize_t mbstowcs(wchar_t* restrict pwcs, const char* restrict s, size_t n); 750b57cec5SDimitry Andricsize_t wcstombs(char* restrict s, const wchar_t* restrict pwcs, size_t n); 760b57cec5SDimitry Andricint at_quick_exit(void (*func)(void)) // C++11 770b57cec5SDimitry Andricvoid quick_exit(int status); // C++11 780b57cec5SDimitry Andricvoid *aligned_alloc(size_t alignment, size_t size); // C11 790b57cec5SDimitry Andric 800b57cec5SDimitry Andric} // std 810b57cec5SDimitry Andric 820b57cec5SDimitry Andric*/ 830b57cec5SDimitry Andric 840b57cec5SDimitry Andric#include <__config> 850b57cec5SDimitry Andric#include <stdlib.h> 860b57cec5SDimitry Andric 870b57cec5SDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 880b57cec5SDimitry Andric#pragma GCC system_header 890b57cec5SDimitry Andric#endif 900b57cec5SDimitry Andric 910b57cec5SDimitry Andric#ifdef __GNUC__ 920b57cec5SDimitry Andric#define _LIBCPP_UNREACHABLE() __builtin_unreachable() 930b57cec5SDimitry Andric#else 940b57cec5SDimitry Andric#define _LIBCPP_UNREACHABLE() _VSTD::abort() 950b57cec5SDimitry Andric#endif 960b57cec5SDimitry Andric 970b57cec5SDimitry Andric_LIBCPP_BEGIN_NAMESPACE_STD 980b57cec5SDimitry Andric 990b57cec5SDimitry Andricusing ::size_t; 1000b57cec5SDimitry Andricusing ::div_t; 1010b57cec5SDimitry Andricusing ::ldiv_t; 1020b57cec5SDimitry Andric#ifndef _LIBCPP_HAS_NO_LONG_LONG 1030b57cec5SDimitry Andricusing ::lldiv_t; 1040b57cec5SDimitry Andric#endif // _LIBCPP_HAS_NO_LONG_LONG 1050b57cec5SDimitry Andricusing ::atof; 1060b57cec5SDimitry Andricusing ::atoi; 1070b57cec5SDimitry Andricusing ::atol; 1080b57cec5SDimitry Andric#ifndef _LIBCPP_HAS_NO_LONG_LONG 1090b57cec5SDimitry Andricusing ::atoll; 1100b57cec5SDimitry Andric#endif // _LIBCPP_HAS_NO_LONG_LONG 1110b57cec5SDimitry Andricusing ::strtod; 1120b57cec5SDimitry Andricusing ::strtof; 1130b57cec5SDimitry Andricusing ::strtold; 1140b57cec5SDimitry Andricusing ::strtol; 1150b57cec5SDimitry Andric#ifndef _LIBCPP_HAS_NO_LONG_LONG 1160b57cec5SDimitry Andricusing ::strtoll; 1170b57cec5SDimitry Andric#endif // _LIBCPP_HAS_NO_LONG_LONG 1180b57cec5SDimitry Andricusing ::strtoul; 1190b57cec5SDimitry Andric#ifndef _LIBCPP_HAS_NO_LONG_LONG 1200b57cec5SDimitry Andricusing ::strtoull; 1210b57cec5SDimitry Andric#endif // _LIBCPP_HAS_NO_LONG_LONG 1220b57cec5SDimitry Andricusing ::rand; 1230b57cec5SDimitry Andricusing ::srand; 1240b57cec5SDimitry Andricusing ::calloc; 1250b57cec5SDimitry Andricusing ::free; 1260b57cec5SDimitry Andricusing ::malloc; 1270b57cec5SDimitry Andricusing ::realloc; 1280b57cec5SDimitry Andricusing ::abort; 1290b57cec5SDimitry Andricusing ::atexit; 1300b57cec5SDimitry Andricusing ::exit; 1310b57cec5SDimitry Andricusing ::_Exit; 1320b57cec5SDimitry Andric#ifndef _LIBCPP_WINDOWS_STORE_APP 1330b57cec5SDimitry Andricusing ::getenv; 1340b57cec5SDimitry Andricusing ::system; 1350b57cec5SDimitry Andric#endif 1360b57cec5SDimitry Andricusing ::bsearch; 1370b57cec5SDimitry Andricusing ::qsort; 1380b57cec5SDimitry Andricusing ::abs; 1390b57cec5SDimitry Andricusing ::labs; 1400b57cec5SDimitry Andric#ifndef _LIBCPP_HAS_NO_LONG_LONG 1410b57cec5SDimitry Andricusing ::llabs; 1420b57cec5SDimitry Andric#endif // _LIBCPP_HAS_NO_LONG_LONG 1430b57cec5SDimitry Andricusing ::div; 1440b57cec5SDimitry Andricusing ::ldiv; 1450b57cec5SDimitry Andric#ifndef _LIBCPP_HAS_NO_LONG_LONG 1460b57cec5SDimitry Andricusing ::lldiv; 1470b57cec5SDimitry Andric#endif // _LIBCPP_HAS_NO_LONG_LONG 1480b57cec5SDimitry Andricusing ::mblen; 1490b57cec5SDimitry Andricusing ::mbtowc; 1500b57cec5SDimitry Andricusing ::wctomb; 1510b57cec5SDimitry Andricusing ::mbstowcs; 1520b57cec5SDimitry Andricusing ::wcstombs; 1530b57cec5SDimitry Andric#if !defined(_LIBCPP_CXX03_LANG) && defined(_LIBCPP_HAS_QUICK_EXIT) 1540b57cec5SDimitry Andricusing ::at_quick_exit; 1550b57cec5SDimitry Andricusing ::quick_exit; 1560b57cec5SDimitry Andric#endif 157*480093f4SDimitry Andric#if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_ALIGNED_ALLOC) 1580b57cec5SDimitry Andricusing ::aligned_alloc; 1590b57cec5SDimitry Andric#endif 1600b57cec5SDimitry Andric 1610b57cec5SDimitry Andric_LIBCPP_END_NAMESPACE_STD 1620b57cec5SDimitry Andric 1630b57cec5SDimitry Andric#endif // _LIBCPP_CSTDLIB 164