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 /* _STLP_WIN32_VERSION is used to detect targetted Windows platforms as
29 * old ones are not supporting some Win32 functions that STLport use.
30 * Limited OSs are going up to and including Windows 98 so they can be
31 * detected using WINVER or _WIN32_WINDOWS macros, we do not have to use
32 * _WINNT_WINDOWS macro for the moment.
34 #if !defined (_STLP_WIN32_VERSION)
36 # define _STLP_WIN32_VERSION WINVER
37 # elif defined (_WIN32_WINDOWS)
38 # define _STLP_WIN32_VERSION _WIN32_WINDOWS
42 #if !defined (_STLP_BIG_ENDIAN) && !defined (_STLP_LITTLE_ENDIAN)
43 # if defined (_MIPSEB)
44 # define _STLP_BIG_ENDIAN 1
46 # if defined (__i386) || defined (_M_IX86) || defined (_M_ARM) || \
47 defined (__amd64__) || defined (_M_AMD64) || defined (__x86_64__) || \
49 # define _STLP_LITTLE_ENDIAN 1
51 # if defined (__ia64__)
52 /* itanium allows both settings (for instance via gcc -mbig-endian) - hence a seperate check is required */
53 # if defined (__BIG_ENDIAN__)
54 # define _STLP_BIG_ENDIAN 1
56 # define _STLP_LITTLE_ENDIAN 1
59 #endif /* _STLP_BIG_ENDIAN */
61 #if !defined (_STLP_WINDOWS_H_INCLUDED)
62 # define _STLP_WINDOWS_H_INCLUDED
63 # if !(defined ( _STLP_MSVC ) || defined (__BORLANDC__) || defined (__ICL) || defined (__WATCOMC__) || \
64 defined (__MINGW32__) || defined (__DMC__))
65 # if defined (_STLP_USE_MFC)
71 /* This section serves as a replacement for windows.h header for Visual C++ */
72 # if defined (__cplusplus)
75 # if (defined (_M_AMD64) || defined (_M_IA64) || (!defined (_STLP_WCE) && defined (_M_MRX000)) || defined (_M_ALPHA) || \
76 (defined (_M_PPC) && (_STLP_MSVC_LIB >= 1000))) && !defined (RC_INVOKED)
77 # define InterlockedIncrement _InterlockedIncrement
78 # define InterlockedDecrement _InterlockedDecrement
79 # define InterlockedExchange _InterlockedExchange
80 /* Here we use a different macro name than the InterlockedExchangePointer SDK function
81 * to avoid macro definition conflict as the SDK might already define InterlockedExchangePointer
84 # define STLPInterlockedExchangePointer _InterlockedExchangePointer
85 # define _STLP_STDCALL
88 # define _STLP_STDCALL _cdecl
90 # define _STLP_STDCALL __stdcall
94 # if defined (_STLP_NEW_PLATFORM_SDK)
95 _STLP_IMPORT_DECLSPEC long _STLP_STDCALL InterlockedIncrement(long volatile *);
96 _STLP_IMPORT_DECLSPEC long _STLP_STDCALL InterlockedDecrement(long volatile *);
97 _STLP_IMPORT_DECLSPEC long _STLP_STDCALL InterlockedExchange(long volatile *, long);
98 # if defined (STLPInterlockedExchangePointer)
99 _STLP_IMPORT_DECLSPEC void* _STLP_STDCALL STLPInterlockedExchangePointer(void* volatile *, void*);
101 _STLP_IMPORT_DECLSPEC long _STLP_STDCALL InterlockedExchangeAdd(long volatile *, long);
102 # elif defined (_STLP_WCE)
104 /* start of eMbedded Visual C++ specific section */
105 # include <windef.h> /* needed for basic windows types */
107 /** in SDKs generated with PB5, windef.h somehow includes headers which then
109 # if (_WIN32_WCE >= 0x500)
110 # define _STLP_NATIVE_SETJMP_H_INCLUDED
113 # ifndef _WINBASE_ /* winbase.h already included? */
114 long WINAPI InterlockedIncrement(long*);
115 long WINAPI InterlockedDecrement(long*);
116 long WINAPI InterlockedExchange(long*, long);
119 # ifndef __WINDOWS__ /* windows.h already included? */
122 # include <winbase.h> /* needed for inline versions of Interlocked* functions */
127 # define MessageBox MessageBoxW
128 int WINAPI MessageBoxW(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType);
130 # define wvsprintf wvsprintfW
131 int WINAPI wvsprintfW(LPWSTR, LPCWSTR, va_list ArgList);
133 void WINAPI ExitThread(DWORD dwExitCode);
135 # if !defined (COREDLL)
136 # define _STLP_WCE_WINBASEAPI DECLSPEC_IMPORT
138 # define _STLP_WCE_WINBASEAPI
141 _STLP_WCE_WINBASEAPI int WINAPI
142 MultiByteToWideChar(UINT CodePage, DWORD dwFlags, LPCSTR lpMultiByteStr,
143 int cbMultiByte, LPWSTR lpWideCharStr, int cchWideChar);
145 _STLP_WCE_WINBASEAPI UINT WINAPI GetACP();
147 _STLP_WCE_WINBASEAPI BOOL WINAPI TerminateProcess(HANDLE hProcess, DWORD uExitCode);
149 # define OutputDebugString OutputDebugStringW
150 void WINAPI OutputDebugStringW(LPCWSTR);
152 _STLP_WCE_WINBASEAPI void WINAPI Sleep(DWORD);
154 # undef _STLP_WCE_WINBASEAPI
156 # endif /* !_MFC_VER */
158 # endif /* !__WINDOWS__ */
160 /* end of eMbedded Visual C++ specific section */
163 /* boris : for the latest SDK, you may actually need the other version of the declaration (above)
164 * even for earlier VC++ versions. There is no way to tell SDK versions apart, sorry ...
166 _STLP_IMPORT_DECLSPEC long _STLP_STDCALL InterlockedIncrement(long*);
167 _STLP_IMPORT_DECLSPEC long _STLP_STDCALL InterlockedDecrement(long*);
168 _STLP_IMPORT_DECLSPEC long _STLP_STDCALL InterlockedExchange(long*, long);
171 # if !defined (STLPInterlockedExchangePointer)
172 /* This API function do not exist in the old platform SDK and is equivalent to
173 * InterlockedExchange on 32 bits platform:
175 # if defined (__cplusplus)
176 /* We do not define this function if we are not in a C++ translation unit just
177 * because of the inline portability issue it would introduce. We will have to
178 * fix it the day we need this function for a C translation unit.
181 void* _STLP_CALL STLPInterlockedExchangePointer(void* volatile* __a, void* __b) {
182 # if defined (_STLP_MSVC)
183 /* Here MSVC produces warning if 64 bits portability issue is activated.
184 * MSVC do not see that _STLP_ATOMIC_EXCHANGE_PTR is a macro which content
185 * is based on the platform, Win32 or Win64
187 # pragma warning (push)
188 # pragma warning (disable : 4311) // pointer truncation from void* to long
189 # pragma warning (disable : 4312) // conversion from long to void* of greater size
191 # if !defined (_STLP_NO_NEW_STYLE_CASTS)
192 return reinterpret_cast<void*>(InterlockedExchange(reinterpret_cast<long*>(const_cast<void**>(__a)),
193 reinterpret_cast<long>(__b)));
195 return (void*)InterlockedExchange((long*)__a, (long)__b);
197 # if defined (_STLP_MSVC)
198 # pragma warning (pop)
204 # if !defined (_STLP_WCE)
205 _STLP_IMPORT_DECLSPEC void _STLP_STDCALL Sleep(unsigned long);
206 _STLP_IMPORT_DECLSPEC void _STLP_STDCALL OutputDebugStringA(const char* lpOutputString);
209 # if defined (InterlockedIncrement)
210 # pragma intrinsic(_InterlockedIncrement)
211 # pragma intrinsic(_InterlockedDecrement)
212 # pragma intrinsic(_InterlockedExchange)
213 # pragma intrinsic(_InterlockedExchangePointer)
215 # if defined (__cplusplus)
219 # endif /* STL_MSVC __BORLANDC__ __ICL __WATCOMC__ __MINGW32__ __DMC__*/
221 #endif /* _STLP_WINDOWS_H_INCLUDED */
223 #endif /* _STLP_INTERNAL_WINDOWS_H */