epoc32/include/tools/stlport/stl/_cstdlib.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
williamr@4
     1
/*
williamr@4
     2
 * Copyright (c) 1999
williamr@4
     3
 * Boris Fomitchev
williamr@4
     4
 *
williamr@4
     5
 * This material is provided "as is", with absolutely no warranty expressed
williamr@4
     6
 * or implied. Any use is at your own risk.
williamr@4
     7
 *
williamr@4
     8
 * Permission to use or copy this software for any purpose is hereby granted
williamr@4
     9
 * without fee, provided the above notices are retained on all copies.
williamr@4
    10
 * Permission to modify the code and to distribute modified code is granted,
williamr@4
    11
 * provided the above notices are retained, and a notice that the code was
williamr@4
    12
 * modified is included with the above copyright notice.
williamr@4
    13
 *
williamr@4
    14
 */
williamr@4
    15
williamr@4
    16
#ifndef _STLP_INTERNAL_CSTDLIB
williamr@4
    17
#define _STLP_INTERNAL_CSTDLIB
williamr@4
    18
williamr@4
    19
#if defined (_STLP_USE_NEW_C_HEADERS)
williamr@4
    20
#  include _STLP_NATIVE_CPP_C_HEADER(cstdlib)
williamr@4
    21
#else
williamr@4
    22
#  include <stdlib.h>
williamr@4
    23
#endif
williamr@4
    24
williamr@4
    25
#if defined (__BORLANDC__)
williamr@4
    26
/* Borland process.h header do not bring anything here and is just included
williamr@4
    27
 * in order to avoid inclusion later. This header cannot be included later
williamr@4
    28
 * because Borland compiler consider that for instance the abort function
williamr@4
    29
 * defined as extern "C" cannot be overloaded and it finds 2 "overloads",
williamr@4
    30
 * once in native std namespace and the other in STLport namespace...
williamr@4
    31
 */
williamr@4
    32
#  include <process.h>
williamr@4
    33
#endif
williamr@4
    34
williamr@4
    35
/* on evc3/evc4 including stdlib.h also defines setjmp macro */
williamr@4
    36
#if defined (_STLP_WCE)
williamr@4
    37
#  define _STLP_NATIVE_SETJMP_H_INCLUDED
williamr@4
    38
#endif
williamr@4
    39
williamr@4
    40
#if defined (__MSL__) && (__MSL__ <= 0x5003)
williamr@4
    41
namespace std {
williamr@4
    42
  typedef ::div_t div_t;
williamr@4
    43
  typedef ::ldiv_t ldiv_t;
williamr@4
    44
#  ifdef __MSL_LONGLONG_SUPPORT__
williamr@4
    45
  typedef ::lldiv_t lldiv_t;
williamr@4
    46
#  endif
williamr@4
    47
}
williamr@4
    48
#endif
williamr@4
    49
williamr@4
    50
#ifdef _STLP_IMPORT_VENDOR_CSTD
williamr@4
    51
_STLP_BEGIN_NAMESPACE
williamr@4
    52
using _STLP_VENDOR_CSTD::div_t;
williamr@4
    53
using _STLP_VENDOR_CSTD::ldiv_t;
williamr@4
    54
using _STLP_VENDOR_CSTD::size_t;
williamr@4
    55
williamr@4
    56
#  ifndef _STLP_NO_CSTD_FUNCTION_IMPORTS
williamr@4
    57
#    ifndef _STLP_WCE
williamr@4
    58
// these functions just don't exist on Windows CE
williamr@4
    59
using _STLP_VENDOR_CSTD::abort;
williamr@4
    60
using _STLP_VENDOR_CSTD::getenv;
williamr@4
    61
using _STLP_VENDOR_CSTD::mblen;
williamr@4
    62
using _STLP_VENDOR_CSTD::mbtowc;
williamr@4
    63
using _STLP_VENDOR_CSTD::system;
williamr@4
    64
using _STLP_VENDOR_CSTD::bsearch;
williamr@4
    65
#    endif
williamr@4
    66
using _STLP_VENDOR_CSTD::atexit;
williamr@4
    67
using _STLP_VENDOR_CSTD::exit;
williamr@4
    68
