Release 980628
[wine/gsoc-2012-control.git] / include / wintypes.h
blobb4804baad605d145932416e89c1ebb71e226307b
1 /*
2 * Basic types definitions
4 * Copyright 1996 Alexandre Julliard
5 */
7 #ifndef __WINE_WINTYPES_H
8 #define __WINE_WINTYPES_H
10 #ifdef __WINE__
11 # include "config.h"
12 # undef UNICODE
13 #endif /* __WINE__ */
15 /* Macros to map Winelib names to the correct implementation name */
16 /* depending on __WINE__ and UNICODE macros. */
17 /* Note that Winelib is purely Win32. */
19 #ifdef __WINE__
20 # define WINELIB_NAME(func) this is a syntax error
21 # define WINELIB_NAME_AW(func) this is a syntax error
22 #else /* __WINE__ */
23 # define WINELIB_NAME(func) func##32
24 # ifdef UNICODE
25 # define WINELIB_NAME_AW(func) func##32W
26 # else
27 # define WINELIB_NAME_AW(func) func##32A
28 # endif /* UNICODE */
29 #endif /* __WINE__ */
31 #ifdef __WINE__
32 # define DECL_WINELIB_TYPE(type) /* nothing */
33 # define DECL_WINELIB_TYPE_AW(type) /* nothing */
34 #else /* __WINE__ */
35 # define DECL_WINELIB_TYPE(type) typedef WINELIB_NAME(type) type;
36 # define DECL_WINELIB_TYPE_AW(type) typedef WINELIB_NAME_AW(type) type;
37 #endif /* __WINE__ */
40 /* Calling conventions definitions */
42 #ifdef __i386__
43 # if defined(__GNUC__) && (__GNUC__ == 2) && (__GNUC_MINOR__ >= 7)
44 # define __stdcall __attribute__((__stdcall__))
45 # define __cdecl __attribute__((__cdecl__))
46 # define __RESTORE_ES __asm__ __volatile__("pushl %ds\n\tpopl %es")
47 # else
48 # error You need gcc >= 2.7 to build Wine on a 386
49 # endif /* __GNUC__ */
50 #else /* __i386__ */
51 # define __stdcall
52 # define __cdecl
53 # define __RESTORE_ES
54 #endif /* __i386__ */
56 #define CALLBACK __stdcall
57 #define WINAPI __stdcall
58 #define APIPRIVATE __stdcall
59 #define PASCAL __stdcall
60 #define _pascal __stdcall
61 #define __export __stdcall
62 #define WINAPIV __cdecl
63 #define APIENTRY WINAPI
66 /* Standard data types. These are the same for emulator and library. */
68 typedef void VOID;
69 typedef short INT16;
70 typedef unsigned short UINT16;
71 typedef int INT32;
72 typedef unsigned int UINT32;
73 typedef unsigned short WORD;
74 typedef unsigned long DWORD;
75 typedef unsigned long ULONG;
76 typedef unsigned char BYTE;
77 typedef long LONG;
78 typedef char CHAR;
79 /* Some systems might have wchar_t, but we really need 16 bit characters */
80 typedef unsigned short WCHAR;
81 typedef unsigned short BOOL16;
82 typedef int BOOL32;
84 /* Integer types. These are the same for emulator and library. */
86 typedef UINT16 HANDLE16;
87 typedef UINT32 HANDLE32;
88 typedef UINT16 WPARAM16;
89 typedef UINT32 WPARAM32;
90 typedef LONG LPARAM;
91 typedef LONG HRESULT;
92 typedef LONG LRESULT;
93 typedef WORD ATOM;
94 typedef WORD CATCHBUF[9];
95 typedef WORD *LPCATCHBUF;
96 typedef DWORD ACCESS_MASK;
97 typedef ACCESS_MASK REGSAM;
98 typedef HANDLE32 HHOOK;
99 typedef HANDLE32 HKEY;
100 typedef DWORD LCID;
101 typedef WORD LANGID;
102 typedef DWORD LCTYPE;
103 typedef float FLOAT;
105 /* Pointers types. These are the same for emulator and library. */
107 typedef CHAR *LPSTR;
108 typedef const CHAR *LPCSTR;
109 typedef WCHAR *LPWSTR;
110 typedef const WCHAR *LPCWSTR;
111 typedef BYTE *LPBYTE;
112 typedef WORD *LPWORD;
113 typedef DWORD *LPDWORD;
114 typedef LONG *LPLONG;
115 typedef VOID *LPVOID;
116 typedef const VOID *LPCVOID;
117 typedef INT16 *LPINT16;
118 typedef UINT16 *LPUINT16;
119 typedef INT32 *LPINT32;
120 typedef UINT32 *LPUINT32;
121 typedef HKEY *LPHKEY;
122 typedef FLOAT *LPFLOAT;
124 /* Special case: a segmented pointer is just a pointer in the user's code. */
126 #ifdef __WINE__
127 typedef DWORD SEGPTR;
128 #else
129 typedef void* SEGPTR;
130 #endif /* __WINE__ */
132 /* Handle types that exist both in Win16 and Win32. */
134 #define DECLARE_HANDLE(a) typedef HANDLE16 a##16; typedef HANDLE32 a##32
135 DECLARE_HANDLE(HACCEL);
136 DECLARE_HANDLE(HBITMAP);
137 DECLARE_HANDLE(HBRUSH);
138 DECLARE_HANDLE(HCURSOR);
139 DECLARE_HANDLE(HDC);
140 DECLARE_HANDLE(HDROP);
141 DECLARE_HANDLE(HDRVR);
142 DECLARE_HANDLE(HDWP);
143 DECLARE_HANDLE(HENHMETAFILE);
144 DECLARE_HANDLE(HFILE);
145 DECLARE_HANDLE(HFONT);
146 DECLARE_HANDLE(HGDIOBJ);
147 DECLARE_HANDLE(HGLOBAL);
148 DECLARE_HANDLE(HICON);
149 DECLARE_HANDLE(HINSTANCE);
150 DECLARE_HANDLE(HLOCAL);
151 DECLARE_HANDLE(HMENU);
152 DECLARE_HANDLE(HMETAFILE);
153 DECLARE_HANDLE(HMIDI);
154 DECLARE_HANDLE(HMIDIIN);
155 DECLARE_HANDLE(HMIDIOUT);
156 DECLARE_HANDLE(HMIXER);
157 DECLARE_HANDLE(HMIXEROBJ);
158 DECLARE_HANDLE(HMMIO);
159 DECLARE_HANDLE(HMODULE);
160 DECLARE_HANDLE(HPALETTE);
161 DECLARE_HANDLE(HPEN);
162 DECLARE_HANDLE(HQUEUE);
163 DECLARE_HANDLE(HRGN);
164 DECLARE_HANDLE(HRSRC);
165 DECLARE_HANDLE(HTASK);
166 DECLARE_HANDLE(HWAVE);
167 DECLARE_HANDLE(HWAVEIN);
168 DECLARE_HANDLE(HWAVEOUT);
169 DECLARE_HANDLE(HWND);
170 DECLARE_HANDLE(HKL);
171 #undef DECLARE_HANDLE
173 /* Callback function pointers types */
175 typedef LRESULT (CALLBACK *DLGPROC16)(HWND16,UINT16,WPARAM16,LPARAM);
176 typedef LRESULT (CALLBACK *DLGPROC32)(HWND32,UINT32,WPARAM32,LPARAM);
177 DECL_WINELIB_TYPE(DLGPROC)
178 typedef LRESULT (CALLBACK *DRIVERPROC16)(DWORD,HDRVR16,UINT16,LPARAM,LPARAM);
179 typedef LRESULT (CALLBACK *DRIVERPROC32)(DWORD,HDRVR32,UINT32,LPARAM,LPARAM);
180 DECL_WINELIB_TYPE(DRIVERPROC)
181 typedef INT16 (CALLBACK *EDITWORDBREAKPROC16)(LPSTR,INT16,INT16,INT16);
182 typedef INT32 (CALLBACK *EDITWORDBREAKPROC32A)(LPSTR,INT32,INT32,INT32);
183 typedef INT32 (CALLBACK *EDITWORDBREAKPROC32W)(LPWSTR,INT32,INT32,INT32);
184 DECL_WINELIB_TYPE_AW(EDITWORDBREAKPROC)
185 typedef LRESULT (CALLBACK *FARPROC16)();
186 typedef LRESULT (CALLBACK *FARPROC32)();
187 DECL_WINELIB_TYPE(FARPROC)
188 typedef INT16 (CALLBACK *GOBJENUMPROC16)(SEGPTR,LPARAM);
189 typedef INT32 (CALLBACK *GOBJENUMPROC32)(LPVOID,LPARAM);
190 DECL_WINELIB_TYPE(GOBJENUMPROC)
191 typedef BOOL16 (CALLBACK *GRAYSTRINGPROC16)(HDC16,LPARAM,INT16);
192 typedef BOOL32 (CALLBACK *GRAYSTRINGPROC32)(HDC32,LPARAM,INT32);
193 DECL_WINELIB_TYPE(GRAYSTRINGPROC)
194 typedef LRESULT (CALLBACK *HOOKPROC16)(INT16,WPARAM16,LPARAM);
195 typedef LRESULT (CALLBACK *HOOKPROC32)(INT32,WPARAM32,LPARAM);
196 DECL_WINELIB_TYPE(HOOKPROC)
197 typedef VOID (CALLBACK *LINEDDAPROC16)(INT16,INT16,LPARAM);
198 typedef VOID (CALLBACK *LINEDDAPROC32)(INT32,INT32,LPARAM);
199 DECL_WINELIB_TYPE(LINEDDAPROC)
200 typedef BOOL16 (CALLBACK *PROPENUMPROC16)(HWND16,SEGPTR,HANDLE16);
201 typedef BOOL32 (CALLBACK *PROPENUMPROC32A)(HWND32,LPCSTR,HANDLE32);
202 typedef BOOL32 (CALLBACK *PROPENUMPROC32W)(HWND32,LPCWSTR,HANDLE32);
203 DECL_WINELIB_TYPE_AW(PROPENUMPROC)
204 typedef BOOL32 (CALLBACK *PROPENUMPROCEX32A)(HWND32,LPCSTR,HANDLE32,LPARAM);
205 typedef BOOL32 (CALLBACK *PROPENUMPROCEX32W)(HWND32,LPCWSTR,HANDLE32,LPARAM);
206 DECL_WINELIB_TYPE_AW(PROPENUMPROCEX)
207 typedef VOID (CALLBACK *TIMERPROC16)(HWND16,UINT16,UINT16,DWORD);
208 typedef VOID (CALLBACK *TIMERPROC32)(HWND32,UINT32,UINT32,DWORD);
209 DECL_WINELIB_TYPE(TIMERPROC)
210 typedef LRESULT (CALLBACK *WNDENUMPROC16)(HWND16,LPARAM);
211 typedef LRESULT (CALLBACK *WNDENUMPROC32)(HWND32,LPARAM);
212 DECL_WINELIB_TYPE(WNDENUMPROC)
213 typedef LRESULT (CALLBACK *WNDPROC16)(HWND16,UINT16,WPARAM16,LPARAM);
214 typedef LRESULT (CALLBACK *WNDPROC32)(HWND32,UINT32,WPARAM32,LPARAM);
215 DECL_WINELIB_TYPE(WNDPROC)
217 /* TCHAR data types definitions for Winelib. */
218 /* These types are _not_ defined for the emulator, because they */
219 /* depend on the UNICODE macro that only exists in user's code. */
221 #ifndef __WINE__
222 # ifdef UNICODE
223 typedef WCHAR TCHAR;
224 typedef LPWSTR LPTSTR;
225 typedef LPCWSTR LPCTSTR;
226 # else /* UNICODE */
227 typedef CHAR TCHAR;
228 typedef LPSTR LPTSTR;
229 typedef LPCSTR LPCTSTR;
230 # endif /* UNICODE */
231 #endif /* __WINE__ */
233 /* Data types specific to the library. These do _not_ exist in the emulator. */
235 DECL_WINELIB_TYPE(INT)
236 DECL_WINELIB_TYPE(LPINT)
237 DECL_WINELIB_TYPE(LPUINT)
238 DECL_WINELIB_TYPE(UINT)
239 DECL_WINELIB_TYPE(BOOL)
240 DECL_WINELIB_TYPE(WPARAM)
242 DECL_WINELIB_TYPE(HACCEL)
243 DECL_WINELIB_TYPE(HANDLE)
244 DECL_WINELIB_TYPE(HBITMAP)
245 DECL_WINELIB_TYPE(HBRUSH)
246 DECL_WINELIB_TYPE(HCURSOR)
247 DECL_WINELIB_TYPE(HDC)
248 DECL_WINELIB_TYPE(HDROP)
249 DECL_WINELIB_TYPE(HDRVR)
250 DECL_WINELIB_TYPE(HDWP)
251 DECL_WINELIB_TYPE(HENHMETAFILE)
252 DECL_WINELIB_TYPE(HFILE)
253 DECL_WINELIB_TYPE(HFONT)
254 DECL_WINELIB_TYPE(HGDIOBJ)
255 DECL_WINELIB_TYPE(HGLOBAL)
256 DECL_WINELIB_TYPE(HICON)
257 DECL_WINELIB_TYPE(HINSTANCE)
258 DECL_WINELIB_TYPE(HLOCAL)
259 DECL_WINELIB_TYPE(HMENU)
260 DECL_WINELIB_TYPE(HMETAFILE)
261 DECL_WINELIB_TYPE(HMIDI)
262 DECL_WINELIB_TYPE(HMIDIIN)
263 DECL_WINELIB_TYPE(HMIDIOUT)
264 DECL_WINELIB_TYPE(HMMIO)
265 DECL_WINELIB_TYPE(HMODULE)
266 DECL_WINELIB_TYPE(HPALETTE)
267 DECL_WINELIB_TYPE(HPEN)
268 DECL_WINELIB_TYPE(HQUEUE)
269 DECL_WINELIB_TYPE(HRGN)
270 DECL_WINELIB_TYPE(HRSRC)
271 DECL_WINELIB_TYPE(HTASK)
272 DECL_WINELIB_TYPE(HWAVE)
273 DECL_WINELIB_TYPE(HWAVEIN)
274 DECL_WINELIB_TYPE(HWAVEOUT)
275 DECL_WINELIB_TYPE(HWND)
277 /* Misc. constants. */
279 #ifdef FALSE
280 #undef FALSE
281 #endif
282 #define FALSE 0
284 #ifdef TRUE
285 #undef TRUE
286 #endif
287 #define TRUE 1
289 #ifdef NULL
290 #undef NULL
291 #endif
292 #define NULL 0
294 /* Define some empty macros for compatibility with Windows code. */
296 #ifndef __WINE__
297 #define NEAR
298 #define FAR
299 #define _far
300 #define _near
301 #endif /* __WINE__ */
303 /* Macro for structure packing. */
305 #ifdef __GNUC__
306 #define WINE_PACKED __attribute__ ((packed))
307 #else
308 #define WINE_PACKED /* nothing */
309 #endif
311 /* Macros to split words and longs. */
313 #define LOBYTE(w) ((BYTE)(WORD)(w))
314 #define HIBYTE(w) ((BYTE)((WORD)(w) >> 8))
316 #define LOWORD(l) ((WORD)(DWORD)(l))
317 #define HIWORD(l) ((WORD)((DWORD)(l) >> 16))
319 #define SLOWORD(l) ((INT16)(LONG)(l))
320 #define SHIWORD(l) ((INT16)((LONG)(l) >> 16))
322 #define MAKELONG(low,high) ((LONG)(((WORD)(low)) | \
323 (((DWORD)((WORD)(high))) << 16)))
324 #define MAKELPARAM(low,high) ((LPARAM)MAKELONG(low,high))
325 #define MAKEWPARAM(low,high) ((WPARAM32)MAKELONG(low,high))
326 #define MAKEINTATOM(atom) ((LPCSTR)MAKELONG((atom),0))
328 #define SELECTOROF(ptr) (HIWORD(ptr))
329 #define OFFSETOF(ptr) (LOWORD(ptr))
331 /* Macros to access unaligned or wrong-endian WORDs and DWORDs. */
333 #ifdef __i386__
334 #define PUT_WORD(ptr,w) (*(WORD *)(ptr) = (w))
335 #define GET_WORD(ptr) (*(WORD *)(ptr))
336 #define PUT_DWORD(ptr,dw) (*(DWORD *)(ptr) = (dw))
337 #define GET_DWORD(ptr) (*(DWORD *)(ptr))
338 #else
339 #define PUT_WORD(ptr,w) (*(BYTE *)(ptr) = LOBYTE(w), \
340 *((BYTE *)(ptr) + 1) = HIBYTE(w))
341 #define GET_WORD(ptr) ((WORD)(*(BYTE *)(ptr) | \
342 (WORD)(*((BYTE *)(ptr)+1) << 8)))
343 #define PUT_DWORD(ptr,dw) (PUT_WORD((ptr),LOWORD(dw)), \
344 PUT_WORD((WORD *)(ptr)+1,HIWORD(dw)))
345 #define GET_DWORD(ptr) ((DWORD)(GET_WORD(ptr) | \
346 ((DWORD)GET_WORD((WORD *)(ptr)+1) << 16)))
347 #endif /* __i386__ */
349 /* MIN and MAX macros */
351 #ifdef MAX
352 #undef MAX
353 #endif
354 #define MAX(a,b) (((a) > (b)) ? (a) : (b))
356 #ifdef MIN
357 #undef MIN
358 #endif
359 #define MIN(a,b) (((a) < (b)) ? (a) : (b))
361 /* Winelib run-time flag */
363 #ifdef __WINE__
364 extern int __winelib;
365 #endif /* __WINE__ */
367 #endif /* __WINE_WINTYPES_H */