Import of virgin gcc 4.0.0 distribution.
[dragonfly.git] / contrib / gcc-4.0 / libstdc++-v3 / include / c_std / std_cstdlib.h
1 // -*- C++ -*- forwarding header.
2
3 // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
4 // Free Software Foundation, Inc.
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
9 // Free Software Foundation; either version 2, or (at your option)
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
17 // You should have received a copy of the GNU General Public License along
18 // with this library; see the file COPYING.  If not, write to the Free
19 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
20 // USA.
21
22 // As a special exception, you may use this file as part of a free software
23 // library without restriction.  Specifically, if other files instantiate
24 // templates or use macros or inline functions from this file, or you compile
25 // this file and link it with other files to produce an executable, this
26 // file does not by itself cause the resulting executable to be covered by
27 // the GNU General Public License.  This exception does not however
28 // invalidate any other reasons why the executable file might be covered by
29 // the GNU General Public License.
30
31 //
32 // ISO C++ 14882: 20.4.6  C library
33 //
34
35 /** @file cstdlib
36  *  This is a Standard C++ Library file.  You should @c #include this file
37  *  in your programs, rather than any of the "*.h" implementation files.
38  *
39  *  This is the C++ version of the Standard C Library header @c stdlib.h,
40  *  and its contents are (mostly) the same as that header, but are all
41  *  contained in the namespace @c std.
42  */
43
44 #ifndef _GLIBCXX_CSTDLIB
45 #define _GLIBCXX_CSTDLIB 1
46
47 #pragma GCC system_header
48
49 #include <bits/c++config.h>
50 #include <cstddef>
51
52 #if _GLIBCXX_HOSTED
53 /* The C standard does not require a freestanding implementation to
54    provide <stdlib.h>.  However, the C++ standard does still require
55    <cstdlib> -- but only the functionality mentioned in
56    [lib.support.start.term].  */
57 #include <stdlib.h>
58 #endif
59
60 // Get rid of those macros defined in <stdlib.h> in lieu of real functions.
61 #undef abort
62 #undef abs
63 #undef atexit
64 #undef atof
65 #undef atoi
66 #undef atol
67 #undef bsearch
68 #undef calloc
69 #undef div
70 #undef exit
71 #undef free
72 #undef getenv
73 #undef labs
74 #undef ldiv
75 #undef malloc
76 #undef mblen
77 #undef mbstowcs
78 #undef mbtowc
79 #undef qsort
80 #undef rand
81 #undef realloc
82 #undef srand
83 #undef strtod
84 #undef strtol
85 #undef strtoul
86 #undef system
87 #undef wcstombs
88 #undef wctomb
89
90 namespace std
91 {
92 #if _GLIBCXX_HOSTED
93   using ::div_t;
94   using ::ldiv_t;
95
96   using ::abort;
97   using ::abs;
98   using ::atexit;
99   using ::atof;
100   using ::atoi;
101   using ::atol;
102   using ::bsearch;
103   using ::calloc;
104   using ::div;
105   using ::exit;
106   using ::free;
107   using ::getenv;
108   using ::labs;
109   using ::ldiv;
110   using ::malloc;
111 #ifdef _GLIBCXX_HAVE_MBSTATE_T
112   using ::mblen;
113   using ::mbstowcs;
114   using ::mbtowc;
115 #endif // _GLIBCXX_HAVE_MBSTATE_T
116   using ::qsort;
117   using ::rand;
118   using ::realloc;
119   using ::srand;
120   using ::strtod;
121   using ::strtol;
122   using ::strtoul;
123   using ::system;
124 #ifdef _GLIBCXX_USE_WCHAR_T
125   using ::wcstombs;
126   using ::wctomb;
127 #endif // _GLIBCXX_USE_WCHAR_T
128
129   inline long
130   abs(long __i) { return labs(__i); }
131
132   inline ldiv_t
133   div(long __i, long __j) { return ldiv(__i, __j); }
134 #else
135   /* Provide the minimal set of definitions required of a freestanding
136      implementation.  */
137   #define EXIT_SUCCESS 0
138   #define EXIT_FAILURE 1
139   extern "C" void abort(void);
140   extern "C" int atexit(void (*)());
141   extern "C" void exit(int);
142 #endif
143 }
144
145 #if _GLIBCXX_USE_C99
146
147 #undef _Exit
148 #undef llabs
149 #undef lldiv
150 #undef atoll
151 #undef strtoll
152 #undef strtoull
153 #undef strtof
154 #undef strtold
155
156 namespace __gnu_cxx
157 {
158 #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
159   using ::lldiv_t;
160 #endif
161 #if _GLIBCXX_USE_C99_CHECK || _GLIBCXX_USE_C99_DYNAMIC
162   extern "C" void (_Exit)(int);
163 #endif
164 #if !_GLIBCXX_USE_C99_DYNAMIC
165   using ::_Exit;
166 #endif
167
168   inline long long
169   abs(long long __x) { return __x >= 0 ? __x : -__x; }
170
171   inline long long
172   llabs(long long __x) { return __x >= 0 ? __x : -__x; }
173
174 #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
175   inline lldiv_t
176   div(long long __n, long long __d)
177   { lldiv_t __q; __q.quot = __n / __d; __q.rem = __n % __d; return __q; }
178
179   inline lldiv_t
180   lldiv(long long __n, long long __d)
181   { lldiv_t __q; __q.quot = __n / __d; __q.rem = __n % __d; return __q; }
182 #endif
183
184 #if _GLIBCXX_USE_C99_LONG_LONG_CHECK || _GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
185   extern "C" long long int (atoll)(const char *);
186   extern "C" long long int
187     (strtoll)(const char * restrict, char ** restrict, int);
188   extern "C" unsigned long long int
189     (strtoull)(const char * restrict, char ** restrict, int);
190 #endif
191 #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
192   using ::atoll;
193   using ::strtoll;
194   using ::strtoull;
195 #endif
196   using ::strtof;
197   using ::strtold;
198 }
199
200 namespace std
201 {
202 #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
203   using __gnu_cxx::lldiv_t;
204 #endif
205   using __gnu_cxx::_Exit;
206   using __gnu_cxx::abs;
207   using __gnu_cxx::llabs;
208 #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
209   using __gnu_cxx::div;
210   using __gnu_cxx::lldiv;
211 #endif
212   using __gnu_cxx::atoll;
213   using __gnu_cxx::strtof;
214   using __gnu_cxx::strtoll;
215   using __gnu_cxx::strtoull;
216   using __gnu_cxx::strtold;
217 }
218 #endif
219
220 #endif