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