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