2 //===----------------------------------------------------------------------===//
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-exception
8 //===----------------------------------------------------------------------===//
10 #ifndef _LIBCPP_CSTDLIB
11 #define _LIBCPP_CSTDLIB
34 double atof (const char* nptr);
35 int atoi (const char* nptr);
36 long atol (const char* nptr);
37 long long atoll(const char* nptr); // C99
38 double strtod (const char* restrict nptr, char** restrict endptr);
39 float strtof (const char* restrict nptr, char** restrict endptr); // C99
40 long double strtold (const char* restrict nptr, char** restrict endptr); // C99
41 long strtol (const char* restrict nptr, char** restrict endptr, int base);
42 long long strtoll (const char* restrict nptr, char** restrict endptr, int base); // C99
43 unsigned long strtoul (const char* restrict nptr, char** restrict endptr, int base);
44 unsigned long long strtoull(const char* restrict nptr, char** restrict endptr, int base); // C99
46 void srand(unsigned int seed);
47 void* calloc(size_t nmemb, size_t size);
49 void* malloc(size_t size);
50 void* realloc(void* ptr, size_t size);
52 int atexit(void (*func)(void));
53 void exit(int status);
54 void _Exit(int status);
55 char* getenv(const char* name);
56 int system(const char* string);
57 void* bsearch(const void* key, const void* base, size_t nmemb, size_t size,
58 int (*compar)(const void *, const void *));
59 void qsort(void* base, size_t nmemb, size_t size,
60 int (*compar)(const void *, const void *));
63 long long abs(long long j); // C++0X
65 long long llabs(long long j); // C99
66 div_t div( int numer, int denom);
67 ldiv_t div( long numer, long denom);
68 lldiv_t div(long long numer, long long denom); // C++0X
69 ldiv_t ldiv( long numer, long denom);
70 lldiv_t lldiv(long long numer, long long denom); // C99
71 int mblen(const char* s, size_t n);
72 int mbtowc(wchar_t* restrict pwc, const char* restrict s, size_t n);
73 int wctomb(char* s, wchar_t wchar);
74 size_t mbstowcs(wchar_t* restrict pwcs, const char* restrict s, size_t n);
75 size_t wcstombs(char* restrict s, const wchar_t* restrict pwcs, size_t n);
76 int at_quick_exit(void (*func)(void)) // C++11
77 void quick_exit(int status); // C++11
78 void *aligned_alloc(size_t alignment, size_t size); // C11
85 #include <__cstddef/size_t.h>
89 #ifndef _LIBCPP_STDLIB_H
90 # error <cstdlib> tried including <stdlib.h> but didn't find libc++'s <stdlib.h> header. \
91 This usually means that your header search paths are not configured properly. \
92 The header search paths should contain the C++ Standard Library headers before \
93 any C Standard Library, and you are probably using compiler flags that make that \
97 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
98 # pragma GCC system_header
101 _LIBCPP_BEGIN_NAMESPACE_STD
103 using ::div_t _LIBCPP_USING_IF_EXISTS;
104 using ::ldiv_t _LIBCPP_USING_IF_EXISTS;
105 using ::lldiv_t _LIBCPP_USING_IF_EXISTS;
106 using ::atof _LIBCPP_USING_IF_EXISTS;
107 using ::atoi _LIBCPP_USING_IF_EXISTS;
108 using ::atol _LIBCPP_USING_IF_EXISTS;
109 using ::atoll _LIBCPP_USING_IF_EXISTS;
110 using ::strtod _LIBCPP_USING_IF_EXISTS;
111 using ::strtof _LIBCPP_USING_IF_EXISTS;
112 using ::strtold _LIBCPP_USING_IF_EXISTS;
113 using ::strtol _LIBCPP_USING_IF_EXISTS;
114 using ::strtoll _LIBCPP_USING_IF_EXISTS;
115 using ::strtoul _LIBCPP_USING_IF_EXISTS;
116 using ::strtoull _LIBCPP_USING_IF_EXISTS;
117 using ::rand _LIBCPP_USING_IF_EXISTS;
118 using ::srand _LIBCPP_USING_IF_EXISTS;
119 using ::calloc _LIBCPP_USING_IF_EXISTS;
120 using ::free _LIBCPP_USING_IF_EXISTS;
121 using ::malloc _LIBCPP_USING_IF_EXISTS;
122 using ::realloc _LIBCPP_USING_IF_EXISTS;
123 using ::abort _LIBCPP_USING_IF_EXISTS;
124 using ::atexit _LIBCPP_USING_IF_EXISTS;
125 using ::exit _LIBCPP_USING_IF_EXISTS;
126 using ::_Exit _LIBCPP_USING_IF_EXISTS;
127 using ::getenv _LIBCPP_USING_IF_EXISTS;
128 using ::system _LIBCPP_USING_IF_EXISTS;
129 using ::bsearch _LIBCPP_USING_IF_EXISTS;
130 using ::qsort _LIBCPP_USING_IF_EXISTS;
131 using ::abs _LIBCPP_USING_IF_EXISTS;
132 using ::labs _LIBCPP_USING_IF_EXISTS;
133 using ::llabs _LIBCPP_USING_IF_EXISTS;
134 using ::div _LIBCPP_USING_IF_EXISTS;
135 using ::ldiv _LIBCPP_USING_IF_EXISTS;
136 using ::lldiv _LIBCPP_USING_IF_EXISTS;
137 using ::mblen _LIBCPP_USING_IF_EXISTS;
138 #if _LIBCPP_HAS_WIDE_CHARACTERS
139 using ::mbtowc _LIBCPP_USING_IF_EXISTS;
140 using ::wctomb _LIBCPP_USING_IF_EXISTS;
141 using ::mbstowcs _LIBCPP_USING_IF_EXISTS;
142 using ::wcstombs _LIBCPP_USING_IF_EXISTS;
144 #if !defined(_LIBCPP_CXX03_LANG)
145 using ::at_quick_exit _LIBCPP_USING_IF_EXISTS;
146 using ::quick_exit _LIBCPP_USING_IF_EXISTS;
148 #if _LIBCPP_STD_VER >= 17
149 using ::aligned_alloc _LIBCPP_USING_IF_EXISTS;
152 _LIBCPP_END_NAMESPACE_STD
154 #endif // _LIBCPP_CSTDLIB