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