ReactOS  0.4.14-dev-77-gd9e7c48
_cstdlib.h
Go to the documentation of this file.
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 # if defined (_STLP_HAS_INCLUDE_NEXT)
21 # include_next <cstdlib>
22 # else
23 # include _STLP_NATIVE_CPP_C_HEADER(cstdlib)
24 # endif
25 #else
26 # include <stdlib.h>
27 #endif
28 
29 #if defined (__BORLANDC__) && !defined (__linux__)
30 /* Borland process.h header do not bring anything here and is just included
31  * in order to avoid inclusion later. This header cannot be included later
32  * because Borland compiler consider that for instance the abort function
33  * defined as extern "C" cannot be overloaded and it finds 2 "overloads",
34  * once in native std namespace and the other in STLport namespace...
35  */
36 # include <process.h>
37 #endif
38 
39 /* on evc3/evc4 including stdlib.h also defines setjmp macro */
40 #if defined (_STLP_WCE)
41 # define _STLP_NATIVE_SETJMP_H_INCLUDED
42 #endif
43 
44 #if defined (__MSL__) && (__MSL__ <= 0x5003)
45 namespace std {
48 # ifdef __MSL_LONGLONG_SUPPORT__
49  typedef ::lldiv_t lldiv_t;
50 # endif
51 }
52 #endif
53 
54 #ifdef _STLP_IMPORT_VENDOR_CSTD
59 
60 # ifndef _STLP_NO_CSTD_FUNCTION_IMPORTS
61 # ifndef _STLP_WCE
62 // these functions just don't exist on Windows CE
69 # endif
83 
84 # if !(defined (_STLP_NO_NATIVE_WIDE_STREAMS) || defined (_STLP_NO_NATIVE_MBSTATE_T))
86 # ifndef _STLP_WCE
88 # endif
89 # endif
93 # if defined (_STLP_LONG_LONG) && !defined (_STLP_NO_VENDOR_STDLIB_L)
94 # if !defined(__sun)
96 using _STLP_VENDOR_CSTD::lldiv_t;
98 # else
100 using ::lldiv_t;
102 # endif
103 # endif
106 # endif /* _STLP_NO_CSTD_FUNCTION_IMPORTS */
108 #endif /* _STLP_IMPORT_VENDOR_CSTD */
109 
110 #if (defined (__BORLANDC__) || defined (__WATCOMC__)) && defined (_STLP_USE_NEW_C_HEADERS)
111 //In this config bcc define everything in std namespace and not in
112 //the global one.
113 inline int abs(int __x) { return _STLP_VENDOR_CSTD::abs(__x); }
114 inline _STLP_VENDOR_CSTD::div_t div(int __x, int __y) { return _STLP_VENDOR_CSTD::div(__x, __y); }
115 #endif
116 
117 #if defined(_MSC_EXTENSIONS) && defined(_STLP_MSVC) && (_STLP_MSVC <= 1300)
118 # define _STLP_RESTORE_FUNCTION_INTRINSIC
119 # pragma warning (push)
120 # pragma warning (disable: 4162)
121 # pragma function (abs)
122 #endif
123 
124 //HP-UX native lib has abs() and div() functions in global namespace
125 #if !defined (__SUNPRO_CC) && \
126  (!defined (__HP_aCC) || (__HP_aCC < 30000))
127 
128 //MSVC starting with .Net 2003 already define all math functions in global namespace:
129 # if !defined (__WATCOMC__) && \
130  (!defined (_STLP_MSVC_LIB) || (_STLP_MSVC_LIB < 1310) || defined (UNDER_CE))
131 inline long abs(long __x) { return _STLP_VENDOR_CSTD::labs(__x); }
132 # endif
133 
135 # if !defined (__WATCOMC__) && \
136  (!defined (_STLP_MSVC_LIB) || (_STLP_MSVC_LIB < 1400) || defined (_STLP_USING_PLATFORM_SDK_COMPILER) || defined (UNDER_CE))
137 inline _STLP_VENDOR_CSTD::ldiv_t div(long __x, long __y) { return _STLP_VENDOR_CSTD::ldiv(__x, __y); }
138 # endif
139 
140 #endif
141 
142 #if defined (_STLP_RESTORE_FUNCTION_INTRINSIC)
143 # pragma intrinsic (abs)
144 # pragma warning (pop)
145 # undef _STLP_RESTORE_FUNCTION_INTRINSIC
146 #endif
147 
148 #if defined (_STLP_LONG_LONG)
149 # if !defined (_STLP_NO_VENDOR_STDLIB_L)
150 # if !defined (__sun)
151 inline _STLP_LONG_LONG abs(_STLP_LONG_LONG __x) { return _STLP_VENDOR_CSTD::llabs(__x); }
152 inline lldiv_t div(_STLP_LONG_LONG __x, _STLP_LONG_LONG __y) { return _STLP_VENDOR_CSTD::lldiv(__x, __y); }
153 # else
155 inline lldiv_t div(_STLP_LONG_LONG __x, _STLP_LONG_LONG __y) { return ::lldiv(__x, __y); }
156 # endif
157 /*# else
158 inline _STLP_LONG_LONG abs(_STLP_LONG_LONG __x) { return __x < 0 ? -__x : __x; }*/
159 # endif
160 #endif
161 
162 /* C++ Standard is unclear about several call to 'using ::func' if new overloads
163  * of ::func appears between 2 successive 'using' calls. To avoid this potential
164  * problem we provide all abs overload before the 'using' call.
165  * Beware: This header inclusion has to be after all abs overload of this file.
166  * The first 'using ::abs' call is going to be in the other header.
167  */
168 #ifndef _STLP_INTERNAL_CMATH
169 # include <stl/_cmath.h>
170 #endif
171 
172 #if defined (_STLP_IMPORT_VENDOR_CSTD) && !defined (_STLP_NO_CSTD_FUNCTION_IMPORTS)
173 // ad hoc, don't replace with _STLP_VENDOR_CSTD::abs here! - ptr 2005-03-05
178 #endif
179 
180 #endif /* _STLP_INTERNAL_CSTDLIB */
#define realloc
Definition: debug_ros.c:6
#define wctomb(cp, wc)
Definition: wchar.h:161
UINT32 strtoul(const char *String, char **Terminator, UINT32 Base)
Definition: utclib.c:696
_Check_return_ double __cdecl strtod(_In_z_ const char *_Str, _Out_opt_ _Deref_post_z_ char **_EndPtr)
size_t __cdecl mbstowcs(_Out_writes_opt_z_(_MaxCount) wchar_t *_Dest, _In_z_ const char *_Source, _In_ size_t _MaxCount)
#define free
Definition: debug_ros.c:5
void __cdecl srand(_In_ unsigned int _Seed)
Definition: features.h:417
int __cdecl atexit(void(__cdecl *)(void))
Definition: atonexit.c:56
_Check_return_ _CRTIMP double __cdecl atof(_In_z_ const char *str)
_Check_return_ int __cdecl rand(void)
Definition: rand.c:10
void __cdecl qsort(_Inout_updates_bytes_(_NumOfElements *_SizeOfElements) void *_Base, _In_ size_t _NumOfElements, _In_ size_t _SizeOfElements, _In_ int(__cdecl *_PtFuncCompare)(const void *, const void *))
_Check_return_ long long __cdecl llabs(_In_ long long x)
Definition: stdlib.h:1444
#define _STLP_LONG_LONG
Definition: _apcc.h:12
int __cdecl system(_In_opt_z_ const char *_Command)
__kernel_size_t size_t
Definition: linux.h:237
_Check_return_ ldiv_t __cdecl ldiv(_In_ long _Numerator, _In_ long _Denominator)
_STLP_VENDOR_CSTD::ldiv_t div(long __x, long __y)
Definition: _cstdlib.h:137
#define mbtowc(wp, cp, len)
Definition: wchar.h:155
_Check_return_ __MINGW_EXTENSION lldiv_t __cdecl lldiv(_In_ long long, _In_ long long)
long abs(long __x)
Definition: _cstdlib.h:131
_Check_return_ long __cdecl atol(_In_z_ const char *_Str)
struct _div_t div_t
_Check_return_ char *__cdecl getenv(_In_z_ const char *_VarName)
_Check_return_ int __cdecl mblen(_In_reads_bytes_opt_(_MaxCount) _Pre_opt_z_ const char *_Ch, _In_ size_t _MaxCount)
#define _STLP_END_NAMESPACE
Definition: features.h:503
#define abort()
Definition: i386-dis.c:35
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
#define calloc
Definition: rosglue.h:14
_Check_return_ long __cdecl strtol(_In_z_ const char *_Str, _Out_opt_ _Deref_post_z_ char **_EndPtr, _In_ int _Radix)
#define malloc
Definition: debug_ros.c:4
#define _STLP_BEGIN_NAMESPACE
Definition: features.h:501
struct _ldiv_t ldiv_t
_Check_return_ long __cdecl labs(_In_ long x)
void exit(int exitcode)
Definition: _exit.c:33
size_t __cdecl wcstombs(_Out_writes_opt_z_(_MaxCount) char *_Dest, _In_z_ const wchar_t *_Source, _In_ size_t _MaxCount)
#define bsearch