]> git.buserror.net Git - polintos/scott/priv.git/blob - include/c++/stl/stl/config/_windows.h
Add STLport 5.1.4
[polintos/scott/priv.git] / include / c++ / stl / 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 /* _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.
33  */
34 #if !defined (_STLP_WIN32_VERSION)
35 #  if defined (WINVER)
36 #    define _STLP_WIN32_VERSION WINVER
37 #  elif defined (_WIN32_WINDOWS)
38 #    define _STLP_WIN32_VERSION _WIN32_WINDOWS
39 #  endif
40 #endif
41
42 #if !defined (_STLP_BIG_ENDIAN) && !defined (_STLP_LITTLE_ENDIAN)
43 #  if defined (_MIPSEB)
44 #    define _STLP_BIG_ENDIAN 1
45 #  endif
46 #  if defined (__i386) || defined (_M_IX86) || defined (_M_ARM) || \
47       defined (__amd64__) || defined (_M_AMD64) || defined (__x86_64__) || \
48       defined (__alpha__)
49 #    define _STLP_LITTLE_ENDIAN 1
50 #  endif
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
55 #    else
56 #      define _STLP_LITTLE_ENDIAN 1
57 #    endif
58 #  endif
59 #endif /* _STLP_BIG_ENDIAN */
60
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)
66 #      include <afx.h>
67 #    else
68 #      include <windows.h>
69 #    endif
70 #  else
71 /* This section serves as a replacement for windows.h header for Visual C++ */
72 #    if defined (__cplusplus)
73 extern "C" {
74 #    endif
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
82  * as a macro.
83  */
84 #      define STLPInterlockedExchangePointer _InterlockedExchangePointer
85 #      define _STLP_STDCALL
86 #    else
87 #      if defined (_MAC)
88 #        define _STLP_STDCALL _cdecl
89 #      else
90 #        define _STLP_STDCALL __stdcall
91 #      endif
92 #    endif
93
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*);
100 #      endif
101 _STLP_IMPORT_DECLSPEC long _STLP_STDCALL InterlockedExchangeAdd(long volatile *, long);
102 #    elif defined (_STLP_WCE)
103
104 /* start of eMbedded Visual C++ specific section */
105 #      include <windef.h> /* needed for basic windows types */
106
107        /** in SDKs generated with PB5, windef.h somehow includes headers which then
108        define setjmp. */
109 #      if (_WIN32_WCE >= 0x500)
110 #        define _STLP_NATIVE_SETJMP_H_INCLUDED
111 #      endif
112
113 #      ifndef _WINBASE_ /* winbase.h already included? */
114 long WINAPI InterlockedIncrement(long*);
115 long WINAPI InterlockedDecrement(long*);
116 long WINAPI InterlockedExchange(long*, long);
117 #      endif
118
119 #      ifndef __WINDOWS__ /* windows.h already included? */
120
121 #        if defined (x86)
122 #          include <winbase.h> /* needed for inline versions of Interlocked* functions */
123 #        endif
124
125 #        ifndef _MFC_VER
126
127 #          define MessageBox MessageBoxW
128 int WINAPI MessageBoxW(HWND hWnd, LPCWSTR lpText, LPCWSTR lpCaption, UINT uType);
129
130 #          define wvsprintf wvsprintfW
131 int WINAPI wvsprintfW(LPWSTR, LPCWSTR, va_list ArgList);
132
133 void WINAPI ExitThread(DWORD dwExitCode);
134
135 #          if !defined (COREDLL)
136 #            define _STLP_WCE_WINBASEAPI DECLSPEC_IMPORT
137 #          else
138 #            define _STLP_WCE_WINBASEAPI
139 #          endif
140
141 _STLP_WCE_WINBASEAPI int WINAPI
142 MultiByteToWideChar(UINT CodePage, DWORD dwFlags, LPCSTR lpMultiByteStr,
143                     int cbMultiByte, LPWSTR lpWideCharStr, int cchWideChar);
144
145 _STLP_WCE_WINBASEAPI UINT WINAPI GetACP();
146
147 _STLP_WCE_WINBASEAPI BOOL WINAPI TerminateProcess(HANDLE hProcess, DWORD uExitCode);
148
149 #          define OutputDebugString OutputDebugStringW
150 void WINAPI OutputDebugStringW(LPCWSTR);
151
152 _STLP_WCE_WINBASEAPI void WINAPI Sleep(DWORD);
153
154 #          undef _STLP_WCE_WINBASEAPI
155
156 #        endif /* !_MFC_VER */
157
158 #      endif /* !__WINDOWS__ */
159
160 /* end of eMbedded Visual C++ specific section */
161
162 #    else
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 ...
165  */
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);
169 #    endif
170
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:
174  */
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.
179  */
180 inline
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
186  */
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
190 #        endif
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)));
194 #        else
195   return (void*)InterlockedExchange((long*)__a, (long)__b);
196 #        endif
197 #        if defined (_STLP_MSVC)
198 #          pragma warning (pop)
199 #        endif
200 }
201 #      endif
202 #    endif
203
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);
207 #    endif
208
209 #    if defined (InterlockedIncrement)
210 #      pragma intrinsic(_InterlockedIncrement)
211 #      pragma intrinsic(_InterlockedDecrement)
212 #      pragma intrinsic(_InterlockedExchange)
213 #      pragma intrinsic(_InterlockedExchangePointer)
214 #    endif
215 #    if defined (__cplusplus)
216 } /* extern "C" */
217 #    endif
218
219 #  endif /* STL_MSVC __BORLANDC__ __ICL __WATCOMC__ __MINGW32__ __DMC__*/
220
221 #endif /* _STLP_WINDOWS_H_INCLUDED */
222
223 #endif /* _STLP_INTERNAL_WINDOWS_H */