2 * Copyright (c) 1997-1999
3 * Silicon Graphics Computer Systems, Inc.
11 * This material is provided "as is", with absolutely no warranty expressed
12 * or implied. Any use is at your own risk.
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.
21 #ifndef _STLP_INTERNAL_WINDOWS_H
22 #define _STLP_INTERNAL_WINDOWS_H
24 #if !defined (_STLP_PLATFORM)
25 # define _STLP_PLATFORM "Windows"
28 #if !defined (_STLP_BIG_ENDIAN) && !defined (_STLP_LITTLE_ENDIAN)
29 # if defined (_MIPSEB)
30 # define _STLP_BIG_ENDIAN 1
32 # if defined (__i386) || defined (_M_IX86) || defined (_M_ARM) || \
33 defined (__amd64__) || defined (_M_AMD64) || defined (__x86_64__) || \
35 # define _STLP_LITTLE_ENDIAN 1
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
42 # define _STLP_LITTLE_ENDIAN 1
45 #endif /* _STLP_BIG_ENDIAN */
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
57 # if !defined (WIN32_LEAN_AND_MEAN)
58 # define WIN32_LEAN_AND_MEAN
60 # if !defined (VC_EXTRALEAN)
63 /* Don't let windows.h define its min and max macros. */
64 # if !defined (NOMINMAX)
67 # if !defined (STRICT)
70 # if defined (_STLP_USE_MFC)
75 # if (_STLP_OUTERMOST_HEADER_ID == 0x100)
76 # undef _STLP_OUTERMOST_HEADER_ID
79 /* This section serves as a replacement for windows.h header. */
80 # if defined (__cplusplus)
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
91 # define _STLP_STDCALL _cdecl
93 # define _STLP_STDCALL __stdcall
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
102 /* Don't let windows.h define its min and max macros. */
103 # if !defined (NOMINMAX)
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
);
114 # if defined (_WIN64)
115 _STLP_IMPORT_DECLSPEC
void* _STLP_STDCALL
_InterlockedExchangePointer(void* volatile *, void*);
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 ...
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);
125 /* start of eMbedded Visual C++ specific section */
126 # include <stl/config/_native_headers.h>
128 /* Don't let windef.h define its min and max macros. */
129 # if !defined (NOMINMAX)
132 # include <windef.h> /* needed for basic windows types */
134 /** in SDKs generated with PB5, windef.h somehow includes headers which then
136 # if (_WIN32_WCE >= 0x500)
137 # define _STLP_NATIVE_SETJMP_H_INCLUDED
140 # ifndef _WINBASE_ /* winbase.h already included? */
141 long WINAPI
InterlockedIncrement(long*);
142 long WINAPI
InterlockedDecrement(long*);
143 long WINAPI
InterlockedExchange(long*, long);
146 # ifndef __WINDOWS__ /* windows.h already included? */
149 # include <winbase.h> /* needed for inline versions of Interlocked* functions */
154 # define MessageBox MessageBoxW
155 int WINAPI
MessageBoxW(HWND hWnd
, LPCWSTR lpText
, LPCWSTR lpCaption
, UINT uType
);
157 # define wvsprintf wvsprintfW
158 int WINAPI
wvsprintfW(LPWSTR
, LPCWSTR
, va_list ArgList
);
160 void WINAPI
ExitThread(DWORD dwExitCode
);
162 # if !defined (COREDLL)
163 # define _STLP_WCE_WINBASEAPI DECLSPEC_IMPORT
165 # define _STLP_WCE_WINBASEAPI
168 _STLP_WCE_WINBASEAPI
int WINAPI
169 MultiByteToWideChar(UINT CodePage
, DWORD dwFlags
, LPCSTR lpMultiByteStr
,
170 int cbMultiByte
, LPWSTR lpWideCharStr
, int cchWideChar
);
172 _STLP_WCE_WINBASEAPI UINT WINAPI
GetACP();
174 _STLP_WCE_WINBASEAPI BOOL WINAPI
TerminateProcess(HANDLE hProcess
, DWORD uExitCode
);
176 # define OutputDebugString OutputDebugStringW
177 void WINAPI
OutputDebugStringW(LPCWSTR
);
179 _STLP_WCE_WINBASEAPI
void WINAPI
Sleep(DWORD
);
181 # undef _STLP_WCE_WINBASEAPI
183 # endif /* !_MFC_VER */
185 # endif /* !__WINDOWS__ */
187 /* end of eMbedded Visual C++ specific section */
190 # if !defined (_STLP_WCE)
191 _STLP_IMPORT_DECLSPEC
void _STLP_STDCALL
OutputDebugStringA(const char* lpOutputString
);
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)
202 # if defined (__cplusplus)
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.
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
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
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
)));
232 return (void*)InterlockedExchange((long*)__a
, (long)__b
);
234 # if defined (_STLP_MSVC)
235 # pragma warning (pop)
240 # define STLPInterlockedExchangePointer _InterlockedExchangePointer
243 #endif /* _STLP_WINDOWS_H_INCLUDED */
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
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
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
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
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
273 # define _STLP_SIGNAL_RUNTIME_COMPATIBILITY building_for_at_least_windows98_but_library_built_for_windows95
276 # if defined (_STLP_WIN95_LIKE)
277 # define _STLP_CHECK_RUNTIME_COMPATIBILITY building_for_windows95_but_library_built_for_at_least_windows98
279 # define _STLP_CHECK_RUNTIME_COMPATIBILITY building_for_at_least_windows98_but_library_built_for_windows95
284 #if defined (__WIN16) || defined (WIN16) || defined (_WIN16)
291 #if defined(_STLP_WIN32)
292 # define _STLP_USE_WIN32_IO /* CreateFile/ReadFile/WriteFile */
296 #if defined(__MINGW32__) && !defined(_STLP_USE_STDIO_IO)
297 # define _STLP_USE_WIN32_IO /* CreateFile/ReadFile/WriteFile */
298 #endif /* __MINGW32__ */
301 # define _STLP_USE_UNIX_EMULATION_IO /* _open/_read/_write */
302 # define _STLP_LDOUBLE_80
305 #endif /* _STLP_INTERNAL_WINDOWS_H */