2 * Basic types definitions
4 * Copyright 1996 Alexandre Julliard
7 #ifndef __WINE_WINDEF_H
8 #define __WINE_WINDEF_H
19 /* Misc. constants. */
36 /* Macros to map Winelib names to the correct implementation name */
37 /* depending on __WINE__ and UNICODE macros. */
38 /* Note that Winelib is purely Win32. */
41 # define WINELIB_NAME_AW(func) this_is_a_syntax_error this_is_a_syntax_error
44 # define WINELIB_NAME_AW(func) func##W
46 # define WINELIB_NAME_AW(func) func##A
51 # define DECL_WINELIB_TYPE_AW(type) /* nothing */
53 # define DECL_WINELIB_TYPE_AW(type) typedef WINELIB_NAME_AW(type) type;
56 #ifndef NONAMELESSSTRUCT
57 # if defined(__WINE__) || !defined(_FORCENAMELESSSTRUCT)
58 # define NONAMELESSSTRUCT
60 #endif /* !defined(NONAMELESSSTRUCT) */
62 #ifndef NONAMELESSUNION
63 # if defined(__WINE__) || !defined(_FORCENAMELESSUNION) || !defined(__cplusplus)
64 # define NONAMELESSUNION
66 #endif /* !defined(NONAMELESSUNION) */
68 #ifndef NONAMELESSSTRUCT
69 #define DUMMYSTRUCTNAME
70 #define DUMMYSTRUCTNAME1
71 #define DUMMYSTRUCTNAME2
72 #define DUMMYSTRUCTNAME3
73 #define DUMMYSTRUCTNAME4
74 #define DUMMYSTRUCTNAME5
75 #else /* !defined(NONAMELESSSTRUCT) */
76 #define DUMMYSTRUCTNAME s
77 #define DUMMYSTRUCTNAME1 s1
78 #define DUMMYSTRUCTNAME2 s2
79 #define DUMMYSTRUCTNAME3 s3
80 #define DUMMYSTRUCTNAME4 s4
81 #define DUMMYSTRUCTNAME5 s5
82 #endif /* !defined(NONAMELESSSTRUCT) */
84 #ifndef NONAMELESSUNION
85 #define DUMMYUNIONNAME
86 #define DUMMYUNIONNAME1
87 #define DUMMYUNIONNAME2
88 #define DUMMYUNIONNAME3
89 #define DUMMYUNIONNAME4
90 #define DUMMYUNIONNAME5
91 #else /* !defined(NONAMELESSUNION) */
92 #define DUMMYUNIONNAME u
93 #define DUMMYUNIONNAME1 u1
94 #define DUMMYUNIONNAME2 u2
95 #define DUMMYUNIONNAME3 u3
96 #define DUMMYUNIONNAME4 u4
97 #define DUMMYUNIONNAME5 u5
98 #endif /* !defined(NONAMELESSUNION) */
100 /* Calling conventions definitions */
103 # if defined(__GNUC__) && ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 7)))
104 # define __stdcall __attribute__((__stdcall__))
105 # define __cdecl __attribute__((__cdecl__))
106 # define __RESTORE_ES __asm__ __volatile__("pushl %ds\n\tpopl %es")
108 # error You need gcc >= 2.7 to build Wine on a 386
109 # endif /* __GNUC__ */
113 # define __RESTORE_ES
114 #endif /* __i386__ */
116 #define CALLBACK __stdcall
117 #define WINAPI __stdcall
118 #define APIPRIVATE __stdcall
119 #define PASCAL __stdcall
120 #define pascal __stdcall
121 #define _pascal __stdcall
122 #define _stdcall __stdcall
123 #define _fastcall __stdcall
124 #define __export __stdcall
125 #define CDECL __cdecl
126 #define _CDECL __cdecl
127 #define cdecl __cdecl
128 #define _cdecl __cdecl
129 #define WINAPIV __cdecl
130 #define APIENTRY WINAPI
132 #define __declspec(x)
138 /* Standard data types. These are the same for emulator and library. */
142 typedef unsigned short UINT16;
144 typedef unsigned int UINT;
145 typedef unsigned short WORD;
146 typedef unsigned long DWORD;
147 typedef unsigned long ULONG;
148 typedef unsigned char BYTE;
151 typedef unsigned short USHORT;
153 typedef unsigned char UCHAR;
154 /* Some systems might have wchar_t, but we really need 16 bit characters */
155 typedef unsigned short WCHAR;
156 typedef unsigned short BOOL16;
159 typedef double DOUBLE;
160 typedef double LONGLONG;
161 typedef double ULONGLONG;
163 /* FIXME: Wine does not compile with strict on, therefore strict
164 * handles are presently only usable on machines where sizeof(UINT) ==
165 * sizeof(void*). HANDLEs are supposed to be void* but a large amount
166 * of WINE code operates on HANDLES as if they are UINTs. So to WINE
167 * they exist as UINTs but to the Winelib user who turns on strict,
168 * they exist as void*. If there is a size difference between UINT and
169 * void* then things get ugly. */
171 typedef UINT16 HANDLE16;
172 typedef VOID* HANDLE;
174 typedef UINT16 HANDLE16;
178 typedef HANDLE16 *LPHANDLE16;
179 typedef HANDLE *LPHANDLE;
181 /* Integer types. These are the same for emulator and library. */
182 typedef UINT16 WPARAM16;
185 typedef LONG HRESULT;
186 typedef LONG LRESULT;
188 typedef WORD CATCHBUF[9];
189 typedef WORD *LPCATCHBUF;
190 typedef HANDLE HHOOK;
191 typedef HANDLE HMONITOR;
194 typedef DWORD LCTYPE;
197 /* Pointers types. These are the same for emulator and library. */
200 typedef const void *PCVOID;
202 typedef UCHAR *PUCHAR;
205 typedef ULONG *PULONG;
207 typedef DWORD *PDWORD;
208 /* common win32 types */
211 typedef const CHAR *LPCSTR;
212 typedef const CHAR *PCSTR;
213 typedef WCHAR *LPWSTR;
214 typedef WCHAR *PWSTR;
215 typedef const WCHAR *LPCWSTR;
216 typedef const WCHAR *PCWSTR;
217 typedef BYTE *LPBYTE;
218 typedef WORD *LPWORD;
219 typedef DWORD *LPDWORD;
220 typedef LONG *LPLONG;
221 typedef VOID *LPVOID;
222 typedef const VOID *LPCVOID;
223 typedef INT16 *LPINT16;
224 typedef UINT16 *LPUINT16;
228 typedef UINT *LPUINT;
229 typedef FLOAT *PFLOAT;
230 typedef FLOAT *LPFLOAT;
232 typedef BOOL *LPBOOL;
234 /* Special case: a segmented pointer is just a pointer in the user's code. */
237 typedef DWORD SEGPTR;
239 typedef void* SEGPTR;
240 #endif /* __WINE__ */
242 /* Handle types that exist both in Win16 and Win32. */
245 #define DECLARE_HANDLE(a) \
246 typedef HANDLE16 a##16; \
247 typedef a##16 *P##a##16; \
248 typedef a##16 *NP##a##16; \
249 typedef a##16 *LP##a##16; \
250 typedef struct a##__ { int unused; } *a; \
254 #define DECLARE_HANDLE(a) \
255 typedef HANDLE16 a##16; \
256 typedef a##16 *P##a##16; \
257 typedef a##16 *NP##a##16; \
258 typedef a##16 *LP##a##16; \
264 DECLARE_HANDLE(HACMDRIVERID);
265 DECLARE_HANDLE(HACMDRIVER);
266 DECLARE_HANDLE(HACMOBJ);
267 DECLARE_HANDLE(HACMSTREAM);
268 DECLARE_HANDLE(HMETAFILEPICT);
270 DECLARE_HANDLE(HACCEL);
271 DECLARE_HANDLE(HBITMAP);
272 DECLARE_HANDLE(HBRUSH);
273 DECLARE_HANDLE(HCOLORSPACE);
274 DECLARE_HANDLE(HCURSOR);
276 DECLARE_HANDLE(HDROP);
277 DECLARE_HANDLE(HDRVR);
278 DECLARE_HANDLE(HDWP);
279 DECLARE_HANDLE(HENHMETAFILE);
280 DECLARE_HANDLE(HFILE);
281 DECLARE_HANDLE(HFONT);
282 DECLARE_HANDLE(HICON);
283 DECLARE_HANDLE(HINSTANCE);
284 DECLARE_HANDLE(HKEY);
285 DECLARE_HANDLE(HMENU);
286 DECLARE_HANDLE(HMETAFILE);
287 DECLARE_HANDLE(HMIDI);
288 DECLARE_HANDLE(HMIDIIN);
289 DECLARE_HANDLE(HMIDIOUT);
290 DECLARE_HANDLE(HMIDISTRM);
291 DECLARE_HANDLE(HMIXER);
292 DECLARE_HANDLE(HMIXEROBJ);
293 DECLARE_HANDLE(HMMIO);
294 DECLARE_HANDLE(HPALETTE);
295 DECLARE_HANDLE(HPEN);
296 DECLARE_HANDLE(HQUEUE);
297 DECLARE_HANDLE(HRGN);
298 DECLARE_HANDLE(HRSRC);
299 DECLARE_HANDLE(HTASK);
300 DECLARE_HANDLE(HWAVE);
301 DECLARE_HANDLE(HWAVEIN);
302 DECLARE_HANDLE(HWAVEOUT);
303 DECLARE_HANDLE(HWINSTA);
304 DECLARE_HANDLE(HDESK);
305 DECLARE_HANDLE(HWND);
308 DECLARE_HANDLE(HRASCONN);
309 #undef DECLARE_HANDLE
311 /* Handle types that must remain interchangeable even with strict on */
313 typedef HINSTANCE16 HMODULE16;
314 typedef HINSTANCE HMODULE;
315 typedef HANDLE16 HGDIOBJ16;
316 typedef HANDLE16 HGLOBAL16;
317 typedef HANDLE16 HLOCAL16;
318 typedef HANDLE HGDIOBJ;
319 typedef HANDLE HGLOBAL;
320 typedef HANDLE HLOCAL;
322 /* Callback function pointers types */
324 typedef BOOL (CALLBACK* DATEFMT_ENUMPROCA)(LPSTR);
325 typedef BOOL (CALLBACK* DATEFMT_ENUMPROCW)(LPWSTR);
326 DECL_WINELIB_TYPE_AW(DATEFMT_ENUMPROC)
327 typedef BOOL16 (CALLBACK *DLGPROC16)(HWND16,UINT16,WPARAM16,LPARAM);
328 typedef BOOL (CALLBACK *DLGPROC)(HWND,UINT,WPARAM,LPARAM);
329 typedef LRESULT (CALLBACK *DRIVERPROC16)(DWORD,HDRVR16,UINT16,LPARAM,LPARAM);
330 typedef LRESULT (CALLBACK *DRIVERPROC)(DWORD,HDRVR,UINT,LPARAM,LPARAM);
331 typedef INT16 (CALLBACK *EDITWORDBREAKPROC16)(LPSTR,INT16,INT16,INT16);
332 typedef INT (CALLBACK *EDITWORDBREAKPROCA)(LPSTR,INT,INT,INT);
333 typedef INT (CALLBACK *EDITWORDBREAKPROCW)(LPWSTR,INT,INT,INT);
334 DECL_WINELIB_TYPE_AW(EDITWORDBREAKPROC)
335 typedef LRESULT (CALLBACK *FARPROC16)();
336 typedef LRESULT (CALLBACK *FARPROC)();
337 typedef INT16 (CALLBACK *PROC16)();
338 typedef INT (CALLBACK *PROC)();
339 typedef BOOL16 (CALLBACK *GRAYSTRINGPROC16)(HDC16,LPARAM,INT16);
340 typedef BOOL (CALLBACK *GRAYSTRINGPROC)(HDC,LPARAM,INT);
341 typedef LRESULT (CALLBACK *HOOKPROC16)(INT16,WPARAM16,LPARAM);
342 typedef LRESULT (CALLBACK *HOOKPROC)(INT,WPARAM,LPARAM);
343 typedef BOOL16 (CALLBACK *PROPENUMPROC16)(HWND16,SEGPTR,HANDLE16);
344 typedef BOOL (CALLBACK *PROPENUMPROCA)(HWND,LPCSTR,HANDLE);
345 typedef BOOL (CALLBACK *PROPENUMPROCW)(HWND,LPCWSTR,HANDLE);
346 DECL_WINELIB_TYPE_AW(PROPENUMPROC)
347 typedef BOOL (CALLBACK *PROPENUMPROCEXA)(HWND,LPCSTR,HANDLE,LPARAM);
348 typedef BOOL (CALLBACK *PROPENUMPROCEXW)(HWND,LPCWSTR,HANDLE,LPARAM);
349 DECL_WINELIB_TYPE_AW(PROPENUMPROCEX)
350 typedef BOOL (CALLBACK* TIMEFMT_ENUMPROCA)(LPSTR);
351 typedef BOOL (CALLBACK* TIMEFMT_ENUMPROCW)(LPWSTR);
352 DECL_WINELIB_TYPE_AW(TIMEFMT_ENUMPROC)
353 typedef VOID (CALLBACK *TIMERPROC16)(HWND16,UINT16,UINT16,DWORD);
354 typedef VOID (CALLBACK *TIMERPROC)(HWND,UINT,UINT,DWORD);
355 typedef LRESULT (CALLBACK *WNDENUMPROC16)(HWND16,LPARAM);
356 typedef LRESULT (CALLBACK *WNDENUMPROC)(HWND,LPARAM);
357 typedef LRESULT (CALLBACK *WNDPROC16)(HWND16,UINT16,WPARAM16,LPARAM);
358 typedef LRESULT (CALLBACK *WNDPROC)(HWND,UINT,WPARAM,LPARAM);
360 /* Define some empty macros for compatibility with Windows code. */
372 #endif /* __WINE__ */
374 /* Macro for structure packing. */
377 #define WINE_PACKED __attribute__ ((packed))
378 #define WINE_UNUSED __attribute__ ((unused))
380 #define WINE_PACKED /* nothing */
381 #define WINE_UNUSED /* nothing */
384 /* Macros to split words and longs. */
386 #define LOBYTE(w) ((BYTE)(WORD)(w))
387 #define HIBYTE(w) ((BYTE)((WORD)(w) >> 8))
389 #define LOWORD(l) ((WORD)(DWORD)(l))
390 #define HIWORD(l) ((WORD)((DWORD)(l) >> 16))
392 #define SLOWORD(l) ((INT16)(LONG)(l))
393 #define SHIWORD(l) ((INT16)((LONG)(l) >> 16))
395 #define MAKEWORD(low,high) ((WORD)(((BYTE)(low)) | ((WORD)((BYTE)(high))) << 8))
396 #define MAKELONG(low,high) ((LONG)(((WORD)(low)) | (((DWORD)((WORD)(high))) << 16)))
397 #define MAKELPARAM(low,high) ((LPARAM)MAKELONG(low,high))
398 #define MAKEWPARAM(low,high) ((WPARAM)MAKELONG(low,high))
399 #define MAKELRESULT(low,high) ((LRESULT)MAKELONG(low,high))
400 #define MAKEINTATOM(atom) ((LPCSTR)MAKELONG((atom),0))
402 #define SELECTOROF(ptr) (HIWORD(ptr))
403 #define OFFSETOF(ptr) (LOWORD(ptr))
406 /* macros to set parts of a DWORD (not in the Windows API) */
407 #define SET_LOWORD(dw,val) ((dw) = ((dw) & 0xffff0000) | LOWORD(val))
408 #define SET_LOBYTE(dw,val) ((dw) = ((dw) & 0xffffff00) | LOBYTE(val))
409 #define SET_HIBYTE(dw,val) ((dw) = ((dw) & 0xffff00ff) | (LOWORD(val) & 0xff00))
410 #define ADD_LOWORD(dw,val) ((dw) = ((dw) & 0xffff0000) | LOWORD((DWORD)(dw)+(val)))
413 /* Macros to access unaligned or wrong-endian WORDs and DWORDs. */
414 /* Note: These macros are semantically broken, at least for wrc. wrc
415 spits out data in the platform's current binary format, *not* in
416 little-endian format. These macros are used throughout the resource
417 code to load and store data to the resources. Since it is unlikely
418 that we'll ever be dealing with little-endian resource data, the
419 byte-swapping nature of these macros has been disabled. Rather than
420 remove the use of these macros from the resource loading code, the
421 macros have simply been disabled. In the future, someone may want
422 to reactivate these macros for other purposes. In that case, the
423 resource code will have to be modified to use different macros. */
426 #define PUT_WORD(ptr,w) (*(WORD *)(ptr) = (w))
427 #define GET_WORD(ptr) (*(WORD *)(ptr))
428 #define PUT_DWORD(ptr,dw) (*(DWORD *)(ptr) = (dw))
429 #define GET_DWORD(ptr) (*(DWORD *)(ptr))
431 #define PUT_WORD(ptr,w) (*(BYTE *)(ptr) = LOBYTE(w), \
432 *((BYTE *)(ptr) + 1) = HIBYTE(w))
433 #define GET_WORD(ptr) ((WORD)(*(BYTE *)(ptr) | \
434 (WORD)(*((BYTE *)(ptr)+1) << 8)))
435 #define PUT_DWORD(ptr,dw) (PUT_WORD((ptr),LOWORD(dw)), \
436 PUT_WORD((WORD *)(ptr)+1,HIWORD(dw)))
437 #define GET_DWORD(ptr) ((DWORD)(GET_WORD(ptr) | \
438 ((DWORD)GET_WORD((WORD *)(ptr)+1) << 16)))
441 /* MIN and MAX macros */
446 #define MAX(a,b) (((a) > (b)) ? (a) : (b))
451 #define MIN(a,b) (((a) < (b)) ? (a) : (b))
453 #define __max(a,b) MAX(a,b)
454 #define __min(a,b) MIN(a,b)
456 #define max(a,b) MAX(a,b)
459 #define min(a,b) MIN(a,b)
462 #define _MAX_PATH 260
466 #define _MAX_FNAME 255
469 #define HFILE_ERROR16 ((HFILE16)-1)
470 #define HFILE_ERROR ((HFILE)-1)
472 /* The SIZE structure */
478 } SIZE16, *PSIZE16, *LPSIZE16;
480 typedef struct tagSIZE
484 } SIZE, *PSIZE, *LPSIZE;
487 typedef SIZE SIZEL, *PSIZEL, *LPSIZEL;
489 #define CONV_SIZE16TO32(s16,s32) \
490 ((s32)->cx = (INT)(s16)->cx, (s32)->cy = (INT)(s16)->cy)
491 #define CONV_SIZE32TO16(s32,s16) \
492 ((s16)->cx = (INT16)(s32)->cx, (s16)->cy = (INT16)(s32)->cy)
494 /* The POINT structure */
500 } POINT16, *PPOINT16, *LPPOINT16;
502 typedef struct tagPOINT
506 } POINT, *PPOINT, *LPPOINT;
508 typedef struct _POINTL
514 #define CONV_POINT16TO32(p16,p32) \
515 ((p32)->x = (INT)(p16)->x, (p32)->y = (INT)(p16)->y)
516 #define CONV_POINT32TO16(p32,p16) \
517 ((p16)->x = (INT16)(p32)->x, (p16)->y = (INT16)(p32)->y)
519 #define MAKEPOINT16(l) (*((POINT16 *)&(l)))
521 /* The POINTS structure */
523 typedef struct tagPOINTS
527 } POINTS, *PPOINTS, *LPPOINTS;
530 #define MAKEPOINTS(l) (*((POINTS *)&(l)))
533 /* The RECT structure */
543 typedef struct tagRECT
549 } RECT, *PRECT, *LPRECT;
550 typedef const RECT *LPCRECT;
553 typedef struct tagRECTL
559 } RECTL, *PRECTL, *LPRECTL;
561 typedef const RECTL *LPCRECTL;
563 #define CONV_RECT16TO32(r16,r32) \
564 ((r32)->left = (INT)(r16)->left, (r32)->top = (INT)(r16)->top, \
565 (r32)->right = (INT)(r16)->right, (r32)->bottom = (INT)(r16)->bottom)
566 #define CONV_RECT32TO16(r32,r16) \
567 ((r16)->left = (INT16)(r32)->left, (r16)->top = (INT16)(r32)->top, \
568 (r16)->right = (INT16)(r32)->right, (r16)->bottom = (INT16)(r32)->bottom)
574 #endif /* __WINE_WINDEF_H */