using _STLP_VENDOR_CSTD::calloc;
williamr@4
    69
using _STLP_VENDOR_CSTD::free;
williamr@4
    70
using _STLP_VENDOR_CSTD::malloc;
williamr@4
    71
using _STLP_VENDOR_CSTD::realloc;
williamr@4
    72
using _STLP_VENDOR_CSTD::atof;
williamr@4
    73
using _STLP_VENDOR_CSTD::atoi;
williamr@4
    74
using _STLP_VENDOR_CSTD::atol;
williamr@4
    75
using _STLP_VENDOR_CSTD::mbstowcs;
williamr@4
    76
using _STLP_VENDOR_CSTD::strtod;
williamr@4
    77
using _STLP_VENDOR_CSTD::strtol;
williamr@4
    78
using _STLP_VENDOR_CSTD::strtoul;
williamr@4
    79
williamr@4
    80
#    if !(defined (_STLP_NO_NATIVE_WIDE_STREAMS) || defined (_STLP_NO_MBSTATE_T))
williamr@4
    81
using _STLP_VENDOR_CSTD::wcstombs;
williamr@4
    82
#      ifndef _STLP_WCE
williamr@4
    83
using _STLP_VENDOR_CSTD::wctomb;
williamr@4
    84
#      endif
williamr@4
    85
#    endif
williamr@4
    86
using _STLP_VENDOR_CSTD::qsort;
williamr@4
    87
using _STLP_VENDOR_CSTD::labs;
williamr@4
    88
using _STLP_VENDOR_CSTD::ldiv;
williamr@4
    89
#    if defined (_STLP_LONG_LONG) && !defined (_STLP_NO_VENDOR_STDLIB_L)
williamr@4
    90
#      if !defined(__sun)
williamr@4
    91
using _STLP_VENDOR_CSTD::llabs;
williamr@4
    92
using _STLP_VENDOR_CSTD::lldiv_t;
williamr@4
    93
using _STLP_VENDOR_CSTD::lldiv;
williamr@4
    94
#      else
williamr@4
    95
using ::llabs;
williamr@4
    96
using ::lldiv_t;
williamr@4
    97
using ::lldiv;
williamr@4
    98
#      endif
williamr@4
    99
#    endif
williamr@4
   100
using _STLP_VENDOR_CSTD::rand;
williamr@4
   101
using _STLP_VENDOR_CSTD::srand;
williamr@4
   102
#  endif /* _STLP_NO_CSTD_FUNCTION_IMPORTS */
williamr@4
   103
_STLP_END_NAMESPACE
williamr@4
   104
#endif /* _STLP_IMPORT_VENDOR_CSTD */
williamr@4
   105
williamr@4
   106
#if defined (__BORLANDC__) && defined (_STLP_USE_NEW_C_HEADERS)
williamr@4
   107
//In this config bcc define everything in std namespace and not in
williamr@4
   108
//the global one.
williamr@4
   109
inline int abs(int __x) { return _STLP_VENDOR_CSTD::abs(__x); }
williamr@4
   110
inline _STLP_VENDOR_CSTD::div_t div(int __x, int __y) { return _STLP_VENDOR_CSTD::div(__x, __y); }
williamr@4
   111
#endif
williamr@4
   112
williamr@4
   113
#if defined(_MSC_EXTENSIONS) && defined(_STLP_MSVC) && (_STLP_MSVC <= 1300)
williamr@4
   114
#  define _STLP_RESTORE_FUNCTION_INTRINSIC
williamr@4
   115
#  pragma warning (push)
williamr@4
   116
#  pragma warning (disable: 4162)
williamr@4
   117
#  pragma function (abs)
williamr@4
   118
#endif
williamr@4
   119
williamr@4
   120
//HP-UX native lib has abs() and div() functions in global namespace
williamr@4
   121
#if !defined (__HP_aCC) || (__HP_aCC < 30000)
williamr@4
   122
williamr@4
   123
//MSVC starting with .Net 2003 already define all math functions in global namespace:
williamr@4
   124
#  if !defined (_STLP_MSVC_LIB) || (_STLP_MSVC_LIB < 1310) || defined(UNDER_CE)
williamr@4
   125
inline long abs(long __x) { return _STLP_VENDOR_CSTD::labs(__x); }
williamr@4
   126
