1 // -*- C++ -*- forwarding header.
3 // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
4 // 2009 Free Software Foundation, Inc.
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
9 // Free Software Foundation; either version 3, or (at your option)
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.
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.
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/>.
26 /** @file include/cstdlib
27 * This is a Standard C++ Library file. You should @c #include this file
28 * in your programs, rather than any of the "*.h" implementation files.
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
32 * contained in the namespace @c std (except for names which are defined
37 // ISO C++ 14882: 20.4.6 C library
40 #ifndef _GLIBCXX_CSTDLIB
41 #define _GLIBCXX_CSTDLIB 1
43 #pragma GCC system_header
45 #include <bits/c++config.h>
49 // The C standard does not require a freestanding implementation to
50 // provide <stdlib.h>. However, the C++ standard does still require
51 // <cstdlib> -- but only the functionality mentioned in
52 // [lib.support.start.term].
54 #define EXIT_SUCCESS 0
55 #define EXIT_FAILURE 1
57 _GLIBCXX_BEGIN_NAMESPACE(std)
59 extern "C" void abort(void);
60 extern "C" int atexit(void (*)());
61 extern "C" void exit(int);
63 _GLIBCXX_END_NAMESPACE
69 // Get rid of those macros defined in <stdlib.h> in lieu of real functions.
99 _GLIBCXX_BEGIN_NAMESPACE(std)
119 #ifdef _GLIBCXX_HAVE_MBSTATE_T
123 #endif // _GLIBCXX_HAVE_MBSTATE_T
132 #ifdef _GLIBCXX_USE_WCHAR_T
135 #endif // _GLIBCXX_USE_WCHAR_T
138 abs(long __i) { return labs(__i); }
141 div(long __i, long __j) { return ldiv(__i, __j); }
143 _GLIBCXX_END_NAMESPACE
156 _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
158 #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
161 #if _GLIBCXX_USE_C99_CHECK || _GLIBCXX_USE_C99_DYNAMIC
162 extern "C" void (_Exit)(int);
164 #if !_GLIBCXX_USE_C99_DYNAMIC
169 abs(long long __x) { return __x >= 0 ? __x : -__x; }
171 #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
175 div(long long __n, long long __d)
176 { lldiv_t __q; __q.quot = __n / __d; __q.rem = __n % __d; return __q; }
181 #if _GLIBCXX_USE_C99_LONG_LONG_CHECK || _GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
182 extern "C" long long int (atoll)(const char *);
183 extern "C" long long int
184 (strtoll)(const char * restrict, char ** restrict, int);
185 extern "C" unsigned long long int
186 (strtoull)(const char * restrict, char ** restrict, int);
188 #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
196 _GLIBCXX_END_NAMESPACE
198 _GLIBCXX_BEGIN_NAMESPACE(std)
200 #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
201 using ::__gnu_cxx::lldiv_t;
203 using ::__gnu_cxx::_Exit;
204 using ::__gnu_cxx::abs;
205 #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
206 using ::__gnu_cxx::llabs;
207 using ::__gnu_cxx::div;
208 using ::__gnu_cxx::lldiv;
210 using ::__gnu_cxx::atoll;
211 using ::__gnu_cxx::strtof;
212 using ::__gnu_cxx::strtoll;
213 using ::__gnu_cxx::strtoull;
214 using ::__gnu_cxx::strtold;
216 _GLIBCXX_END_NAMESPACE
218 #endif // _GLIBCXX_USE_C99
220 #endif // !_GLIBCXX_HOSTED