std_cstdlib.h revision 132720
197403Sobrien// -*- C++ -*- forwarding header.
297403Sobrien
3117397Skan// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
497403Sobrien// Free Software Foundation, Inc.
597403Sobrien//
697403Sobrien// This file is part of the GNU ISO C++ Library.  This library is free
797403Sobrien// software; you can redistribute it and/or modify it under the
897403Sobrien// terms of the GNU General Public License as published by the
997403Sobrien// Free Software Foundation; either version 2, or (at your option)
1097403Sobrien// any later version.
1197403Sobrien
1297403Sobrien// This library is distributed in the hope that it will be useful,
1397403Sobrien// but WITHOUT ANY WARRANTY; without even the implied warranty of
1497403Sobrien// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1597403Sobrien// GNU General Public License for more details.
1697403Sobrien
1797403Sobrien// You should have received a copy of the GNU General Public License along
1897403Sobrien// with this library; see the file COPYING.  If not, write to the Free
1997403Sobrien// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
2097403Sobrien// USA.
2197403Sobrien
2297403Sobrien// As a special exception, you may use this file as part of a free software
2397403Sobrien// library without restriction.  Specifically, if other files instantiate
2497403Sobrien// templates or use macros or inline functions from this file, or you compile
2597403Sobrien// this file and link it with other files to produce an executable, this
2697403Sobrien// file does not by itself cause the resulting executable to be covered by
2797403Sobrien// the GNU General Public License.  This exception does not however
2897403Sobrien// invalidate any other reasons why the executable file might be covered by
2997403Sobrien// the GNU General Public License.
3097403Sobrien
3197403Sobrien//
3297403Sobrien// ISO C++ 14882: 20.4.6  C library
3397403Sobrien//
3497403Sobrien
3597403Sobrien/** @file cstdlib
3697403Sobrien *  This is a Standard C++ Library file.  You should @c #include this file
3797403Sobrien *  in your programs, rather than any of the "*.h" implementation files.
3897403Sobrien *
3997403Sobrien *  This is the C++ version of the Standard C Library header @c stdlib.h,
4097403Sobrien *  and its contents are (mostly) the same as that header, but are all
4197403Sobrien *  contained in the namespace @c std.
4297403Sobrien */
4397403Sobrien
44132720Skan#ifndef _GLIBCXX_CSTDLIB
45132720Skan#define _GLIBCXX_CSTDLIB 1
4697403Sobrien
4797403Sobrien#pragma GCC system_header
4897403Sobrien
4997403Sobrien#include <bits/c++config.h>
5097403Sobrien#include <cstddef>
5197403Sobrien
5297403Sobrien#include <stdlib.h>
5397403Sobrien
5497403Sobrien// Get rid of those macros defined in <stdlib.h> in lieu of real functions.
5597403Sobrien#undef abort
5697403Sobrien#undef abs
5797403Sobrien#undef atexit
5897403Sobrien#undef atof
5997403Sobrien#undef atoi
6097403Sobrien#undef atol
6197403Sobrien#undef bsearch
6297403Sobrien#undef calloc
6397403Sobrien#undef div
6497403Sobrien#undef exit
6597403Sobrien#undef free
6697403Sobrien#undef getenv
6797403Sobrien#undef labs
6897403Sobrien#undef ldiv
6997403Sobrien#undef malloc
7097403Sobrien#undef mblen
7197403Sobrien#undef mbstowcs
7297403Sobrien#undef mbtowc
7397403Sobrien#undef qsort
7497403Sobrien#undef rand
7597403Sobrien#undef realloc
7697403Sobrien#undef srand
7797403Sobrien#undef strtod
7897403Sobrien#undef strtol
7997403Sobrien#undef strtoul
8097403Sobrien#undef system
8197403Sobrien#undef wcstombs
8297403Sobrien#undef wctomb
8397403Sobrien
84132720Skannamespace std
8597403Sobrien{
8697403Sobrien  using ::div_t;
8797403Sobrien  using ::ldiv_t;
8897403Sobrien
8997403Sobrien  using ::abort;
9097403Sobrien  using ::abs;
9197403Sobrien  using ::atexit;
9297403Sobrien  using ::atof;
9397403Sobrien  using ::atoi;
9497403Sobrien  using ::atol;
9597403Sobrien  using ::bsearch;
9697403Sobrien  using ::calloc;
9797403Sobrien  using ::div;
9897403Sobrien  using ::exit;
9997403Sobrien  using ::free;
10097403Sobrien  using ::getenv;
10197403Sobrien  using ::labs;
10297403Sobrien  using ::ldiv;
10397403Sobrien  using ::malloc;
104132720Skan#ifdef _GLIBCXX_HAVE_MBSTATE_T
10597403Sobrien  using ::mblen;
10697403Sobrien  using ::mbstowcs;
10797403Sobrien  using ::mbtowc;
108132720Skan#endif // _GLIBCXX_HAVE_MBSTATE_T
10997403Sobrien  using ::qsort;
11097403Sobrien  using ::rand;
11197403Sobrien  using ::realloc;
11297403Sobrien  using ::srand;
11397403Sobrien  using ::strtod;
11497403Sobrien  using ::strtol;
11597403Sobrien  using ::strtoul;
11697403Sobrien  using ::system;
117132720Skan#ifdef _GLIBCXX_USE_WCHAR_T
11897403Sobrien  using ::wcstombs;
11997403Sobrien  using ::wctomb;
120132720Skan#endif // _GLIBCXX_USE_WCHAR_T
12197403Sobrien
122132720Skan  inline long
12397403Sobrien  abs(long __i) { return labs(__i); }
12497403Sobrien
12597403Sobrien  inline ldiv_t
12697403Sobrien  div(long __i, long __j) { return ldiv(__i, __j); }
127132720Skan}
12897403Sobrien
129132720Skan#if _GLIBCXX_USE_C99
13097403Sobrien
13197403Sobrien#undef _Exit
13297403Sobrien#undef llabs
13397403Sobrien#undef lldiv
13497403Sobrien#undef atoll
13597403Sobrien#undef strtoll
13697403Sobrien#undef strtoull
13797403Sobrien#undef strtof
13897403Sobrien#undef strtold
13997403Sobrien
14097403Sobriennamespace __gnu_cxx
14197403Sobrien{
142132720Skan#if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
14397403Sobrien  using ::lldiv_t;
144117397Skan#endif
145132720Skan#if _GLIBCXX_USE_C99_CHECK || _GLIBCXX_USE_C99_DYNAMIC
146117397Skan  extern "C" void (_Exit)(int);
147117397Skan#endif
148132720Skan#if !_GLIBCXX_USE_C99_DYNAMIC
14997403Sobrien  using ::_Exit;
150117397Skan#endif
15197403Sobrien
152132720Skan  inline long long
15397403Sobrien  abs(long long __x) { return __x >= 0 ? __x : -__x; }
15497403Sobrien
155132720Skan  inline long long
15697403Sobrien  llabs(long long __x) { return __x >= 0 ? __x : -__x; }
15797403Sobrien
158132720Skan#if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
159132720Skan  inline lldiv_t
16097403Sobrien  div(long long __n, long long __d)
16197403Sobrien  { lldiv_t __q; __q.quot = __n / __d; __q.rem = __n % __d; return __q; }
16297403Sobrien
163132720Skan  inline lldiv_t
16497403Sobrien  lldiv(long long __n, long long __d)
16597403Sobrien  { lldiv_t __q; __q.quot = __n / __d; __q.rem = __n % __d; return __q; }
166117397Skan#endif
16797403Sobrien
168132720Skan#if _GLIBCXX_USE_C99_LONG_LONG_CHECK || _GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
169117397Skan  extern "C" long long int (atoll)(const char *);
170117397Skan  extern "C" long long int
171117397Skan    (strtoll)(const char * restrict, char ** restrict, int);
172117397Skan  extern "C" unsigned long long int
173117397Skan    (strtoull)(const char * restrict, char ** restrict, int);
174117397Skan#endif
175132720Skan#if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
17697403Sobrien  using ::atoll;
17797403Sobrien  using ::strtoll;
17897403Sobrien  using ::strtoull;
179117397Skan#endif
180117397Skan  using ::strtof;
181132720Skan  using ::strtold;
182132720Skan}
18397403Sobrien
18497403Sobriennamespace std
18597403Sobrien{
186132720Skan#if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
18797403Sobrien  using __gnu_cxx::lldiv_t;
188117397Skan#endif
18997403Sobrien  using __gnu_cxx::_Exit;
19097403Sobrien  using __gnu_cxx::abs;
191132720Skan  using __gnu_cxx::llabs;
192132720Skan#if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
19397403Sobrien  using __gnu_cxx::div;
19497403Sobrien  using __gnu_cxx::lldiv;
195117397Skan#endif
19697403Sobrien  using __gnu_cxx::atoll;
19797403Sobrien  using __gnu_cxx::strtof;
19897403Sobrien  using __gnu_cxx::strtoll;
19997403Sobrien  using __gnu_cxx::strtoull;
20097403Sobrien  using __gnu_cxx::strtold;
20197403Sobrien}
20297403Sobrien#endif
20397403Sobrien
204132720Skan#endif
205