epoc32/include/stdapis/stlportv5/stl/_cstdlib.h
branchSymbian2
changeset 3 e1b950c65cb4
parent 2 2fe1408b6811
child 4 837f303aceeb
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/stdapis/stlportv5/stl/_cstdlib.h	Wed Mar 31 12:27:01 2010 +0100
     1.3 @@ -0,0 +1,179 @@
     1.4 +/*
     1.5 + * Copyright (c) 1999
     1.6 + * Boris Fomitchev
     1.7 + *
     1.8 + * This material is provided "as is", with absolutely no warranty expressed
     1.9 + * or implied. Any use is at your own risk.
    1.10 + *
    1.11 + * Permission to use or copy this software for any purpose is hereby granted
    1.12 + * without fee, provided the above notices are retained on all copies.
    1.13 + * Permission to modify the code and to distribute modified code is granted,
    1.14 + * provided the above notices are retained, and a notice that the code was
    1.15 + * modified is included with the above copyright notice.
    1.16 + *
    1.17 + */
    1.18 +
    1.19 +#ifndef _STLP_INTERNAL_CSTDLIB
    1.20 +#define _STLP_INTERNAL_CSTDLIB
    1.21 +
    1.22 +#if defined (_STLP_USE_NEW_C_HEADERS)
    1.23 +#  include _STLP_NATIVE_CPP_C_HEADER(cstdlib)
    1.24 +#else
    1.25 +#  include <stdlib.h>
    1.26 +#endif
    1.27 +
    1.28 +#if defined (__BORLANDC__)
    1.29 +/* Borland process.h header do not bring anything here and is just included
    1.30 + * in order to avoid inclusion later. This header cannot be included later
    1.31 + * because Borland compiler consider that for instance the abort function
    1.32 + * defined as extern "C" cannot be overloaded and it finds 2 "overloads",
    1.33 + * once in native std namespace and the other in STLport namespace...
    1.34 + */
    1.35 +#  include <process.h>
    1.36 +#endif
    1.37 +
    1.38 +/* on evc3/evc4 including stdlib.h also defines setjmp macro */
    1.39 +#if defined (_STLP_WCE)
    1.40 +#  define _STLP_NATIVE_SETJMP_H_INCLUDED
    1.41 +#endif
    1.42 +
    1.43 +#if defined (__MSL__) && (__MSL__ <= 0x5003)
    1.44 +namespace std {
    1.45 +  typedef ::div_t div_t;
    1.46 +  typedef ::ldiv_t ldiv_t;
    1.47 +#  ifdef __MSL_LONGLONG_SUPPORT__
    1.48 +  typedef ::lldiv_t lldiv_t;
    1.49 +#  endif
    1.50 +}
    1.51 +#endif
    1.52 +
    1.53 +#ifdef _STLP_IMPORT_VENDOR_CSTD
    1.54 +_STLP_BEGIN_NAMESPACE
    1.55 +using _STLP_VENDOR_CSTD::div_t;
    1.56 +using _STLP_VENDOR_CSTD::ldiv_t;
    1.57 +using _STLP_VENDOR_CSTD::size_t;
    1.58 +
    1.59 +#  ifndef _STLP_NO_CSTD_FUNCTION_IMPORTS
    1.60 +#    ifndef _STLP_WCE
    1.61 +// these functions just don't exist on Windows CE
    1.62 +using _STLP_VENDOR_CSTD::abort;
    1.63 +using _STLP_VENDOR_CSTD::getenv;
    1.64 +using _STLP_VENDOR_CSTD::mblen;
    1.65 +using _STLP_VENDOR_CSTD::mbtowc;
    1.66 +using _STLP_VENDOR_CSTD::system;
    1.67 +using _STLP_VENDOR_CSTD::bsearch;
    1.68 +#    endif
    1.69 +using _STLP_VENDOR_CSTD::atexit;
    1.70 +using _STLP_VENDOR_CSTD::exit;
    1.71 +using _STLP_VENDOR_CSTD::calloc;
    1.72 +using _STLP_VENDOR_CSTD::free;
    1.73 +using _STLP_VENDOR_CSTD::malloc;
    1.74 +using _STLP_VENDOR_CSTD::realloc;
    1.75 +using _STLP_VENDOR_CSTD::atof;
    1.76 +using _STLP_VENDOR_CSTD::atoi;
    1.77 +using _STLP_VENDOR_CSTD::atol;
    1.78 +using _STLP_VENDOR_CSTD::mbstowcs;
    1.79 +using _STLP_VENDOR_CSTD::strtod;
    1.80 +using _STLP_VENDOR_CSTD::strtol;
    1.81 +using _STLP_VENDOR_CSTD::strtoul;
    1.82 +
    1.83 +#    if !(defined (_STLP_NO_NATIVE_WIDE_STREAMS) || defined (_STLP_NO_MBSTATE_T))
    1.84 +using _STLP_VENDOR_CSTD::wcstombs;
    1.85 +#      ifndef _STLP_WCE
    1.86 +using _STLP_VENDOR_CSTD::wctomb;
    1.87 +#      endif
    1.88 +#    endif
    1.89 +using _STLP_VENDOR_CSTD::qsort;
    1.90 +using _STLP_VENDOR_CSTD::labs;
    1.91 +using _STLP_VENDOR_CSTD::ldiv;
    1.92 +#    if defined (_STLP_LONG_LONG) && !defined (_STLP_NO_VENDOR_STDLIB_L)
    1.93 +#      if !defined(__sun)
    1.94 +using _STLP_VENDOR_CSTD::llabs;
    1.95 +using _STLP_VENDOR_CSTD::lldiv_t;
    1.96 +using _STLP_VENDOR_CSTD::lldiv;
    1.97 +#      else
    1.98 +using ::llabs;
    1.99 +using ::lldiv_t;
   1.100 +using ::lldiv;
   1.101 +#      endif
   1.102 +#    endif
   1.103 +using _STLP_VENDOR_CSTD::rand;
   1.104 +using _STLP_VENDOR_CSTD::srand;
   1.105 +#  endif /* _STLP_NO_CSTD_FUNCTION_IMPORTS */
   1.106 +_STLP_END_NAMESPACE
   1.107 +#endif /* _STLP_IMPORT_VENDOR_CSTD */
   1.108 +
   1.109 +#if defined (__BORLANDC__) && defined (_STLP_USE_NEW_C_HEADERS)
   1.110 +//In this config bcc define everything in std namespace and not in
   1.111 +//the global one.
   1.112 +inline int abs(int __x) { return _STLP_VENDOR_CSTD::abs(__x); }
   1.113 +inline _STLP_VENDOR_CSTD::div_t div(int __x, int __y) { return _STLP_VENDOR_CSTD::div(__x, __y); }
   1.114 +#endif
   1.115 +
   1.116 +#if defined(_MSC_EXTENSIONS) && defined(_STLP_MSVC) && (_STLP_MSVC <= 1300)
   1.117 +#  define _STLP_RESTORE_FUNCTION_INTRINSIC
   1.118 +#  pragma warning (push)
   1.119 +#  pragma warning (disable: 4162)
   1.120 +#  pragma function (abs)
   1.121 +#endif
   1.122 +
   1.123 +//HP-UX native lib has abs() and div() functions in global namespace
   1.124 +#if !defined (__HP_aCC) || (__HP_aCC < 30000)
   1.125 +
   1.126 +//MSVC starting with .Net 2003 already define all math functions in global namespace:
   1.127 +#  if !defined (_STLP_MSVC_LIB) || (_STLP_MSVC_LIB < 1310) || defined(UNDER_CE)
   1.128 +inline long abs(long __x) { return _STLP_VENDOR_CSTD::labs(__x); }
   1.129 +#  endif
   1.130 +
   1.131 +/** VC since version 8 has this, the platform SDK and CE SDKs hanging behind. */
   1.132 +#  if !defined (_STLP_MSVC_LIB) || (_STLP_MSVC_LIB < 1400) || defined (_STLP_USING_PLATFORM_SDK_COMPILER) || defined(UNDER_CE)
   1.133 +inline _STLP_VENDOR_CSTD::ldiv_t div(long __x, long __y) { return _STLP_VENDOR_CSTD::ldiv(__x, __y); }
   1.134 +#  endif
   1.135 +
   1.136 +#endif
   1.137 +
   1.138 +#if defined (_STLP_RESTORE_FUNCTION_INTRINSIC)
   1.139 +#  pragma intrinsic (abs)
   1.140 +#  pragma warning (pop)
   1.141 +#  undef _STLP_RESTORE_FUNCTION_INTRINSIC
   1.142 +#endif
   1.143 +
   1.144 +#if defined (_STLP_LONG_LONG)
   1.145 +#  if !defined (_STLP_NO_VENDOR_STDLIB_L)
   1.146 +#    if !defined (__sun)
   1.147 +inline _STLP_LONG_LONG  abs(_STLP_LONG_LONG __x) { return _STLP_VENDOR_CSTD::llabs(__x); }
   1.148 +inline lldiv_t div(_STLP_LONG_LONG __x, _STLP_LONG_LONG __y) { return _STLP_VENDOR_CSTD::lldiv(__x, __y); }
   1.149 +#    else
   1.150 +inline _STLP_LONG_LONG  abs(_STLP_LONG_LONG __x) { return ::llabs(__x); }
   1.151 +inline lldiv_t div(_STLP_LONG_LONG __x, _STLP_LONG_LONG __y) { return ::lldiv(__x, __y); }
   1.152 +#    endif
   1.153 +#  else
   1.154 +inline _STLP_LONG_LONG  abs(_STLP_LONG_LONG __x) { return __x < 0 ? -__x : __x; }
   1.155 +#  endif
   1.156 +#endif
   1.157 +
   1.158 +/* C++ Standard is unclear about several call to 'using ::func' if new overloads
   1.159 + * of ::func appears between 2 successive 'using' calls. To avoid this potential
   1.160 + * problem we provide all abs overload before the 'using' call.
   1.161 + * Beware: This header inclusion has to be after all abs overload of this file.
   1.162 + *         The first 'using ::abs' call is going to be in the other header.
   1.163 + */
   1.164 +#ifndef _STLP_INTERNAL_CMATH
   1.165 +#  include <stl/_cmath.h>
   1.166 +#endif
   1.167 +
   1.168 +#if defined (_STLP_IMPORT_VENDOR_CSTD) && !defined (_STLP_NO_CSTD_FUNCTION_IMPORTS)
   1.169 +// ad hoc, don't replace with _STLP_VENDOR_CSTD::abs here! - ptr 2005-03-05
   1.170 +_STLP_BEGIN_NAMESPACE
   1.171 +using ::abs;
   1.172 +#  if !defined (N_PLAT_NLM)
   1.173 +using ::div;
   1.174 +#  else
   1.175 +// Don't use div from clib or libc on NetWare---buggy! - ptr 2005-06-06
   1.176 +inline div_t div(int __x, int __y) { div_t d; d.quot = __x / __y; d.rem = __x % __y; return d; }
   1.177 +inline ldiv_t div(long __x, long __y) { ldiv_t d; d.quot = __x / __y; d.rem = __x % __y; return d; }
   1.178 +#  endif
   1.179 +_STLP_END_NAMESPACE
   1.180 +#endif
   1.181 +
   1.182 +#endif /* _STLP_INTERNAL_CSTDLIB */