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