ReactOS 0.4.16-dev-321-g63bb46a
_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)
45namespace std {
46 typedef ::div_t div_t;
47 typedef ::ldiv_t ldiv_t;
48# ifdef __MSL_LONGLONG_SUPPORT__
49 typedef ::lldiv_t lldiv_t;
50# endif
51}
52#endif
53
54#ifdef _STLP_IMPORT_VENDOR_CSTD
56using _STLP_VENDOR_CSTD::div_t;
57using _STLP_VENDOR_CSTD::ldiv_t;
58using _STLP_VENDOR_CSTD::size_t;
59
60# ifndef _STLP_NO_CSTD_FUNCTION_IMPORTS
61# ifndef _STLP_WCE
62// these functions just don't exist on Windows CE
63using _STLP_VENDOR_CSTD::abort;
64using _STLP_VENDOR_CSTD::getenv;
65using _STLP_VENDOR_CSTD::mblen;
66using _STLP_VENDOR_CSTD::mbtowc;
67using _STLP_VENDOR_CSTD::system;
68using _STLP_VENDOR_CSTD::bsearch;
69# endif
70using _STLP_VENDOR_CSTD::atexit;
71using _STLP_VENDOR_CSTD::exit;
72using _STLP_VENDOR_CSTD::calloc;
73using _STLP_VENDOR_CSTD::free;
74using _STLP_VENDOR_CSTD::malloc;
75using _STLP_VENDOR_CSTD::realloc;
76using _STLP_VENDOR_CSTD::atof;
77using _STLP_VENDOR_CSTD::atoi;
78using _STLP_VENDOR_CSTD::atol;
79using _STLP_VENDOR_CSTD::mbstowcs;
80using _STLP_VENDOR_CSTD::strtod;
81using _STLP_VENDOR_CSTD::strtol;
82using _STLP_VENDOR_CSTD::strtoul;
83
84# if !(defined (_STLP_NO_NATIVE_WIDE_STREAMS) || defined (_STLP_NO_NATIVE_MBSTATE_T))
85using _STLP_VENDOR_CSTD::wcstombs;
86# ifndef _STLP_WCE
87using _STLP_VENDOR_CSTD::wctomb;
88# endif
89# endif
90using _STLP_VENDOR_CSTD::qsort;
91using _STLP_VENDOR_CSTD::labs;
92using _STLP_VENDOR_CSTD::ldiv;
93# if defined (_STLP_LONG_LONG) && !defined (_STLP_NO_VENDOR_STDLIB_L)
94# if !defined(__sun)
95using _STLP_VENDOR_CSTD::llabs;
96using _STLP_VENDOR_CSTD::lldiv_t;
97using _STLP_VENDOR_CSTD::lldiv;
98# else
99using ::llabs;
100using ::lldiv_t;
101using ::lldiv;
102# endif
103# endif
104using _STLP_VENDOR_CSTD::rand;
105using _STLP_VENDOR_CSTD::srand;
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.
113inline int abs(int __x) { return _STLP_VENDOR_CSTD::abs(__x); }
114inline _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))
131inline 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))
137inline _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)
151inline _STLP_LONG_LONG abs(_STLP_LONG_LONG __x) { return _STLP_VENDOR_CSTD::llabs(__x); }
152inline lldiv_t div(_STLP_LONG_LONG __x, _STLP_LONG_LONG __y) { return _STLP_VENDOR_CSTD::lldiv(__x, __y); }
153# else
154inline _STLP_LONG_LONG abs(_STLP_LONG_LONG __x) { return ::llabs(__x); }
155inline lldiv_t div(_STLP_LONG_LONG __x, _STLP_LONG_LONG __y) { return ::lldiv(__x, __y); }
156# endif
157/*# else
158inline _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
175using ::abs;
176using ::div;
178#endif
179
180#endif /* _STLP_INTERNAL_CSTDLIB */
#define _STLP_LONG_LONG
Definition: _apcc.h:12
_STLP_VENDOR_CSTD::ldiv_t div(long __x, long __y)
Definition: _cstdlib.h:137
#define abs(i)
Definition: fconv.c:206
#define _STLP_BEGIN_NAMESPACE
Definition: features.h:501
#define _STLP_END_NAMESPACE
Definition: features.h:503
struct _ldiv_t ldiv_t
struct _div_t div_t
Definition: features.h:417
Definition: stdlib.h:38
Definition: stdlib.h:43