]>
Commit | Line | Data |
---|---|---|
98e6e789 | 1 | // -*- C++ -*- forwarding header. |
22aef514 | 2 | |
748086b7 | 3 | // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, |
2a60a9f6 | 4 | // 2009, 2010 Free Software Foundation, Inc. |
22aef514 BK |
5 | // |
6 | // This file is part of the GNU ISO C++ Library. This library is free | |
7 | // software; you can redistribute it and/or modify it under the | |
8 | // terms of the GNU General Public License as published by the | |
748086b7 | 9 | // Free Software Foundation; either version 3, or (at your option) |
22aef514 BK |
10 | // any later version. |
11 | ||
12 | // This library is distributed in the hope that it will be useful, | |
13 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | // GNU General Public License for more details. | |
16 | ||
748086b7 JJ |
17 | // Under Section 7 of GPL version 3, you are granted additional |
18 | // permissions described in the GCC Runtime Library Exception, version | |
19 | // 3.1, as published by the Free Software Foundation. | |
22aef514 | 20 | |
748086b7 JJ |
21 | // You should have received a copy of the GNU General Public License and |
22 | // a copy of the GCC Runtime Library Exception along with this program; | |
23 | // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see | |
24 | // <http://www.gnu.org/licenses/>. | |
22aef514 | 25 | |
143c27b0 | 26 | /** @file include/cstdlib |
ffe94f83 | 27 | * This is a Standard C++ Library file. You should @c #include this file |
2a60a9f6 | 28 | * in your programs, rather than any of the @a *.h implementation files. |
ffe94f83 PE |
29 | * |
30 | * This is the C++ version of the Standard C Library header @c stdlib.h, | |
31 | * and its contents are (mostly) the same as that header, but are all | |
097588e4 PC |
32 | * contained in the namespace @c std (except for names which are defined |
33 | * as macros in C). | |
ffe94f83 PE |
34 | */ |
35 | ||
143c27b0 BK |
36 | // |
37 | // ISO C++ 14882: 20.4.6 C library | |
38 | // | |
39 | ||
1143680e SE |
40 | #ifndef _GLIBCXX_CSTDLIB |
41 | #define _GLIBCXX_CSTDLIB 1 | |
34ff0b99 BK |
42 | |
43 | #pragma GCC system_header | |
22aef514 | 44 | |
98e6e789 | 45 | #include <bits/c++config.h> |
22aef514 | 46 | |
6fbcd2e5 BK |
47 | #if !_GLIBCXX_HOSTED |
48 | // The C standard does not require a freestanding implementation to | |
49 | // provide <stdlib.h>. However, the C++ standard does still require | |
50 | // <cstdlib> -- but only the functionality mentioned in | |
51 | // [lib.support.start.term]. | |
52 | ||
53 | #define EXIT_SUCCESS 0 | |
54 | #define EXIT_FAILURE 1 | |
55 | ||
12ffa228 BK |
56 | namespace std |
57 | { | |
1cae1c5f JH |
58 | extern "C" void abort(void) throw () _GLIBCXX_NORETURN; |
59 | extern "C" int atexit(void (*)()) throw (); | |
60 | extern "C" void exit(int) throw () _GLIBCXX_NORETURN; | |
12ffa228 | 61 | } // namespace |
6fbcd2e5 BK |
62 | |
63 | #else | |
64 | ||
c0dae541 | 65 | #include <stdlib.h> |
22aef514 | 66 | |
8089616e | 67 | // Get rid of those macros defined in <stdlib.h> in lieu of real functions. |
61c71946 BK |
68 | #undef abort |
69 | #undef abs | |
70 | #undef atexit | |
8089616e BK |
71 | #undef atof |
72 | #undef atoi | |
73 | #undef atol | |
61c71946 | 74 | #undef bsearch |
8089616e | 75 | #undef calloc |
61c71946 | 76 | #undef div |
8089616e | 77 | #undef exit |
61c71946 | 78 | #undef free |
8089616e | 79 | #undef getenv |
8089616e | 80 | #undef labs |
8089616e | 81 | #undef ldiv |
61c71946 | 82 | #undef malloc |
7b331228 | 83 | #undef mblen |
8089616e | 84 | #undef mbstowcs |
61c71946 BK |
85 | #undef mbtowc |
86 | #undef qsort | |
87 | #undef rand | |
88 | #undef realloc | |
89 | #undef srand | |
90 | #undef strtod | |
91 | #undef strtol | |
92 | #undef strtoul | |
93 | #undef system | |
8089616e | 94 | #undef wcstombs |
61c71946 | 95 | #undef wctomb |
7b331228 | 96 | |
12ffa228 BK |
97 | namespace std _GLIBCXX_VISIBILITY(default) |
98 | { | |
99 | _GLIBCXX_BEGIN_NAMESPACE_VERSION | |
3cbc7af0 | 100 | |
98e6e789 BK |
101 | using ::div_t; |
102 | using ::ldiv_t; | |
22aef514 | 103 | |
61c71946 BK |
104 | using ::abort; |
105 | using ::abs; | |
106 | using ::atexit; | |
de96ac46 BK |
107 | using ::atof; |
108 | using ::atoi; | |
109 | using ::atol; | |
61c71946 | 110 | using ::bsearch; |
de96ac46 | 111 | using ::calloc; |
61c71946 | 112 | using ::div; |
de96ac46 | 113 | using ::exit; |
61c71946 | 114 | using ::free; |
de96ac46 | 115 | using ::getenv; |
de96ac46 | 116 | using ::labs; |
de96ac46 | 117 | using ::ldiv; |
61c71946 | 118 | using ::malloc; |
e7f115de | 119 | #ifdef _GLIBCXX_HAVE_MBSTATE_T |
de96ac46 | 120 | using ::mblen; |
de96ac46 | 121 | using ::mbstowcs; |
61c71946 | 122 | using ::mbtowc; |
e7f115de | 123 | #endif // _GLIBCXX_HAVE_MBSTATE_T |
61c71946 BK |
124 | using ::qsort; |
125 | using ::rand; | |
126 | using ::realloc; | |
127 | using ::srand; | |
128 | using ::strtod; | |
129 | using ::strtol; | |
130 | using ::strtoul; | |
131 | using ::system; | |
e7f115de | 132 | #ifdef _GLIBCXX_USE_WCHAR_T |
de96ac46 | 133 | using ::wcstombs; |
61c71946 | 134 | using ::wctomb; |
7dd8177f | 135 | #endif // _GLIBCXX_USE_WCHAR_T |
22aef514 | 136 | |
7dd8177f | 137 | inline long |
de96ac46 | 138 | abs(long __i) { return labs(__i); } |
21aaf8bf SS |
139 | |
140 | inline ldiv_t | |
de96ac46 | 141 | div(long __i, long __j) { return ldiv(__i, __j); } |
3cbc7af0 | 142 | |
12ffa228 BK |
143 | _GLIBCXX_END_NAMESPACE_VERSION |
144 | } // namespace | |
7cda84dc | 145 | |
3d7c150e | 146 | #if _GLIBCXX_USE_C99 |
61c71946 BK |
147 | |
148 | #undef _Exit | |
149 | #undef llabs | |
150 | #undef lldiv | |
151 | #undef atoll | |
152 | #undef strtoll | |
153 | #undef strtoull | |
154 | #undef strtof | |
155 | #undef strtold | |
156 | ||
12ffa228 BK |
157 | namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) |
158 | { | |
159 | _GLIBCXX_BEGIN_NAMESPACE_VERSION | |
3cbc7af0 | 160 | |
3d7c150e | 161 | #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC |
7cda84dc | 162 | using ::lldiv_t; |
9c594837 | 163 | #endif |
3d7c150e | 164 | #if _GLIBCXX_USE_C99_CHECK || _GLIBCXX_USE_C99_DYNAMIC |
1cae1c5f | 165 | extern "C" void (_Exit)(int) throw () _GLIBCXX_NORETURN; |
9c594837 | 166 | #endif |
3d7c150e | 167 | #if !_GLIBCXX_USE_C99_DYNAMIC |
61c71946 | 168 | using ::_Exit; |
9c594837 | 169 | #endif |
21aaf8bf | 170 | |
7dd8177f | 171 | inline long long |
98e6e789 | 172 | abs(long long __x) { return __x >= 0 ? __x : -__x; } |
22aef514 | 173 | |
3d7c150e | 174 | #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC |
10d877a8 PC |
175 | using ::llabs; |
176 | ||
7dd8177f | 177 | inline lldiv_t |
98e6e789 | 178 | div(long long __n, long long __d) |
22aef514 BK |
179 | { lldiv_t __q; __q.quot = __n / __d; __q.rem = __n % __d; return __q; } |
180 | ||
10d877a8 | 181 | using ::lldiv; |
9c594837 | 182 | #endif |
98e6e789 | 183 | |
3d7c150e | 184 | #if _GLIBCXX_USE_C99_LONG_LONG_CHECK || _GLIBCXX_USE_C99_LONG_LONG_DYNAMIC |
1cae1c5f | 185 | extern "C" long long int (atoll)(const char *) throw (); |
9c594837 | 186 | extern "C" long long int |
f2871ffd | 187 | (strtoll)(const char * __restrict, char ** __restrict, int) throw (); |
9c594837 | 188 | extern "C" unsigned long long int |
f2871ffd | 189 | (strtoull)(const char * __restrict, char ** __restrict, int) throw (); |
9c594837 | 190 | #endif |
3d7c150e | 191 | #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC |
de96ac46 BK |
192 | using ::atoll; |
193 | using ::strtoll; | |
194 | using ::strtoull; | |
9c594837 LR |
195 | #endif |
196 | using ::strtof; | |
7dd8177f | 197 | using ::strtold; |
5db6f3de | 198 | |
12ffa228 BK |
199 | _GLIBCXX_END_NAMESPACE_VERSION |
200 | } // namespace __gnu_cxx | |
3cbc7af0 | 201 | |
12ffa228 BK |
202 | namespace std |
203 | { | |
7dd8177f | 204 | #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC |
6fbcd2e5 | 205 | using ::__gnu_cxx::lldiv_t; |
9c594837 | 206 | #endif |
6fbcd2e5 BK |
207 | using ::__gnu_cxx::_Exit; |
208 | using ::__gnu_cxx::abs; | |
7dd8177f | 209 | #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC |
6fbcd2e5 BK |
210 | using ::__gnu_cxx::llabs; |
211 | using ::__gnu_cxx::div; | |
212 | using ::__gnu_cxx::lldiv; | |
9c594837 | 213 | #endif |
6fbcd2e5 BK |
214 | using ::__gnu_cxx::atoll; |
215 | using ::__gnu_cxx::strtof; | |
216 | using ::__gnu_cxx::strtoll; | |
217 | using ::__gnu_cxx::strtoull; | |
218 | using ::__gnu_cxx::strtold; | |
12ffa228 | 219 | } // namespace std |
6fbcd2e5 BK |
220 | |
221 | #endif // _GLIBCXX_USE_C99 | |
222 | ||
223 | #endif // !_GLIBCXX_HOSTED | |
98e6e789 | 224 | |
7dd8177f | 225 | #endif |