/home/ntakagi/work/STLport-5.1.5/stlport/stl/_cstdlib.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 1999
00003  * Boris Fomitchev
00004  *
00005  * This material is provided "as is", with absolutely no warranty expressed
00006  * or implied. Any use is at your own risk.
00007  *
00008  * Permission to use or copy this software for any purpose is hereby granted
00009  * without fee, provided the above notices are retained on all copies.
00010  * Permission to modify the code and to distribute modified code is granted,
00011  * provided the above notices are retained, and a notice that the code was
00012  * modified is included with the above copyright notice.
00013  *
00014  */
00015 
00016 #ifndef _STLP_INTERNAL_CSTDLIB
00017 #define _STLP_INTERNAL_CSTDLIB
00018 
00019 #if defined (_STLP_USE_NEW_C_HEADERS)
00020 #  include _STLP_NATIVE_CPP_C_HEADER(cstdlib)
00021 #else
00022 #  include <stdlib.h>
00023 #endif
00024 
00025 #if defined (__BORLANDC__)
00026 /* Borland process.h header do not bring anything here and is just included
00027  * in order to avoid inclusion later. This header cannot be included later
00028  * because Borland compiler consider that for instance the abort function
00029  * defined as extern "C" cannot be overloaded and it finds 2 "overloads",
00030  * once in native std namespace and the other in STLport namespace...
00031  */
00032 #  include <process.h>
00033 #endif
00034 
00035 /* on evc3/evc4 including stdlib.h also defines setjmp macro */
00036 #if defined (_STLP_WCE)
00037 #  define _STLP_NATIVE_SETJMP_H_INCLUDED
00038 #endif
00039 
00040 #if defined (__MSL__) && (__MSL__ <= 0x5003)
00041 namespace std {
00042   typedef ::div_t div_t;
00043   typedef ::ldiv_t ldiv_t;
00044 #  ifdef __MSL_LONGLONG_SUPPORT__
00045   typedef ::lldiv_t lldiv_t;
00046 #  endif
00047 }
00048 #endif
00049 
00050 #ifdef _STLP_IMPORT_VENDOR_CSTD
00051 _STLP_BEGIN_NAMESPACE
00052 using _STLP_VENDOR_CSTD::div_t;
00053 using _STLP_VENDOR_CSTD::ldiv_t;
00054 using _STLP_VENDOR_CSTD::size_t;
00055 
00056 #  ifndef _STLP_NO_CSTD_FUNCTION_IMPORTS
00057 #    ifndef _STLP_WCE
00058 // these functions just don't exist on Windows CE
00059 using _STLP_VENDOR_CSTD::abort;
00060 using _STLP_VENDOR_CSTD::getenv;
00061 
00062 #ifndef __hpux
00063 using _STLP_VENDOR_CSTD::mblen;
00064 using _STLP_VENDOR_CSTD::mbtowc;
00065 #endif
00066 
00067 using _STLP_VENDOR_CSTD::system;
00068 using _STLP_VENDOR_CSTD::bsearch;
00069 #    endif
00070 using _STLP_VENDOR_CSTD::atexit;
00071 using _STLP_VENDOR_CSTD::exit;
00072 using _STLP_VENDOR_CSTD::calloc;
00073 using _STLP_VENDOR_CSTD::free;
00074 using _STLP_VENDOR_CSTD::malloc;
00075 using _STLP_VENDOR_CSTD::realloc;
00076 using _STLP_VENDOR_CSTD::atof;
00077 using _STLP_VENDOR_CSTD::atoi;
00078 using _STLP_VENDOR_CSTD::atol;
00079 
00080 #ifndef __hpux
00081 using _STLP_VENDOR_CSTD::mbstowcs;
00082 #endif
00083 
00084 using _STLP_VENDOR_CSTD::strtod;
00085 using _STLP_VENDOR_CSTD::strtol;
00086 using _STLP_VENDOR_CSTD::strtoul;
00087 
00088 #    if !(defined (_STLP_NO_NATIVE_WIDE_STREAMS) || defined (_STLP_NO_MBSTATE_T))
00089 using _STLP_VENDOR_CSTD::wcstombs;
00090 #      ifndef _STLP_WCE
00091 using _STLP_VENDOR_CSTD::wctomb;
00092 #      endif
00093 #    endif
00094 using _STLP_VENDOR_CSTD::qsort;
00095 using _STLP_VENDOR_CSTD::labs;
00096 using _STLP_VENDOR_CSTD::ldiv;
00097 #    if defined (_STLP_LONG_LONG) && !defined (_STLP_NO_VENDOR_STDLIB_L)
00098 #      if !defined(__sun)
00099 using _STLP_VENDOR_CSTD::llabs;
00100 using _STLP_VENDOR_CSTD::lldiv_t;
00101 using _STLP_VENDOR_CSTD::lldiv;
00102 #      else
00103 using ::llabs;
00104 using ::lldiv_t;
00105 using ::lldiv;
00106 #      endif
00107 #    endif
00108 using _STLP_VENDOR_CSTD::rand;
00109 using _STLP_VENDOR_CSTD::srand;
00110 #  endif /* _STLP_NO_CSTD_FUNCTION_IMPORTS */
00111 _STLP_END_NAMESPACE
00112 #endif /* _STLP_IMPORT_VENDOR_CSTD */
00113 
00114 #if defined (__BORLANDC__) && defined (_STLP_USE_NEW_C_HEADERS)
00115 //In this config bcc define everything in std namespace and not in
00116 //the global one.
00117 inline int abs(int __x) { return _STLP_VENDOR_CSTD::abs(__x); }
00118 inline _STLP_VENDOR_CSTD::div_t div(int __x, int __y) { return _STLP_VENDOR_CSTD::div(__x, __y); }
00119 #endif
00120 
00121 #if defined(_MSC_EXTENSIONS) && defined(_STLP_MSVC) && (_STLP_MSVC <= 1300)
00122 #  define _STLP_RESTORE_FUNCTION_INTRINSIC
00123 #  pragma warning (push)
00124 #  pragma warning (disable: 4162)
00125 #  pragma function (abs)
00126 #endif
00127 
00128 //HP-UX native lib has abs() and div() functions in global namespace
00129 #if !defined (__HP_aCC) || (__HP_aCC < 30000)
00130 
00131 //MSVC starting with .Net 2003 already define all math functions in global namespace:
00132 #  if !defined (_STLP_MSVC_LIB) || (_STLP_MSVC_LIB < 1310) || defined(UNDER_CE)
00133 inline long abs(long __x) { return _STLP_VENDOR_CSTD::labs(__x); }
00134 #  endif
00135 
00137 #  if !defined (_STLP_MSVC_LIB) || (_STLP_MSVC_LIB < 1400) || defined (_STLP_USING_PLATFORM_SDK_COMPILER) || defined(UNDER_CE)
00138 inline _STLP_VENDOR_CSTD::ldiv_t div(long __x, long __y) { return _STLP_VENDOR_CSTD::ldiv(__x, __y); }
00139 #  endif
00140 
00141 #endif
00142 
00143 #if defined (_STLP_RESTORE_FUNCTION_INTRINSIC)
00144 #  pragma intrinsic (abs)
00145 #  pragma warning (pop)
00146 #  undef _STLP_RESTORE_FUNCTION_INTRINSIC
00147 #endif
00148 
00149 #if defined (_STLP_LONG_LONG)
00150 #  if !defined (_STLP_NO_VENDOR_STDLIB_L)
00151 #    if !defined (__sun)
00152 inline _STLP_LONG_LONG  abs(_STLP_LONG_LONG __x) { return _STLP_VENDOR_CSTD::llabs(__x); }
00153 inline lldiv_t div(_STLP_LONG_LONG __x, _STLP_LONG_LONG __y) { return _STLP_VENDOR_CSTD::lldiv(__x, __y); }
00154 #    else
00155 inline _STLP_LONG_LONG  abs(_STLP_LONG_LONG __x) { return ::llabs(__x); }
00156 inline lldiv_t div(_STLP_LONG_LONG __x, _STLP_LONG_LONG __y) { return ::lldiv(__x, __y); }
00157 #    endif
00158 #  else
00159 inline _STLP_LONG_LONG  abs(_STLP_LONG_LONG __x) { return __x < 0 ? -__x : __x; }
00160 #  endif
00161 #endif
00162 
00163 /* C++ Standard is unclear about several call to 'using ::func' if new overloads
00164  * of ::func appears between 2 successive 'using' calls. To avoid this potential
00165  * problem we provide all abs overload before the 'using' call.
00166  * Beware: This header inclusion has to be after all abs overload of this file.
00167  *         The first 'using ::abs' call is going to be in the other header.
00168  */
00169 #ifndef _STLP_INTERNAL_CMATH
00170 #  include <stl/_cmath.h>
00171 #endif
00172 
00173 #if defined (_STLP_IMPORT_VENDOR_CSTD) && !defined (_STLP_NO_CSTD_FUNCTION_IMPORTS)
00174 // ad hoc, don't replace with _STLP_VENDOR_CSTD::abs here! - ptr 2005-03-05
00175 _STLP_BEGIN_NAMESPACE
00176 using ::abs;
00177 #  if !defined (N_PLAT_NLM)
00178 using ::div;
00179 #  else
00180 // Don't use div from clib or libc on NetWare---buggy! - ptr 2005-06-06
00181 inline div_t div(int __x, int __y) { div_t d; d.quot = __x / __y; d.rem = __x % __y; return d; }
00182 inline ldiv_t div(long __x, long __y) { ldiv_t d; d.quot = __x / __y; d.rem = __x % __y; return d; }
00183 #  endif
00184 _STLP_END_NAMESPACE
00185 #endif
00186 
00187 #endif /* _STLP_INTERNAL_CSTDLIB */



Generated on Mon Mar 10 15:32:20 2008 by  doxygen 1.5.1