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