ReactOS  0.4.14-dev-999-g61c8d34
_windows.h
Go to the documentation of this file.
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)
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 # include <windef.h>
103 
104 #ifndef InterlockedIncrement
109 #endif
110 # if defined (_WIN64)
112 # endif
113 # elif !defined (_STLP_WCE)
114 /* boris : for the latest SDK, you may actually need the other version of the declaration (above)
115  * even for earlier VC++ versions. There is no way to tell SDK versions apart, sorry ...
116  */
119 _STLP_IMPORT_DECLSPEC long _STLP_STDCALL InterlockedExchange(long volatile *, long);
120 # else
121 /* start of eMbedded Visual C++ specific section */
123 
124 /* Don't let windef.h define its min and max macros. */
125 # if !defined (NOMINMAX)
126 # define NOMINMAX
127 # endif
128 # include <windef.h> /* needed for basic windows types */
129 
132 # if (_WIN32_WCE >= 0x500)
133 # define _STLP_NATIVE_SETJMP_H_INCLUDED
134 # endif
135 
136 # ifndef _WINBASE_ /* winbase.h already included? */
137 long WINAPI InterlockedIncrement(long*);
138 long WINAPI InterlockedDecrement(long*);
139 long WINAPI InterlockedExchange(long*, long);
140 # endif
141 
142 # ifndef __WINDOWS__ /* windows.h already included? */
143 
144 # if defined (x86)
145 # include <winbase.h> /* needed for inline versions of Interlocked* functions */
146 # endif
147 
148 # ifndef _MFC_VER
149 
150 # define MessageBox MessageBoxW
151 int WINAPI MessageBoxW(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType);
152 
153 # define wvsprintf wvsprintfW
154 int WINAPI wvsprintfW(LPWSTR, LPCWSTR, va_list ArgList);
155 
156 void WINAPI ExitThread(DWORD dwExitCode);
157 
158 # if !defined (COREDLL)
159 # define _STLP_WCE_WINBASEAPI DECLSPEC_IMPORT
160 # else
161 # define _STLP_WCE_WINBASEAPI
162 # endif
163 
164 _STLP_WCE_WINBASEAPI int WINAPI
165 MultiByteToWideChar(UINT CodePage, DWORD dwFlags, LPCSTR lpMultiByteStr,
166  int cbMultiByte, LPWSTR lpWideCharStr, int cchWideChar);
167 
168 _STLP_WCE_WINBASEAPI UINT WINAPI GetACP();
169 
170 _STLP_WCE_WINBASEAPI BOOL WINAPI TerminateProcess(HANDLE hProcess, DWORD uExitCode);
171 
172 # define OutputDebugString OutputDebugStringW
174 
175 _STLP_WCE_WINBASEAPI void WINAPI Sleep(DWORD);
176 
177 # undef _STLP_WCE_WINBASEAPI
178 
179 # endif /* !_MFC_VER */
180 
181 # endif /* !__WINDOWS__ */
182 
183 /* end of eMbedded Visual C++ specific section */
184 # endif
185 
186 # if !defined (_STLP_WCE)
187 _STLP_IMPORT_DECLSPEC void _STLP_STDCALL OutputDebugStringA(const char* lpOutputString);
188 # endif
189 
190 # if defined (InterlockedIncrement) && defined(_MSC_VER)
191 # pragma intrinsic(_InterlockedIncrement)
192 # pragma intrinsic(_InterlockedDecrement)
193 # pragma intrinsic(_InterlockedExchange)
194 # if defined (_WIN64)
195 # pragma intrinsic(_InterlockedExchangePointer)
196 # endif
197 # endif
198 # if defined (__cplusplus)
199 } /* extern "C" */
200 # endif
201 
202 # endif
203 
204 /* Here we use a macro different than the InterlockedExchangePointer SDK one
205  * to avoid macro definition conflict. */
206 # if !defined (_WIN64)
207 /* Under 32 bits platform we rely on a simple InterlockedExchange call. */
208 # if defined (__cplusplus) && defined(__BUILDING_STLPORT)
209 /* We do not define this function if we are not in a C++ translation unit just
210  * because of the 'inline' keyword portability issue it would introduce. We will
211  * have to fix it the day we need this function for a C translation unit.
212  */
213 inline
214 void* _STLP_CALL STLPInterlockedExchangePointer(void* volatile* __a, void* __b) {
215 # if defined (_STLP_MSVC)
216 /* Here MSVC produces warning if 64 bits portability issue is activated.
217  * MSVC do not see that _STLP_ATOMIC_EXCHANGE_PTR is a macro which content
218  * is based on the platform, Win32 or Win64
219  */
220 # pragma warning (push)
221 # pragma warning (disable : 4311) // pointer truncation from void* to long
222 # pragma warning (disable : 4312) // conversion from long to void* of greater size
223 # endif
224 # if !defined (_STLP_NO_NEW_STYLE_CASTS)
225  return reinterpret_cast<void*>(InterlockedExchange(reinterpret_cast<long*>(const_cast<void**>(__a)),
226  reinterpret_cast<long>(__b)));
227 # else
228  return (void*)InterlockedExchange((long*)__a, (long)__b);
229 # endif
230 # if defined (_STLP_MSVC)
231 # pragma warning (pop)
232 # endif
233 }
234 # endif
235 # else
236 # define STLPInterlockedExchangePointer _InterlockedExchangePointer
237 # endif
238 
239 #endif /* _STLP_WINDOWS_H_INCLUDED */
240 
241 /* _STLP_WIN95_LIKE signal the Windows 95 OS or assimilated Windows OS version that
242  * has Interlockeded[Increment, Decrement] Win32 API functions not returning modified
243  * value.
244  */
245 #if (defined (WINVER) && (WINVER < 0x0410) && (!defined (_WIN32_WINNT) || (_WIN32_WINNT < 0x400))) || \
246  (!defined (WINVER) && (defined (_WIN32_WINDOWS) && (_WIN32_WINDOWS < 0x0410) || \
247  (defined (_WIN32_WINNT) && (_WIN32_WINNT < 0x400))))
248 # define _STLP_WIN95_LIKE
249 #endif
250 
251 /* Between Windows 95 (0x400) and later Windows OSes an API enhancement forces us
252  * to change _Refcount_Base internal struct. As _Refcount_base member methods might
253  * be partially inlined we need to check that STLport build/use are coherent. To do
254  * so we try to generate a link time error thanks to the following macro.
255  * This additional check is limited to old compilers that might still be used with
256  * Windows 95. */
257 #if (defined (_DEBUG) || defined (_STLP_DEBUG)) && \
258  (defined (_STLP_MSVC) && (_STLP_MSVC < 1310) || \
259  defined (__GNUC__) && (__GNUC__ < 3))
260 /* We invert symbol names based on macro detection, when building for Windows
261  * 95 we expose a
262  * building_for_windows95_or_previous_but_library_built_for_windows98_or_later
263  * function in order to have a more obvious link error message signaling how
264  * the lib has been built and how it is used. */
265 # if defined (__BUILDING_STLPORT)
266 # if defined (_STLP_WIN95_LIKE)
267 # define _STLP_SIGNAL_RUNTIME_COMPATIBILITY building_for_windows95_but_library_built_for_at_least_windows98
268 # else
269 # define _STLP_SIGNAL_RUNTIME_COMPATIBILITY building_for_at_least_windows98_but_library_built_for_windows95
270 # endif
271 # else
272 # if defined (_STLP_WIN95_LIKE)
273 # define _STLP_CHECK_RUNTIME_COMPATIBILITY building_for_windows95_but_library_built_for_at_least_windows98
274 # else
275 # define _STLP_CHECK_RUNTIME_COMPATIBILITY building_for_at_least_windows98_but_library_built_for_windows95
276 # endif
277 # endif
278 #endif
279 
280 #if defined (__WIN16) || defined (WIN16) || defined (_WIN16)
281 # define _STLP_WIN16
282 #else
283 # define _STLP_WIN32
284 #endif
285 
286 #if 0
287 #if defined(_STLP_WIN32)
288 # define _STLP_USE_WIN32_IO /* CreateFile/ReadFile/WriteFile */
289 #endif
290 #endif
291 
292 #if defined(__MINGW32__) && !defined(_STLP_USE_STDIO_IO)
293 # define _STLP_USE_WIN32_IO /* CreateFile/ReadFile/WriteFile */
294 #endif /* __MINGW32__ */
295 
296 #ifdef _STLP_WIN16
297 # define _STLP_USE_UNIX_EMULATION_IO /* _open/_read/_write */
298 # define _STLP_LDOUBLE_80
299 #endif
300 
301 #endif /* _STLP_INTERNAL_WINDOWS_H */
#define IN
Definition: typedefs.h:39
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
_STLP_IMPORT_DECLSPEC void _STLP_STDCALL OutputDebugStringA(const char *lpOutputString)
HWND hWnd
Definition: settings.c:17
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
_STLP_IMPORT_DECLSPEC long _STLP_STDCALL InterlockedExchange(long volatile *, long)
Definition: interlocked.c:10
void WINAPI SHIM_OBJ_NAME() OutputDebugStringW(LPCWSTR lpOutputString)
Definition: ignoredbgout.c:23
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
UINT WINAPI GetACP(VOID)
Definition: nls.c:2180
char * va_list
Definition: acmsvcex.h:78
VOID WINAPI ExitThread(IN DWORD uExitCode)
Definition: thread.c:364
const char * LPCSTR
Definition: xmlstorage.h:183
int WINAPI MessageBoxW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ UINT)
#define _STLP_STDCALL
Definition: _windows.h:93
#define WINAPI
Definition: msvc.h:6
unsigned long DWORD
Definition: ntddk_ex.h:95
void * _InterlockedExchangePointer(_Interlocked_operand_ void *volatile *_Target, void *_Value)
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
BOOL WINAPI TerminateProcess(IN HANDLE hProcess, IN UINT uExitCode)
Definition: proc.c:1532
unsigned int UINT
Definition: ndis.h:50
#define MultiByteToWideChar
Definition: compat.h:100
#define OUT
Definition: typedefs.h:40
int WINAPI wvsprintfW(_Out_ LPWSTR, _In_ _Printf_format_string_ LPCWSTR, _In_ va_list arglist)
_STLP_IMPORT_DECLSPEC long _STLP_STDCALL InterlockedDecrement(long volatile *)
#define _STLP_IMPORT_DECLSPEC
Definition: _bc.h:108
WCHAR * LPWSTR
Definition: xmlstorage.h:184
_STLP_IMPORT_DECLSPEC long _STLP_STDCALL InterlockedIncrement(long volatile *)
#define _STLP_CALL
Definition: _bc.h:131