Install gcc-4.4.0-tdm-1-core-2.tar.gz
[msysgit.git] / mingw / lib / gcc / mingw32 / 4.3.3 / include / c++ / cstdlib
blobe03fff61882044aeff60a7caf6857b6f04f75ece
1 // -*- C++ -*- forwarding header.
3 // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
4 // 2006, 2007, 2008
5 // Free Software Foundation, Inc.
6 //
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 2, or (at your option)
11 // any later version.
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 // You should have received a copy of the GNU General Public License
19 // along with this library; see the file COPYING.  If not, write to
20 // the Free Software Foundation, 51 Franklin Street, Fifth Floor,
21 // Boston, MA 02110-1301, USA.
23 // As a special exception, you may use this file as part of a free software
24 // library without restriction.  Specifically, if other files instantiate
25 // templates or use macros or inline functions from this file, or you compile
26 // this file and link it with other files to produce an executable, this
27 // file does not by itself cause the resulting executable to be covered by
28 // the GNU General Public License.  This exception does not however
29 // invalidate any other reasons why the executable file might be covered by
30 // the GNU General Public License.
32 /** @file include/cstdlib
33  *  This is a Standard C++ Library file.  You should @c #include this file
34  *  in your programs, rather than any of the "*.h" implementation files.
35  *
36  *  This is the C++ version of the Standard C Library header @c stdlib.h,
37  *  and its contents are (mostly) the same as that header, but are all
38  *  contained in the namespace @c std (except for names which are defined
39  *  as macros in C).
40  */
43 // ISO C++ 14882: 20.4.6  C library
46 #pragma GCC system_header
48 #include <bits/c++config.h>
49 #include <cstddef>
51 #ifndef _GLIBCXX_CSTDLIB
52 #define _GLIBCXX_CSTDLIB 1
54 #if !_GLIBCXX_HOSTED
55 // The C standard does not require a freestanding implementation to
56 // provide <stdlib.h>.  However, the C++ standard does still require
57 // <cstdlib> -- but only the functionality mentioned in
58 // [lib.support.start.term].
60 #define EXIT_SUCCESS 0
61 #define EXIT_FAILURE 1
63 _GLIBCXX_BEGIN_NAMESPACE(std)
65   extern "C" void abort(void);
66   extern "C" int atexit(void (*)());
67   extern "C" void exit(int);
69 _GLIBCXX_END_NAMESPACE
71 #else
73 #include <stdlib.h>
75 // Get rid of those macros defined in <stdlib.h> in lieu of real functions.
76 #undef abort
77 #undef abs
78 #undef atexit
79 #undef atof
80 #undef atoi
81 #undef atol
82 #undef bsearch
83 #undef calloc
84 #undef div
85 #undef exit
86 #undef free
87 #undef getenv
88 #undef labs
89 #undef ldiv
90 #undef malloc
91 #undef mblen
92 #undef mbstowcs
93 #undef mbtowc
94 #undef qsort
95 #undef rand
96 #undef realloc
97 #undef srand
98 #undef strtod
99 #undef strtol
100 #undef strtoul
101 #undef system
102 #undef wcstombs
103 #undef wctomb
105 _GLIBCXX_BEGIN_NAMESPACE(std)
107   using ::div_t;
108   using ::ldiv_t;
110   using ::abort;
111   using ::abs;
112   using ::atexit;
113   using ::atof;
114   using ::atoi;
115   using ::atol;
116   using ::bsearch;
117   using ::calloc;
118   using ::div;
119   using ::exit;
120   using ::free;
121   using ::getenv;
122   using ::labs;
123   using ::ldiv;
124   using ::malloc;
125 #ifdef _GLIBCXX_HAVE_MBSTATE_T
126   using ::mblen;
127   using ::mbstowcs;
128   using ::mbtowc;
129 #endif // _GLIBCXX_HAVE_MBSTATE_T
130   using ::qsort;
131   using ::rand;
132   using ::realloc;
133   using ::srand;
134   using ::strtod;
135   using ::strtol;
136   using ::strtoul;
137   using ::system;
138 #ifdef _GLIBCXX_USE_WCHAR_T
139   using ::wcstombs;
140   using ::wctomb;
141 #endif // _GLIBCXX_USE_WCHAR_T
143   inline long
144   abs(long __i) { return labs(__i); }
146   inline ldiv_t
147   div(long __i, long __j) { return ldiv(__i, __j); }
149 _GLIBCXX_END_NAMESPACE
151 #if _GLIBCXX_USE_C99
153 #undef _Exit
154 #undef llabs
155 #undef lldiv
156 #undef atoll
157 #undef strtoll
158 #undef strtoull
159 #undef strtof
160 #undef strtold
162 _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
164 #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
165   using ::lldiv_t;
166 #endif
167 #if _GLIBCXX_USE_C99_CHECK || _GLIBCXX_USE_C99_DYNAMIC
168   extern "C" void (_Exit)(int);
169 #endif
170 #if !_GLIBCXX_USE_C99_DYNAMIC
171   using ::_Exit;
172 #endif
174   inline long long
175   abs(long long __x) { return __x >= 0 ? __x : -__x; }
177 #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
178   using ::llabs;
180   inline lldiv_t
181   div(long long __n, long long __d)
182   { lldiv_t __q; __q.quot = __n / __d; __q.rem = __n % __d; return __q; }
184   using ::lldiv;
185 #endif
187 #if _GLIBCXX_USE_C99_LONG_LONG_CHECK || _GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
188   extern "C" long long int (atoll)(const char *);
189   extern "C" long long int
190     (strtoll)(const char * restrict, char ** restrict, int);
191   extern "C" unsigned long long int
192     (strtoull)(const char * restrict, char ** restrict, int);
193 #endif
194 #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
195   using ::atoll;
196   using ::strtoll;
197   using ::strtoull;
198 #endif
199   using ::strtof;
200   using ::strtold;
202 _GLIBCXX_END_NAMESPACE
204 _GLIBCXX_BEGIN_NAMESPACE(std)
206 #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
207   using ::__gnu_cxx::lldiv_t;
208 #endif
209   using ::__gnu_cxx::_Exit;
210   using ::__gnu_cxx::abs;
211 #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
212   using ::__gnu_cxx::llabs;
213   using ::__gnu_cxx::div;
214   using ::__gnu_cxx::lldiv;
215 #endif
216   using ::__gnu_cxx::atoll;
217   using ::__gnu_cxx::strtof;
218   using ::__gnu_cxx::strtoll;
219   using ::__gnu_cxx::strtoull;
220   using ::__gnu_cxx::strtold;
222 _GLIBCXX_END_NAMESPACE
224 #endif // _GLIBCXX_USE_C99
226 #ifdef __GXX_EXPERIMENTAL_CXX0X__
227 #  if defined(_GLIBCXX_INCLUDE_AS_TR1)
228 #    error C++0x header cannot be included from TR1 header
229 #  endif
230 #  if defined(_GLIBCXX_INCLUDE_AS_CXX0X)
231 #    include <tr1_impl/cstdlib>
232 #  else
233 #    define _GLIBCXX_INCLUDE_AS_CXX0X
234 #    define _GLIBCXX_BEGIN_NAMESPACE_TR1
235 #    define _GLIBCXX_END_NAMESPACE_TR1
236 #    define _GLIBCXX_TR1
237 #    include <tr1_impl/cstdlib>
238 #    undef _GLIBCXX_TR1
239 #    undef _GLIBCXX_END_NAMESPACE_TR1
240 #    undef _GLIBCXX_BEGIN_NAMESPACE_TR1
241 #    undef _GLIBCXX_INCLUDE_AS_CXX0X
242 #  endif
243 #endif
245 #endif // !_GLIBCXX_HOSTED
247 #endif