1 | // -*- C++ -*- |
2 | //===--------------------------- cstdlib ----------------------------------===// |
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-exception |
7 | // |
8 | //===----------------------------------------------------------------------===// |
9 | |
10 | #ifndef _LIBCPP_CSTDLIB |
11 | #define _LIBCPP_CSTDLIB |
12 | |
13 | /* |
14 | cstdlib synopsis |
15 | |
16 | Macros: |
17 | |
18 | EXIT_FAILURE |
19 | EXIT_SUCCESS |
20 | MB_CUR_MAX |
21 | NULL |
22 | RAND_MAX |
23 | |
24 | namespace std |
25 | { |
26 | |
27 | Types: |
28 | |
29 | size_t |
30 | div_t |
31 | ldiv_t |
32 | lldiv_t // C99 |
33 | |
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 |
45 | int rand(void); |
46 | void srand(unsigned int seed); |
47 | void* calloc(size_t nmemb, size_t size); |
48 | void free(void* ptr); |
49 | void* malloc(size_t size); |
50 | void* realloc(void* ptr, size_t size); |
51 | void abort(void); |
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 *)); |
61 | int abs( int j); |
62 | long abs( long j); |
63 | long long abs(long long j); // C++0X |
64 | long labs( long j); |
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 |
79 | |
80 | } // std |
81 | |
82 | */ |
83 | |
84 | #include <__config> |
85 | #include <stdlib.h> |
86 | |
87 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
88 | #pragma GCC system_header |
89 | #endif |
90 | |
91 | #ifdef __GNUC__ |
92 | #define _LIBCPP_UNREACHABLE() __builtin_unreachable() |
93 | #else |
94 | #define _LIBCPP_UNREACHABLE() _VSTD::abort() |
95 | #endif |
96 | |
97 | _LIBCPP_BEGIN_NAMESPACE_STD |
98 | |
99 | using ::size_t; |
100 | using ::div_t; |
101 | using ::ldiv_t; |
102 | #ifndef _LIBCPP_HAS_NO_LONG_LONG |
103 | using ::lldiv_t; |
104 | #endif // _LIBCPP_HAS_NO_LONG_LONG |
105 | using ::atof; |
106 | using ::atoi; |
107 | using ::atol; |
108 | #ifndef _LIBCPP_HAS_NO_LONG_LONG |
109 | using ::atoll; |
110 | #endif // _LIBCPP_HAS_NO_LONG_LONG |
111 | using ::strtod; |
112 | using ::strtof; |
113 | using ::strtold; |
114 | using ::strtol; |
115 | #ifndef _LIBCPP_HAS_NO_LONG_LONG |
116 | using ::strtoll; |
117 | #endif // _LIBCPP_HAS_NO_LONG_LONG |
118 | using ::strtoul; |
119 | #ifndef _LIBCPP_HAS_NO_LONG_LONG |
120 | using ::strtoull; |
121 | #endif // _LIBCPP_HAS_NO_LONG_LONG |
122 | using ::rand; |
123 | using ::srand; |
124 | using ::calloc; |
125 | using ::free; |
126 | using ::malloc; |
127 | using ::realloc; |
128 | using ::abort; |
129 | using ::atexit; |
130 | using ::exit; |
131 | using ::_Exit; |
132 | #ifndef _LIBCPP_WINDOWS_STORE_APP |
133 | using ::getenv; |
134 | using ::system; |
135 | #endif |
136 | using ::bsearch; |
137 | using ::qsort; |
138 | using ::abs; |
139 | using ::labs; |
140 | #ifndef _LIBCPP_HAS_NO_LONG_LONG |
141 | using ::llabs; |
142 | #endif // _LIBCPP_HAS_NO_LONG_LONG |
143 | using ::div; |
144 | using ::ldiv; |
145 | #ifndef _LIBCPP_HAS_NO_LONG_LONG |
146 | using ::lldiv; |
147 | #endif // _LIBCPP_HAS_NO_LONG_LONG |
148 | using ::mblen; |
149 | using ::mbtowc; |
150 | using ::wctomb; |
151 | using ::mbstowcs; |
152 | using ::wcstombs; |
153 | #if !defined(_LIBCPP_CXX03_LANG) && defined(_LIBCPP_HAS_QUICK_EXIT) |
154 | using ::at_quick_exit; |
155 | using ::quick_exit; |
156 | #endif |
157 | #if _LIBCPP_STD_VER > 14 && defined(_LIBCPP_HAS_ALIGNED_ALLOC) |
158 | using ::aligned_alloc; |
159 | #endif |
160 | |
161 | _LIBCPP_END_NAMESPACE_STD |
162 | |
163 | #endif // _LIBCPP_CSTDLIB |
164 | |