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 // 2006, 2007, 2008, 2009
00005 // Free Software Foundation, Inc.
00006 //
00007 // This file is part of the GNU ISO C++ Library.  This library is free
00008 // software; you can redistribute it and/or modify it under the
00009 // terms of the GNU General Public License as published by the
00010 // Free Software Foundation; either version 3, or (at your option)
00011 // any later version.
00012 
00013 // This library is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 // GNU General Public License for more details.
00017 
00018 // Under Section 7 of GPL version 3, you are granted additional
00019 // permissions described in the GCC Runtime Library Exception, version
00020 // 3.1, as published by the Free Software Foundation.
00021 
00022 // You should have received a copy of the GNU General Public License and
00023 // a copy of the GCC Runtime Library Exception along with this program;
00024 // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
00025 // <http://www.gnu.org/licenses/>.
00026 
00027 /** @file include/cstdlib
00028  *  This is a Standard C++ Library file.  You should @c #include this file
00029  *  in your programs, rather than any of the "*.h" implementation files.
00030  *
00031  *  This is the C++ version of the Standard C Library header @c stdlib.h,
00032  *  and its contents are (mostly) the same as that header, but are all
00033  *  contained in the namespace @c std (except for names which are defined
00034  *  as macros in C).
00035  */
00036 
00037 //
00038 // ISO C++ 14882: 20.4.6  C library
00039 //
00040 
00041 #pragma GCC system_header
00042 
00043 #include <bits/c++config.h>
00044 #include <cstddef>
00045 
00046 #ifndef _GLIBCXX_CSTDLIB
00047 #define _GLIBCXX_CSTDLIB 1
00048 
00049 #if !_GLIBCXX_HOSTED
00050 // The C standard does not require a freestanding implementation to
00051 // provide <stdlib.h>.  However, the C++ standard does still require
00052 // <cstdlib> -- but only the functionality mentioned in
00053 // [lib.support.start.term].
00054 
00055 #define EXIT_SUCCESS 0
00056 #define EXIT_FAILURE 1
00057 
00058 _GLIBCXX_BEGIN_NAMESPACE(std)
00059 
00060   extern "C" void abort(void);
00061   extern "C" int atexit(void (*)());
00062   extern "C" void exit(int);
00063 
00064 _GLIBCXX_END_NAMESPACE
00065 
00066 #else
00067 
00068 #include <stdlib.h>
00069 
00070 // Get rid of those macros defined in <stdlib.h> in lieu of real functions.
00071 #undef abort
00072 #undef abs
00073 #undef atexit
00074 #undef atof
00075 #undef atoi
00076 #undef atol
00077 #undef bsearch
00078 #undef calloc
00079 #undef div
00080 #undef exit
00081 #undef free
00082 #undef getenv
00083 #undef labs
00084 #undef ldiv
00085 #undef malloc
00086 #undef mblen
00087 #undef mbstowcs
00088 #undef mbtowc
00089 #undef qsort
00090 #undef rand
00091 #undef realloc
00092 #undef srand
00093 #undef strtod
00094 #undef strtol
00095 #undef strtoul
00096 #undef system
00097 #undef wcstombs
00098 #undef wctomb
00099 
00100 _GLIBCXX_BEGIN_NAMESPACE(std)
00101 
00102   using ::div_t;
00103   using ::ldiv_t;
00104 
00105   using ::abort;
00106   using ::abs;
00107   using ::atexit;
00108   using ::atof;
00109   using ::atoi;
00110   using ::atol;
00111   using ::bsearch;
00112   using ::calloc;
00113   using ::div;
00114   using ::exit;
00115   using ::free;
00116   using ::getenv;
00117   using ::labs;
00118   using ::ldiv;
00119   using ::malloc;
00120 #ifdef _GLIBCXX_HAVE_MBSTATE_T
00121   using ::mblen;
00122   using ::mbstowcs;
00123   using ::mbtowc;
00124 #endif // _GLIBCXX_HAVE_MBSTATE_T
00125   using ::qsort;
00126   using ::rand;
00127   using ::realloc;
00128   using ::srand;
00129   using ::strtod;
00130   using ::strtol;
00131   using ::strtoul;
00132   using ::system;
00133 #ifdef _GLIBCXX_USE_WCHAR_T
00134   using ::wcstombs;
00135   using ::wctomb;
00136 #endif // _GLIBCXX_USE_WCHAR_T
00137 
00138   inline long
00139   abs(long __i) { return labs(__i); }
00140 
00141   inline ldiv_t
00142   div(long __i, long __j) { return ldiv(__i, __j); }
00143 
00144 _GLIBCXX_END_NAMESPACE
00145 
00146 #if _GLIBCXX_USE_C99
00147 
00148 #undef _Exit
00149 #undef llabs
00150 #undef lldiv
00151 #undef atoll
00152 #undef strtoll
00153 #undef strtoull
00154 #undef strtof
00155 #undef strtold
00156 
00157 _GLIBCXX_BEGIN_NAMESPACE(__gnu_cxx)
00158 
00159 #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
00160   using ::lldiv_t;
00161 #endif
00162 #if _GLIBCXX_USE_C99_CHECK || _GLIBCXX_USE_C99_DYNAMIC
00163   extern "C" void (_Exit)(int);
00164 #endif
00165 #if !_GLIBCXX_USE_C99_DYNAMIC
00166   using ::_Exit;
00167 #endif
00168 
00169   inline long long
00170   abs(long long __x) { return __x >= 0 ? __x : -__x; }
00171 
00172 #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
00173   using ::llabs;
00174 
00175   inline lldiv_t
00176   div(long long __n, long long __d)
00177   { lldiv_t __q; __q.quot = __n / __d; __q.rem = __n % __d; return __q; }
00178 
00179   using ::lldiv;
00180 #endif
00181 
00182 #if _GLIBCXX_USE_C99_LONG_LONG_CHECK || _GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
00183   extern "C" long long int (atoll)(const char *);
00184   extern "C" long long int
00185     (strtoll)(const char * restrict, char ** restrict, int);
00186   extern "C" unsigned long long int
00187     (strtoull)(const char * restrict, char ** restrict, int);
00188 #endif
00189 #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
00190   using ::atoll;
00191   using ::strtoll;
00192   using ::strtoull;
00193 #endif
00194   using ::strtof;
00195   using ::strtold;
00196 
00197 _GLIBCXX_END_NAMESPACE
00198 
00199 _GLIBCXX_BEGIN_NAMESPACE(std)
00200 
00201 #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
00202   using ::__gnu_cxx::lldiv_t;
00203 #endif
00204   using ::__gnu_cxx::_Exit;
00205   using ::__gnu_cxx::abs;
00206 #if !_GLIBCXX_USE_C99_LONG_LONG_DYNAMIC
00207   using ::__gnu_cxx::llabs;
00208   using ::__gnu_cxx::div;
00209   using ::__gnu_cxx::lldiv;
00210 #endif
00211   using ::__gnu_cxx::atoll;
00212   using ::__gnu_cxx::strtof;
00213   using ::__gnu_cxx::strtoll;
00214   using ::__gnu_cxx::strtoull;
00215   using ::__gnu_cxx::strtold;
00216 
00217 _GLIBCXX_END_NAMESPACE
00218 
00219 #endif // _GLIBCXX_USE_C99
00220 
00221 #ifdef __GXX_EXPERIMENTAL_CXX0X__
00222 #  if defined(_GLIBCXX_INCLUDE_AS_TR1)
00223 #    error C++0x header cannot be included from TR1 header
00224 #  endif
00225 #  if defined(_GLIBCXX_INCLUDE_AS_CXX0X)
00226 #    include <tr1_impl/cstdlib>
00227 #  else
00228 #    define _GLIBCXX_INCLUDE_AS_CXX0X
00229 #    define _GLIBCXX_BEGIN_NAMESPACE_TR1
00230 #    define _GLIBCXX_END_NAMESPACE_TR1
00231 #    define _GLIBCXX_TR1
00232 #    include <tr1_impl/cstdlib>
00233 #    undef _GLIBCXX_TR1
00234 #    undef _GLIBCXX_END_NAMESPACE_TR1
00235 #    undef _GLIBCXX_BEGIN_NAMESPACE_TR1
00236 #    undef _GLIBCXX_INCLUDE_AS_CXX0X
00237 #  endif
00238 #endif
00239 
00240 #endif // !_GLIBCXX_HOSTED
00241 
00242 #endif

Generated on Tue Apr 21 13:13:26 2009 for libstdc++ by  doxygen 1.5.8