cstdlib

Go to the documentation of this file.
00001 // -*- C++ -*- forwarding header.
00002 
00003 // Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
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, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
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 
00045 #ifndef _GLIBCXX_CSTDLIB
00046 #define _GLIBCXX_CSTDLIB 1
00047 
00048 #pragma GCC system_header
00049 
00050 #include <bits/c++config.h>
00051 #include <cstddef>
00052 
00053 #if !_GLIBCXX_HOSTED
00054 // The C standard does not require a freestanding implementation to
00055 // provide <stdlib.h>.  However, the C++ standard does still require
00056 // <cstdlib> -- but only the functionality mentioned in
00057 // [lib.support.start.term].
00058 
00059 #define EXIT_SUCCESS 0
00060 #define EXIT_FAILURE 1
00061 
00062 namespace std
00063 {
00064   extern "C" void abort(void);
00065   extern "C" int atexit(void (*)());
00066   extern "C" void exit(int);
00067 } // namespace std
00068 
00069 #else
00070 
00071 #include <stdlib.h>
00072 
00073 // Get rid of those macros defined in <stdlib.h> in lieu of real functions.
00074 #undef abort
00075 #undef abs
00076 #undef atexit
00077 #undef atof
00078 #undef atoi
00079 #undef atol
00080 #undef bsearch
00081 #undef calloc
00082 #undef div
00083 #undef exit
00084 #undef free
00085 #undef getenv
00086 #undef labs
00087 #undef ldiv
00088 #undef malloc
00089 #undef mblen
00090 #undef mbstowcs
00091 #undef mbtowc
00092 #undef qsort
00093 #undef rand
00094 #undef realloc
00095 #undef srand
00096 #undef strtod
00097 #undef strtol
00098 #undef strtoul
00099 #undef system
00100 #undef wcstombs
00101 #undef wctomb
00102 
00103 namespace std
00104 {
00105   using ::div_t;
00106   using ::ldiv_t;
00107 
00108   using ::abort;
00109   using ::abs;
00110   using ::atexit;
00111   using ::atof;
00112   using ::atoi;
00113   using ::atol;
00114   using ::bsearch;
00115   using ::calloc;
00116   using ::div;
00117   using ::exit;
00118   using ::free;
00119   using ::getenv;
00120   using ::labs;
00121   using ::ldiv;
00122   using ::malloc;
00123 #ifdef _GLIBCXX_HAVE_MBSTATE_T
00124   using ::mblen;
00125   using ::mbstowcs;
00126   using ::mbtowc;
00127 #endif // _GLIBCXX_HAVE_MBSTATE_T
00128   using ::qsort;
00129   using ::rand;
00130   using ::realloc;
00131   using ::srand;
00132   using ::strtod;
00133   using ::strtol;
00134   using ::strtoul;
00135   using ::system;
00136 #ifdef _GLIBCXX_USE_WCHAR_T
00137   using ::wcstombs;
00138   using ::wctomb;
00139 #endif // _GLIBCXX_USE_WCHAR_T
00140 
00141   inline long
00142   abs(long __i) { return labs(__i); }
00143 
00144   inline ldiv_t
00145   div(long __i, long __j) { return ldiv(__i, __j); }
00146 } // namespace std
00147 
00148 #if _GLIBCXX_USE_C99
00149 
00150 #undef _Exit
00151 #undef llabs
00152 #undef lldiv
00153 #undef atoll
00154 #undef strtoll
00155 #undef strtoull
00156 #undef strtof
00157 #undef strtold
00158 
00159 namespace __gnu_cxx
00160 {
00161 #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
00162   using ::lldiv_t;
00163 #endif
00164 #if _GLIBCXX_USE_C99_CHECK || _GLIBCXX_USE_C99_DYNAMIC
00165   extern "C" void (_Exit)(int);
00166 #endif
00167 #if !_GLIBCXX_USE_C99_DYNAMIC
00168   using ::_Exit;
00169 #endif
00170 
00171   inline long long
00172   abs(long long __x) { return __x >= 0 ? __x : -__x; }
00173 
00174 #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
00175   using ::llabs;
00176 
00177   inline lldiv_t
00178   div(long long __n, long long __d)
00179   { lldiv_t __q; __q.quot = __n / __d; __q.rem = __n % __d; return __q; }
00180 
00181   using ::lldiv;
00182 #endif
00183 
00184 #if _GLIBCXX_USE_C99_LONG_LONG_CHECK || _GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
00185   extern "C" long long int (atoll)(const char *);
00186   extern "C" long long int
00187     (strtoll)(const char * restrict, char ** restrict, int);
00188   extern "C" unsigned long long int
00189     (strtoull)(const char * restrict, char ** restrict, int);
00190 #endif
00191 #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
00192   using ::atoll;
00193   using ::strtoll;
00194   using ::strtoull;
00195 #endif
00196   using ::strtof;
00197   using ::strtold;
00198 }
00199 
00200 namespace std
00201 {
00202 #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
00203   using ::__gnu_cxx::lldiv_t;
00204 #endif
00205   using ::__gnu_cxx::_Exit;
00206   using ::__gnu_cxx::abs;
00207 #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
00208   using ::__gnu_cxx::llabs;
00209   using ::__gnu_cxx::div;
00210   using ::__gnu_cxx::lldiv;
00211 #endif
00212   using ::__gnu_cxx::atoll;
00213   using ::__gnu_cxx::strtof;
00214   using ::__gnu_cxx::strtoll;
00215   using ::__gnu_cxx::strtoull;
00216   using ::__gnu_cxx::strtold;
00217 }
00218 
00219 #endif // _GLIBCXX_USE_C99
00220 
00221 #endif // !_GLIBCXX_HOSTED
00222 
00223 #endif

Generated on Tue Feb 2 16:55:52 2010 for GNU C++ STL by  doxygen 1.4.7