[STLPORT]
[reactos.git] / reactos / include / c++ / stlport / stl / config / _windows.h
1 /*
2 * Copyright (c) 1997-1999
3 * Silicon Graphics Computer Systems, Inc.
4 *
5 * Copyright (c) 1999
6 * Boris Fomitchev
7 *
8 * Copyright (c) 2003
9 * Francois Dumont
10 *
11 * This material is provided "as is", with absolutely no warranty expressed
12 * or implied. Any use is at your own risk.
13 *
14 * Permission to use or copy this software for any purpose is hereby granted
15 * without fee, provided the above notices are retained on all copies.
16 * Permission to modify the code and to distribute modified code is granted,
17 * provided the above notices are retained, and a notice that the code was
18 * modified is included with the above copyright notice.
19 *
20 */
21 #ifndef _STLP_INTERNAL_WINDOWS_H
22 #define _STLP_INTERNAL_WINDOWS_H
23
24 #if !defined (_STLP_PLATFORM)
25 # define _STLP_PLATFORM "Windows"
26 #endif
27
28 #if !defined (_STLP_BIG_ENDIAN) && !defined (_STLP_LITTLE_ENDIAN)
29 # if defined (_MIPSEB)
30 # define _STLP_BIG_ENDIAN 1
31 # endif
32 # if defined (__i386) || defined (_M_IX86) || defined (_M_ARM) || \
33 defined (__amd64__) || defined (_M_AMD64) || defined (__x86_64__) || \
34 defined (__alpha__)
35 # define _STLP_LITTLE_ENDIAN 1
36 # endif
37 # if defined (__ia64__)
38 /* itanium allows both settings (for instance via gcc -mbig-endian) - hence a seperate check is required */
39 # if defined (__BIG_ENDIAN__)
40 # define _STLP_BIG_ENDIAN 1
41 # else
42 # define _STLP_LITTLE_ENDIAN 1
43 # endif
44 # endif
45 #endif /* _STLP_BIG_ENDIAN */
46
47 #if !defined (_STLP_WINDOWS_H_INCLUDED)
48 # define _STLP_WINDOWS_H_INCLUDED
49 # if defined (__BUILDING_STLPORT)
50 # include <stl/config/_native_headers.h>
51 /* Here we define _STLP_OUTERMOST_HEADER_ID to avoid indirect inclusion
52 * of STLport stuffs from C/C++ Standard headers exposed by STLport
53 * as configuration is not yet completed. */
54 # if !defined (_STLP_OUTERMOST_HEADER_ID)
55 # define _STLP_OUTERMOST_HEADER_ID 0x100
56 # endif
57 # if !defined (WIN32_LEAN_AND_MEAN)
58 # define WIN32_LEAN_AND_MEAN
59 # endif
60 # if !defined (VC_EXTRALEAN)
61 # define VC_EXTRALEAN
62 # endif
63 /* Don't let windows.h define its min and max macros. */
64 # if !defined (NOMINMAX)
65 # define NOMINMAX
66 # endif
67 # if !defined (STRICT)
68 # define STRICT
69 # endif
70 # if defined (_STLP_USE_MFC)
71 # include <afx.h>
72 # else
73 # include <windows.h>
74 # endif
75 # if (_STLP_OUTERMOST_HEADER_ID == 0x100)
76 # undef _STLP_OUTERMOST_HEADER_ID
77 # endif
78 # else
79 /* This section serves as a replacement for windows.h header. */
80 # if defined (__cplusplus)
81 extern "C" {
82 # endif
83 # if (defined (_M_AMD64) || defined (_M_IA64) || (!defined (_STLP_WCE) && defined (_M_MRX000)) || defined (_M_ALPHA) || \
84 (defined (_M_PPC) && (_STLP_MSVC_LIB >= 1000))) && !defined (RC_INVOKED)
85 # define InterlockedIncrement _InterlockedIncrement
86 # define InterlockedDecrement _InterlockedDecrement
87 # define InterlockedExchange _InterlockedExchange
88 # define _STLP_STDCALL
89 # else
90 # if defined (_MAC)
91 # define _STLP_STDCALL _cdecl
92 # else
93 # define _STLP_STDCALL __stdcall
94 # endif
95 # endif
96
97 # if defined (_STLP_NEW_PLATFORM_SDK) && !defined(_WDMDDK_)
98 /* Define WIN32_NO_STATUS to prevent status codes redefinitions */
99 # if !defined(WIN32_NO_STATUS)
100 # define WIN32_NO_STATUS
101 # endif
102 /* Don't let windows.h define its min and max macros. */
103 # if !defined (NOMINMAX)
104 # define NOMINMAX
105 # endif
106 # include <windef.h>
107
108 #ifndef InterlockedIncrement
109 _STLP_IMPORT_DECLSPEC LONG _STLP_STDCALL InterlockedIncrement(IN OUT LONG volatile *);
110 _STLP_IMPORT_DECLSPEC LONG _STLP_STDCALL InterlockedDecrement(IN OUT LONG volatile *);
111 _STLP_IMPORT_DECLSPEC LONG _STLP_STDCALL InterlockedExchange(IN OUT LONG volatile *, LONG);
112 _STLP_IMPORT_DECLSPEC void _STLP_STDCALL Sleep(DWORD);
113 #endif
114 # if defined (_WIN64)
115 _STLP_IMPORT_DECLSPEC void* _STLP_STDCALL _InterlockedExchangePointer(void* volatile *, void*);
116 # endif
117 # elif !defined (_STLP_WCE)
118 /* boris : for the latest SDK, you may actually need the other version of the declaration (above)
119 * even for earlier VC++ versions. There is no way to tell SDK versions apart, sorry ...
120 */
121 _STLP_IMPORT_DECLSPEC long _STLP_STDCALL InterlockedIncrement(long volatile *);
122 _STLP_IMPORT_DECLSPEC long _STLP_STDCALL InterlockedDecrement(long volatile *);
123 _STLP_IMPORT_DECLSPEC long _STLP_STDCALL InterlockedExchange(long volatile *, long);
124 # else
125 /* start of eMbedded Visual C++ specific section */
126 # include <stl/config/_native_headers.h>
127
128 /* Don't let windef.h define its min and max macros. */
129 # if !defined (NOMINMAX)
130 # define NOMINMAX
131 # endif
132 # include <windef.h> /* needed for basic windows types */
133
134 /** in SDKs generated with PB5, windef.h somehow includes headers which then
135 define setjmp. */
136 # if (_WIN32_WCE >= 0x500)
137 # define _STLP_NATIVE_SETJMP_H_INCLUDED
138 # endif
139
140 # ifndef _WINBASE_ /* winbase.h already included? */
141 long WINAPI InterlockedIncrement(long*);
142 long WINAPI InterlockedDecrement(long*);
143 long WINAPI InterlockedExchange(long*, long);
144 # endif
145
146 # ifndef __WINDOWS__ /* windows.h already included? */
147
148 # if defined (x86)
149 # include <winbase.h> /* needed for inline versions of Interlocked* functions */
150 # endif
151
152 # ifndef _MFC_VER
153
154 # define MessageBox MessageBoxW
155 int WINAPI MessageBoxW(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType);
156
157 # define wvsprintf wvsprintfW
158 int WINAPI wvsprintfW(LPWSTR, LPCWSTR, va_list ArgList);
159
160 void WINAPI ExitThread(DWORD dwExitCode);
161
162 # if !defined (COREDLL)
163 # define _STLP_WCE_WINBASEAPI DECLSPEC_IMPORT
164 # else
165 # define _STLP_WCE_WINBASEAPI
166 # endif
167
168 _STLP_WCE_WINBASEAPI int WINAPI
169 MultiByteToWideChar(UINT CodePage, DWORD dwFlags, LPCSTR lpMultiByteStr,
170 int cbMultiByte, LPWSTR lpWideCharStr, int cchWideChar);
171
172 _STLP_WCE_WINBASEAPI UINT WINAPI GetACP();
173
174 _STLP_WCE_WINBASEAPI BOOL WINAPI TerminateProcess(HANDLE hProcess, DWORD uExitCode);
175
176 # define OutputDebugString OutputDebugStringW
177 void WINAPI OutputDebugStringW(LPCWSTR);
178
179 _STLP_WCE_WINBASEAPI void WINAPI Sleep(DWORD);
180
181 # undef _STLP_WCE_WINBASEAPI
182
183 # endif /* !_MFC_VER */
184
185 # endif /* !__WINDOWS__ */
186
187 /* end of eMbedded Visual C++ specific section */
188 # endif
189
190 # if !defined (_STLP_WCE)
191 _STLP_IMPORT_DECLSPEC void _STLP_STDCALL OutputDebugStringA(const char* lpOutputString);
192 # endif
193
194 # if defined (InterlockedIncrement) && defined(_MSC_VER)
195 # pragma intrinsic(_InterlockedIncrement)
196 # pragma intrinsic(_InterlockedDecrement)
197 # pragma intrinsic(_InterlockedExchange)
198 # if defined (_WIN64)
199 # pragma intrinsic(_InterlockedExchangePointer)
200 # endif
201 # endif
202 # if defined (__cplusplus)
203 } /* extern "C" */
204 # endif
205
206 # endif
207
208 /* Here we use a macro different than the InterlockedExchangePointer SDK one
209 * to avoid macro definition conflict. */
210 # if !defined (_WIN64)
211 /* Under 32 bits platform we rely on a simple InterlockedExchange call. */
212 # if defined (__cplusplus) && defined(__BUILDING_STLPORT)
213 /* We do not define this function if we are not in a C++ translation unit just
214 * because of the 'inline' keyword portability issue it would introduce. We will
215 * have to fix it the day we need this function for a C translation unit.
216 */
217 inline
218 void* _STLP_CALL STLPInterlockedExchangePointer(void* volatile* __a, void* __b) {
219 # if defined (_STLP_MSVC)
220 /* Here MSVC produces warning if 64 bits portability issue is activated.
221 * MSVC do not see that _STLP_ATOMIC_EXCHANGE_PTR is a macro which content
222 * is based on the platform, Win32 or Win64
223 */
224 # pragma warning (push)
225 # pragma warning (disable : 4311) // pointer truncation from void* to long
226 # pragma warning (disable : 4312) // conversion from long to void* of greater size
227 # endif
228 # if !defined (_STLP_NO_NEW_STYLE_CASTS)
229 return reinterpret_cast<void*>(InterlockedExchange(reinterpret_cast<long*>(const_cast<void**>(__a)),
230 reinterpret_cast<long>(__b)));
231 # else
232 return (void*)InterlockedExchange((long*)__a, (long)__b);
233 # endif
234 # if defined (_STLP_MSVC)
235 # pragma warning (pop)
236 # endif
237 }
238 # endif
239 # else
240 # define STLPInterlockedExchangePointer _InterlockedExchangePointer
241 # endif
242
243 #endif /* _STLP_WINDOWS_H_INCLUDED */
244
245 /* _STLP_WIN95_LIKE signal the Windows 95 OS or assimilated Windows OS version that
246 * has Interlockeded[Increment, Decrement] Win32 API functions not returning modified
247 * value.
248 */
249 #if (defined (WINVER) && (WINVER < 0x0410) && (!defined (_WIN32_WINNT) || (_WIN32_WINNT < 0x400))) || \
250 (!defined (WINVER) && (defined (_WIN32_WINDOWS) && (_WIN32_WINDOWS < 0x0410) || \
251 (defined (_WIN32_WINNT) && (_WIN32_WINNT < 0x400))))
252 # define _STLP_WIN95_LIKE
253 #endif
254
255 /* Between Windows 95 (0x400) and later Windows OSes an API enhancement forces us
256 * to change _Refcount_Base internal struct. As _Refcount_base member methods might
257 * be partially inlined we need to check that STLport build/use are coherent. To do
258 * so we try to generate a link time error thanks to the following macro.
259 * This additional check is limited to old compilers that might still be used with
260 * Windows 95. */
261 #if (defined (_DEBUG) || defined (_STLP_DEBUG)) && \
262 (defined (_STLP_MSVC) && (_STLP_MSVC < 1310) || \
263 defined (__GNUC__) && (__GNUC__ < 3))
264 /* We invert symbol names based on macro detection, when building for Windows
265 * 95 we expose a
266 * building_for_windows95_or_previous_but_library_built_for_windows98_or_later
267 * function in order to have a more obvious link error message signaling how
268 * the lib has been built and how it is used. */
269 # if defined (__BUILDING_STLPORT)
270 # if defined (_STLP_WIN95_LIKE)
271 # define _STLP_SIGNAL_RUNTIME_COMPATIBILITY building_for_windows95_but_library_built_for_at_least_windows98
272 # else
273 # define _STLP_SIGNAL_RUNTIME_COMPATIBILITY building_for_at_least_windows98_but_library_built_for_windows95
274 # endif
275 # else
276 # if defined (_STLP_WIN95_LIKE)
277 # define _STLP_CHECK_RUNTIME_COMPATIBILITY building_for_windows95_but_library_built_for_at_least_windows98
278 # else
279 # define _STLP_CHECK_RUNTIME_COMPATIBILITY building_for_at_least_windows98_but_library_built_for_windows95
280 # endif
281 # endif
282 #endif
283
284 #if defined (__WIN16) || defined (WIN16) || defined (_WIN16)
285 # define _STLP_WIN16
286 #else
287 # define _STLP_WIN32
288 #endif
289
290 #if 0
291 #if defined(_STLP_WIN32)
292 # define _STLP_USE_WIN32_IO /* CreateFile/ReadFile/WriteFile */
293 #endif
294 #endif
295
296 #if defined(__MINGW32__) && !defined(_STLP_USE_STDIO_IO)
297 # define _STLP_USE_WIN32_IO /* CreateFile/ReadFile/WriteFile */
298 #endif /* __MINGW32__ */
299
300 #ifdef _STLP_WIN16
301 # define _STLP_USE_UNIX_EMULATION_IO /* _open/_read/_write */
302 # define _STLP_LDOUBLE_80
303 #endif
304
305 #endif /* _STLP_INTERNAL_WINDOWS_H */