#  endif
williamr@4
   127
williamr@4
   128
/** VC since version 8 has this, the platform SDK and CE SDKs hanging behind. */
williamr@4
   129
#  if !defined (_STLP_MSVC_LIB) || (_STLP_MSVC_LIB < 1400) || defined (_STLP_USING_PLATFORM_SDK_COMPILER) || defined(UNDER_CE)
williamr@4
   130
inline _STLP_VENDOR_CSTD::ldiv_t div(long __x, long __y) { return _STLP_VENDOR_CSTD::ldiv(__x, __y); }
williamr@4
   131
#  endif
williamr@4
   132
williamr@4
   133
#endif
williamr@4
   134
williamr@4
   135
#if defined (_STLP_RESTORE_FUNCTION_INTRINSIC)
williamr@4
   136
#  pragma intrinsic (abs)
williamr@4
   137
#  pragma warning (pop)
williamr@4
   138
#  undef _STLP_RESTORE_FUNCTION_INTRINSIC
williamr@4
   139
#endif
williamr@4
   140
williamr@4
   141
#if defined (_STLP_LONG_LONG)
williamr@4
   142
#  if !defined (_STLP_NO_VENDOR_STDLIB_L)
williamr@4
   143
#    if !defined (__sun)
williamr@4
   144
inline _STLP_LONG_LONG  abs(_STLP_LONG_LONG __x) { return _STLP_VENDOR_CSTD::llabs(__x); }
williamr@4
   145
inline lldiv_t div(_STLP_LONG_LONG __x, _STLP_LONG_LONG __y) { return _STLP_VENDOR_CSTD::lldiv(__x, __y); }
williamr@4
   146
#    else
williamr@4
   147
inline _STLP_LONG_LONG  abs(_STLP_LONG_LONG __x) { return ::llabs(__x); }
williamr@4
   148
inline lldiv_t div(_STLP_LONG_LONG __x, _STLP_LONG_LONG __y) { return ::lldiv(__x, __y); }
williamr@4
   149
#    endif
williamr@4
   150
#  else
williamr@4
   151
inline _STLP_LONG_LONG  abs(_STLP_LONG_LONG __x) { return __x < 0 ? -__x : __x; }
williamr@4
   152
#  endif
williamr@4
   153
#endif
williamr@4
   154
williamr@4
   155
/* C++ Standard is unclear about several call to 'using ::func' if new overloads
williamr@4
   156
 * of ::func appears between 2 successive 'using' calls. To avoid this potential
williamr@4
   157
 * problem we provide all abs overload before the 'using' call.
williamr@4
   158
 * Beware: This header inclusion has to be after all abs overload of this file.
williamr@4
   159
 *         The first 'using ::abs' call is going to be in the other header.
williamr@4
   160
 */
williamr@4
   161
#ifndef _STLP_INTERNAL_CMATH
williamr@4
   162
#  include <stl/_cmath.h>
williamr@4
   163
#endif
williamr@4
   164
williamr@4
   165
#if defined (_STLP_IMPORT_VENDOR_CSTD) && !defined (_STLP_NO_CSTD_FUNCTION_IMPORTS)
williamr@4
   166
// ad hoc, don't replace with _STLP_VENDOR_CSTD::abs here! - ptr 2005-03-05
williamr@4
   167
_STLP_BEGIN_NAMESPACE
williamr@4
   168
using ::abs;
williamr@4
   169
#  if !defined (N_PLAT_NLM)
williamr@4
   170
using ::div;
williamr@4
   171
#  else
williamr@4
   172
// Don't use div from clib or libc on NetWare---buggy! - ptr 2005-06-06
williamr@4
   173
inline div_t div(int __x, int __y) { div_t d; d.quot = __x / __y; d.rem = __x % __y; return d; }
williamr@4
   174
inline ldiv_t div(long __x, long __y) { ldiv_t d; d.quot = __x / __y; d.rem = __x % __y; return d; }
williamr@4
   175
#  endif
williamr@4
   176
_STLP_END_NAMESPACE
williamr@4
   177
#endif
williamr@4
   178
williamr@4
   179
#endif /* _STLP_INTERNAL_CSTDLIB */