1 // -*- C++ -*- forwarding header.
3 // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
4 // 2006, 2007, 2008, 2009, 2010
5 // Free Software Foundation, Inc.
7 // This file is part of the GNU ISO C++ Library. This library is free
8 // software; you can redistribute it and/or modify it under the
9 // terms of the GNU General Public License as published by the
10 // Free Software Foundation; either version 3, or (at your option)
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // Under Section 7 of GPL version 3, you are granted additional
19 // permissions described in the GCC Runtime Library Exception, version
20 // 3.1, as published by the Free Software Foundation.
22 // You should have received a copy of the GNU General Public License and
23 // a copy of the GCC Runtime Library Exception along with this program;
24 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
25 // <http://www.gnu.org/licenses/>.
27 /** @file include/cstdlib
28 * This is a Standard C++ Library file. You should @c \#include this file
29 * in your programs, rather than any of the @a *.h implementation files.
31 * This is the C++ version of the Standard C Library header @c stdlib.h,
32 * and its contents are (mostly) the same as that header, but are all
33 * contained in the namespace @c std (except for names which are defined
38 // ISO C++ 14882: 20.4.6 C library
41 #pragma GCC system_header
43 #include <bits/c++config.h>
46 #ifndef _GLIBCXX_CSTDLIB
47 #define _GLIBCXX_CSTDLIB 1
50 // The C standard does not require a freestanding implementation to
51 // provide <stdlib.h>. However, the C++ standard does still require
52 // <cstdlib> -- but only the functionality mentioned in
53 // [lib.support.start.term].
55 #define EXIT_SUCCESS 0
56 #define EXIT_FAILURE 1
58 _GLIBCXX_BEGIN_NAMESPACE(std)
60 extern "C" void abort(void) throw () _GLIBC_NORETURN;
61 extern "C" int atexit(void (*)()) throw ();
62 extern "C" void exit(int) throw () _GLIBC_NORETURN;
64 _GLIBCXX_END_NAMESPACE
70 // Get rid of those macros defined in <stdlib.h> in lieu of real functions.
100 _GLIBCXX_BEGIN_NAMESPACE(std)
120 #ifdef _GLIBCXX_HAVE_MBSTATE_T
124 #endif // _GLIBCXX_HAVE_MBSTATE_T
133 #ifdef _GLIBCXX_USE_WCHAR_T
136 #endif // _GLIBCXX_USE_WCHAR_T
139 abs(long __i) { return labs(__i); }
142 div(long __i, long __j) { return ldiv(__i, __j); }
144 _GLIBCXX_END_NAMESPACE
157 _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
159 #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
162 #if _GLIBCXX_USE_C99_CHECK || _GLIBCXX_USE_C99_DYNAMIC
163 extern "C" void (_Exit)(int) throw () _GLIBCXX_NORETURN;
165 #if !_GLIBCXX_USE_C99_DYNAMIC
170 abs(long long __x) { return __x >= 0 ? __x : -__x; }
172 #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
176 div(long long __n, long long __d)
177 { lldiv_t __q; __q.quot = __n / __d; __q.rem = __n % __d; return __q; }
182 #if _GLIBCXX_USE_C99_LONG_LONG_CHECK || _GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
183 extern "C" long long int (atoll)(const char *) throw ();
184 extern "C" long long int
185 (strtoll)(const char * restrict, char ** restrict, int) throw ();
186 extern "C" unsigned long long int
187 (strtoull)(const char * restrict, char ** restrict, int) throw ();
189 #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
197 _GLIBCXX_END_NAMESPACE
199 _GLIBCXX_BEGIN_NAMESPACE(std)
201 #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
202 using ::__gnu_cxx::lldiv_t;
204 using ::__gnu_cxx::_Exit;
205 using ::__gnu_cxx::abs;
206 #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
207 using ::__gnu_cxx::llabs;
208 using ::__gnu_cxx::div;
209 using ::__gnu_cxx::lldiv;
211 using ::__gnu_cxx::atoll;
212 using ::__gnu_cxx::strtof;
213 using ::__gnu_cxx::strtoll;
214 using ::__gnu_cxx::strtoull;
215 using ::__gnu_cxx::strtold;
217 _GLIBCXX_END_NAMESPACE
219 #endif // _GLIBCXX_USE_C99
221 #ifdef __GXX_EXPERIMENTAL_CXX0X__
222 # if defined(_GLIBCXX_INCLUDE_AS_TR1)
223 # error C++0x header cannot be included from TR1 header
225 # if defined(_GLIBCXX_INCLUDE_AS_CXX0X)
226 # include <tr1_impl/cstdlib>
228 # define _GLIBCXX_INCLUDE_AS_CXX0X
229 # define _GLIBCXX_BEGIN_NAMESPACE_TR1
230 # define _GLIBCXX_END_NAMESPACE_TR1
231 # define _GLIBCXX_TR1
232 # include <tr1_impl/cstdlib>
234 # undef _GLIBCXX_END_NAMESPACE_TR1
235 # undef _GLIBCXX_BEGIN_NAMESPACE_TR1
236 # undef _GLIBCXX_INCLUDE_AS_CXX0X
240 #endif // !_GLIBCXX_HOSTED