# cstdlib

Go to the documentation of this file.

    00001 // -*- C++ -*- forwarding header.
    00002
    00003 // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
    00004 // Free Software Foundation, Inc.
    00005 //
    00006 // This file is part of the GNU ISO C++ Library.  This library is free
    00007 // software; you can redistribute it and/or modify it under the
    00008 // terms of the GNU General Public License as published by the
    00009 // Free Software Foundation; either version 2, or (at your option)
    00010 // any later version.
    00011
    00012 // This library is distributed in the hope that it will be useful,
    00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
    00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00015 // GNU General Public License for more details.
    00016
    00017 // You should have received a copy of the GNU General Public License along
    00018 // with this library; see the file COPYING.  If not, write to the Free
    00019 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
    00020 // USA.
    00021
    00022 // As a special exception, you may use this file as part of a free software
    00023 // library without restriction.  Specifically, if other files instantiate
    00024 // templates or use macros or inline functions from this file, or you compile
    00025 // this file and link it with other files to produce an executable, this
    00026 // file does not by itself cause the resulting executable to be covered by
    00027 // the GNU General Public License.  This exception does not however
    00028 // invalidate any other reasons why the executable file might be covered by
    00029 // the GNU General Public License.
    00030
    00031 //
    00032 // ISO C++ 14882: 20.4.6  C library
    00033 //
    00034
    00035 /** @file cstdlib
    00036  *  This is a Standard C++ Library file.  You should @c #include this file
    00037  *  in your programs, rather than any of the "*.h" implementation files.
    00038  *
    00039  *  This is the C++ version of the Standard C Library header @c stdlib.h,
    00040  *  and its contents are (mostly) the same as that header, but are all
    00041  *  contained in the namespace @c std.
    00042  */
    00043
    00044 #ifndef _GLIBCXX_CSTDLIB
    00045 #define _GLIBCXX_CSTDLIB 1
    00046
    00047 #pragma GCC system_header
    00048
    00049 #include <bits/c++config.h>
    00050 #include <cstddef>
    00051
    00052 #include <stdlib.h>
    00053
    00054 // Get rid of those macros defined in <stdlib.h> in lieu of real functions.
    00055 #undef abort
    00056 #undef abs
    00057 #undef atexit
    00058 #undef atof
    00059 #undef atoi
    00060 #undef atol
    00061 #undef bsearch
    00062 #undef calloc
    00063 #undef div
    00064 #undef exit
    00065 #undef free
    00066 #undef getenv
    00067 #undef labs
    00068 #undef ldiv
    00069 #undef malloc
    00070 #undef mblen
    00071 #undef mbstowcs
    00072 #undef mbtowc
    00073 #undef qsort
    00074 #undef rand
    00075 #undef realloc
    00076 #undef srand
    00077 #undef strtod
    00078 #undef strtol
    00079 #undef strtoul
    00080 #undef system
    00081 #undef wcstombs
    00082 #undef wctomb
    00083
    00084 namespace std
    00085 {
    00086   using ::div_t;
    00087   using ::ldiv_t;
    00088
    00089   using ::abort;
    00090   using ::abs;
    00091   using ::atexit;
    00092   using ::atof;
    00093   using ::atoi;
    00094   using ::atol;
    00095   using ::bsearch;
    00096   using ::calloc;
    00097   using ::div;
    00098   using ::exit;
    00099   using ::free;
    00100   using ::getenv;
    00101   using ::labs;
    00102   using ::ldiv;
    00103   using ::malloc;
    00104 #ifdef _GLIBCXX_HAVE_MBSTATE_T
    00105   using ::mblen;
    00106   using ::mbstowcs;
    00107   using ::mbtowc;
    00108 #endif // _GLIBCXX_HAVE_MBSTATE_T
    00109   using ::qsort;
    00110   using ::rand;
    00111   using ::realloc;
    00112   using ::srand;
    00113   using ::strtod;
    00114   using ::strtol;
    00115   using ::strtoul;
    00116   using ::system;
    00117 #ifdef _GLIBCXX_USE_WCHAR_T
    00118   using ::wcstombs;
    00119   using ::wctomb;
    00120 #endif // _GLIBCXX_USE_WCHAR_T
    00121
    00122   inline long
    00123   abs(long __i) { return labs(__i); }
    00124
    00125   inline ldiv_t
    00126   div(long __i, long __j) { return ldiv(__i, __j); }
    00127 }
    00128
    00129 #if _GLIBCXX_USE_C99
    00130
    00131 #undef _Exit
    00132 #undef llabs
    00133 #undef lldiv
    00134 #undef atoll
    00135 #undef strtoll
    00136 #undef strtoull
    00137 #undef strtof
    00138 #undef strtold
    00139
    00140 namespace __gnu_cxx
    00141 {
    00142 #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
    00143   using ::lldiv_t;
    00144 #endif
    00145 #if _GLIBCXX_USE_C99_CHECK || _GLIBCXX_USE_C99_DYNAMIC
    00146   extern "C" void (_Exit)(int);
    00147 #endif
    00148 #if !_GLIBCXX_USE_C99_DYNAMIC
    00149   using ::_Exit;
    00150 #endif
    00151
    00152   inline long long
    00153   abs(long long __x) { return __x >= 0 ? __x : -__x; }
    00154
    00155   inline long long
    00156   llabs(long long __x) { return __x >= 0 ? __x : -__x; }
    00157
    00158 #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
    00159   inline lldiv_t
    00160   div(long long __n, long long __d)
    00161   { lldiv_t __q; __q.quot = __n / __d; __q.rem = __n % __d; return __q; }
    00162
    00163   inline lldiv_t
    00164   lldiv(long long __n, long long __d)
    00165   { lldiv_t __q; __q.quot = __n / __d; __q.rem = __n % __d; return __q; }
    00166 #endif
    00167
    00168 #if _GLIBCXX_USE_C99_LONG_LONG_CHECK || _GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
    00169   extern "C" long long int (atoll)(const char *);
    00170   extern "C" long long int
    00171     (strtoll)(const char * restrict, char ** restrict, int);
    00172   extern "C" unsigned long long int
    00173     (strtoull)(const char * restrict, char ** restrict, int);
    00174 #endif
    00175 #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
    00176   using ::atoll;
    00177   using ::strtoll;
    00178   using ::strtoull;
    00179 #endif
    00180   using ::strtof;
    00181   using ::strtold;
    00182 }
    00183
    00184 namespace std
    00185 {
    00186 #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
    00187   using __gnu_cxx::lldiv_t;
    00188 #endif
    00189   using __gnu_cxx::_Exit;
    00190   using __gnu_cxx::abs;
    00191   using __gnu_cxx::llabs;
    00192 #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
    00193   using __gnu_cxx::div;
    00194   using __gnu_cxx::lldiv;
    00195 #endif
    00196   using __gnu_cxx::atoll;
    00197   using __gnu_cxx::strtof;
    00198   using __gnu_cxx::strtoll;
    00199   using __gnu_cxx::strtoull;
    00200   using __gnu_cxx::strtold;
    00201 }
    00202 #endif
    00203
    00204 #endif