2 * Basic types definitions
4 * Copyright 1996 Alexandre Julliard
6 * Modified for use with MPlayer, detailed CVS changelog at
7 * http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
12 #ifndef __WINE_WINDEF_H
13 #define __WINE_WINDEF_H
28 /* Misc. constants. */
45 /* Macros to map Winelib names to the correct implementation name */
46 /* depending on __WINE__ and UNICODE macros. */
47 /* Note that Winelib is purely Win32. */
50 # define WINELIB_NAME_AW(func) \
51 func##_must_be_suffixed_with_W_or_A_in_this_context \
52 func##_must_be_suffixed_with_W_or_A_in_this_context
55 # define WINELIB_NAME_AW(func) func##W
57 # define WINELIB_NAME_AW(func) func##A
62 # define DECL_WINELIB_TYPE_AW(type) /* nothing */
64 # define DECL_WINELIB_TYPE_AW(type) typedef WINELIB_NAME_AW(type) type;
67 #ifndef NONAMELESSSTRUCT
68 # if defined(__WINE__) || !defined(_FORCENAMELESSSTRUCT)
69 # define NONAMELESSSTRUCT
71 #endif /* !defined(NONAMELESSSTRUCT) */
73 #ifndef NONAMELESSUNION
74 # if defined(__WINE__) || !defined(_FORCENAMELESSUNION) || !defined(__cplusplus)
75 # define NONAMELESSUNION
77 #endif /* !defined(NONAMELESSUNION) */
79 #ifndef NONAMELESSSTRUCT
80 #define DUMMYSTRUCTNAME
81 #define DUMMYSTRUCTNAME1
82 #define DUMMYSTRUCTNAME2
83 #define DUMMYSTRUCTNAME3
84 #define DUMMYSTRUCTNAME4
85 #define DUMMYSTRUCTNAME5
86 #else /* !defined(NONAMELESSSTRUCT) */
87 #define DUMMYSTRUCTNAME s
88 #define DUMMYSTRUCTNAME1 s1
89 #define DUMMYSTRUCTNAME2 s2
90 #define DUMMYSTRUCTNAME3 s3
91 #define DUMMYSTRUCTNAME4 s4
92 #define DUMMYSTRUCTNAME5 s5
93 #endif /* !defined(NONAMELESSSTRUCT) */
95 #ifndef NONAMELESSUNION
96 #define DUMMYUNIONNAME
97 #define DUMMYUNIONNAME1
98 #define DUMMYUNIONNAME2
99 #define DUMMYUNIONNAME3
100 #define DUMMYUNIONNAME4
101 #define DUMMYUNIONNAME5
102 #else /* !defined(NONAMELESSUNION) */
103 #define DUMMYUNIONNAME u
104 #define DUMMYUNIONNAME1 u1
105 #define DUMMYUNIONNAME2 u2
106 #define DUMMYUNIONNAME3 u3
107 #define DUMMYUNIONNAME4 u4
108 #define DUMMYUNIONNAME5 u5
109 #endif /* !defined(NONAMELESSUNION) */
111 /* Calling conventions definitions */
114 # if defined(__GNUC__) && ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 7)))
116 #define __stdcall __attribute__((__stdcall__))
117 #define __cdecl __attribute__((__cdecl__))
118 # define __RESTORE_ES __asm__ __volatile__("pushl %ds\n\tpopl %es")
121 // # error You need gcc >= 2.7 to build Wine on a 386
126 # define __RESTORE_ES
129 #define CALLBACK __stdcall
130 #define WINAPI __stdcall
131 #define APIPRIVATE __stdcall
132 #define PASCAL __stdcall
133 #define pascal __stdcall
134 #define _pascal __stdcall
135 #if !defined(__CYGWIN__) && !defined(__MINGW32__)
136 #define _stdcall __stdcall
137 #define _fastcall __stdcall
138 #define __fastcall __stdcall
140 #define __export __stdcall
141 #define CDECL __cdecl
142 #define _CDECL __cdecl
143 #define cdecl __cdecl
144 #if !defined(__CYGWIN__) && !defined(__MINGW32__)
145 #define _cdecl __cdecl
147 #define WINAPIV __cdecl
148 #define APIENTRY WINAPI
150 #if !defined(__CYGWIN__) && !defined(__MINGW32__)
151 #define __declspec(x)
158 /* Standard data types. These are the same for emulator and library. */
162 typedef unsigned int UINT;
163 typedef unsigned short WORD;
164 typedef unsigned long DWORD;
165 typedef unsigned long ULONG;
166 typedef unsigned char BYTE;
169 typedef unsigned short USHORT;
171 typedef unsigned char UCHAR;
175 /* Some systems might have wchar_t, but we really need 16 bit characters */
176 typedef unsigned short WCHAR;
177 typedef int WIN_BOOL;
179 typedef double DOUBLE;
180 typedef long long LONGLONG;
181 typedef unsigned long long ULONGLONG;
183 /* FIXME: Wine does not compile with strict on, therefore strict
184 * handles are presently only usable on machines where sizeof(UINT) ==
185 * sizeof(void*). HANDLEs are supposed to be void* but a large amount
186 * of WINE code operates on HANDLES as if they are UINTs. So to WINE
187 * they exist as UINTs but to the Winelib user who turns on strict,
188 * they exist as void*. If there is a size difference between UINT and
189 * void* then things get ugly. */
191 typedef VOID* HANDLE;
197 typedef HANDLE *LPHANDLE;
199 /* Integer types. These are the same for emulator and library. */
202 typedef LONG HRESULT;
203 typedef LONG LRESULT;
205 typedef WORD CATCHBUF[9];
206 typedef WORD *LPCATCHBUF;
207 typedef HANDLE HHOOK;
208 typedef HANDLE HMONITOR;
211 typedef DWORD LCTYPE;
214 /* Pointers types. These are the same for emulator and library. */
217 typedef const void *PCVOID;
219 typedef UCHAR *PUCHAR;
222 typedef USHORT *PUSHORT;
223 typedef SHORT *PSHORT;
224 typedef ULONG *PULONG;
226 typedef DWORD *PDWORD;
227 /* common win32 types */
230 typedef const CHAR *LPCSTR;
231 typedef const CHAR *PCSTR;
232 typedef WCHAR *LPWSTR;
233 typedef WCHAR *PWSTR;
234 typedef const WCHAR *LPCWSTR;
235 typedef const WCHAR *PCWSTR;
236 typedef BYTE *LPBYTE;
237 typedef WORD *LPWORD;
238 typedef DWORD *LPDWORD;
239 typedef LONG *LPLONG;
240 typedef VOID *LPVOID;
241 typedef const VOID *LPCVOID;
245 typedef UINT *LPUINT;
246 typedef FLOAT *PFLOAT;
247 typedef FLOAT *LPFLOAT;
248 typedef WIN_BOOL *PWIN_BOOL;
249 typedef WIN_BOOL *LPWIN_BOOL;
251 /* Special case: a segmented pointer is just a pointer in the user's code. */
254 typedef DWORD SEGPTR;
256 typedef void* SEGPTR;
257 #endif /* __WINE__ */
259 /* Handle types that exist both in Win16 and Win32. */
262 #define DECLARE_HANDLE(a) \
263 typedef struct a##__ { int unused; } *a; \
267 #define DECLARE_HANDLE(a) \
273 DECLARE_HANDLE(HACMDRIVERID);
274 DECLARE_HANDLE(HACMDRIVER);
275 DECLARE_HANDLE(HACMOBJ);
276 DECLARE_HANDLE(HACMSTREAM);
277 DECLARE_HANDLE(HMETAFILEPICT);
279 DECLARE_HANDLE(HACCEL);
280 DECLARE_HANDLE(HBITMAP);
281 DECLARE_HANDLE(HBRUSH);
282 DECLARE_HANDLE(HCOLORSPACE);
283 DECLARE_HANDLE(HCURSOR);
285 DECLARE_HANDLE(HDROP);
286 DECLARE_HANDLE(HDRVR);
287 DECLARE_HANDLE(HDWP);
288 DECLARE_HANDLE(HENHMETAFILE);
289 DECLARE_HANDLE(HFILE);
290 DECLARE_HANDLE(HFONT);
291 DECLARE_HANDLE(HICON);
292 DECLARE_HANDLE(HINSTANCE);
293 DECLARE_HANDLE(HKEY);
294 DECLARE_HANDLE(HMENU);
295 DECLARE_HANDLE(HMETAFILE);
296 DECLARE_HANDLE(HMIDI);
297 DECLARE_HANDLE(HMIDIIN);
298 DECLARE_HANDLE(HMIDIOUT);
299 DECLARE_HANDLE(HMIDISTRM);
300 DECLARE_HANDLE(HMIXER);
301 DECLARE_HANDLE(HMIXEROBJ);
302 DECLARE_HANDLE(HMMIO);
303 DECLARE_HANDLE(HPALETTE);
304 DECLARE_HANDLE(HPEN);
305 DECLARE_HANDLE(HQUEUE);
306 DECLARE_HANDLE(HRGN);
307 DECLARE_HANDLE(HRSRC);
308 DECLARE_HANDLE(HTASK);
309 DECLARE_HANDLE(HWAVE);
310 DECLARE_HANDLE(HWAVEIN);
311 DECLARE_HANDLE(HWAVEOUT);
312 DECLARE_HANDLE(HWINSTA);
313 DECLARE_HANDLE(HDESK);
314 DECLARE_HANDLE(HWND);
317 DECLARE_HANDLE(HRASCONN);
319 /* Handle types that must remain interchangeable even with strict on */
321 typedef HINSTANCE HMODULE;
322 typedef HANDLE HGDIOBJ;
323 typedef HANDLE HGLOBAL;
324 typedef HANDLE HLOCAL;
325 typedef HANDLE GLOBALHANDLE;
326 typedef HANDLE LOCALHANDLE;
328 /* Callback function pointers types */
329 //WIN_BOOL CALLBACK DATEFMT_ENUMPROCA(LPSTR);
331 typedef WIN_BOOL CALLBACK (* DATEFMT_ENUMPROCA)(LPSTR);
332 typedef WIN_BOOL CALLBACK (* DATEFMT_ENUMPROCW)(LPWSTR);
333 DECL_WINELIB_TYPE_AW(DATEFMT_ENUMPROC)
334 typedef WIN_BOOL CALLBACK (*DLGPROC)(HWND,UINT,WPARAM,LPARAM);
335 typedef LRESULT CALLBACK (*DRIVERPROC)(DWORD,HDRVR,UINT,LPARAM,LPARAM);
336 typedef INT CALLBACK (*EDITWORDBREAKPROCA)(LPSTR,INT,INT,INT);
337 typedef INT CALLBACK (*EDITWORDBREAKPROCW)(LPWSTR,INT,INT,INT);
338 DECL_WINELIB_TYPE_AW(EDITWORDBREAKPROC)
339 typedef LRESULT CALLBACK (*FARPROC)();
340 typedef INT CALLBACK (*PROC)();
341 typedef WIN_BOOL CALLBACK (*GRAYSTRINGPROC)(HDC,LPARAM,INT);
342 typedef LRESULT CALLBACK (*HOOKPROC)(INT,WPARAM,LPARAM);
343 typedef WIN_BOOL CALLBACK (*PROPENUMPROCA)(HWND,LPCSTR,HANDLE);
344 typedef WIN_BOOL CALLBACK (*PROPENUMPROCW)(HWND,LPCWSTR,HANDLE);
345 DECL_WINELIB_TYPE_AW(PROPENUMPROC)
346 typedef WIN_BOOL CALLBACK (*PROPENUMPROCEXA)(HWND,LPCSTR,HANDLE,LPARAM);
347 typedef WIN_BOOL CALLBACK (*PROPENUMPROCEXW)(HWND,LPCWSTR,HANDLE,LPARAM);
348 DECL_WINELIB_TYPE_AW(PROPENUMPROCEX)
349 typedef WIN_BOOL CALLBACK (* TIMEFMT_ENUMPROCA)(LPSTR);
350 typedef WIN_BOOL CALLBACK (* TIMEFMT_ENUMPROCW)(LPWSTR);
351 DECL_WINELIB_TYPE_AW(TIMEFMT_ENUMPROC)
352 typedef VOID CALLBACK (*TIMERPROC)(HWND,UINT,UINT,DWORD);
353 typedef WIN_BOOL CALLBACK (*WNDENUMPROC)(HWND,LPARAM);
354 typedef LRESULT CALLBACK (*WNDPROC)(HWND,UINT,WPARAM,LPARAM);
356 /*----------------------------------------------------------------------------
357 ** FIXME: Better isolate Wine's reliance on the xxx16 type definitions.
358 ** For now, we just isolate them to make the situation clear.
359 **--------------------------------------------------------------------------*/
361 * Basic type definitions for 16 bit variations on Windows types.
362 * These types are provided mostly to insure compatibility with
363 * 16 bit windows code.
366 #ifndef __WINE_WINDEF16_H
367 #define __WINE_WINDEF16_H
371 /* Standard data types */
374 typedef unsigned short UINT16;
375 typedef unsigned short WIN_BOOL16;
377 typedef UINT16 HANDLE16;
378 typedef HANDLE16 *LPHANDLE16;
380 typedef UINT16 WPARAM16;
381 typedef INT16 *LPINT16;
382 typedef UINT16 *LPUINT16;
384 #define DECLARE_HANDLE16(a) \
385 typedef HANDLE16 a##16; \
386 typedef a##16 *P##a##16; \
387 typedef a##16 *NP##a##16; \
388 typedef a##16 *LP##a##16
390 DECLARE_HANDLE16(HACMDRIVERID);
391 DECLARE_HANDLE16(HACMDRIVER);
392 DECLARE_HANDLE16(HACMOBJ);
393 DECLARE_HANDLE16(HACMSTREAM);
394 DECLARE_HANDLE16(HMETAFILEPICT);
396 DECLARE_HANDLE16(HACCEL);
397 DECLARE_HANDLE16(HBITMAP);
398 DECLARE_HANDLE16(HBRUSH);
399 DECLARE_HANDLE16(HCOLORSPACE);
400 DECLARE_HANDLE16(HCURSOR);
401 DECLARE_HANDLE16(HDC);
402 DECLARE_HANDLE16(HDROP);
403 DECLARE_HANDLE16(HDRVR);
404 DECLARE_HANDLE16(HDWP);
405 DECLARE_HANDLE16(HENHMETAFILE);
406 DECLARE_HANDLE16(HFILE);
407 DECLARE_HANDLE16(HFONT);
408 DECLARE_HANDLE16(HICON);
409 DECLARE_HANDLE16(HINSTANCE);
410 DECLARE_HANDLE16(HKEY);
411 DECLARE_HANDLE16(HMENU);
412 DECLARE_HANDLE16(HMETAFILE);
413 DECLARE_HANDLE16(HMIDI);
414 DECLARE_HANDLE16(HMIDIIN);
415 DECLARE_HANDLE16(HMIDIOUT);
416 DECLARE_HANDLE16(HMIDISTRM);
417 DECLARE_HANDLE16(HMIXER);
418 DECLARE_HANDLE16(HMIXEROBJ);
419 DECLARE_HANDLE16(HMMIO);
420 DECLARE_HANDLE16(HPALETTE);
421 DECLARE_HANDLE16(HPEN);
422 DECLARE_HANDLE16(HQUEUE);
423 DECLARE_HANDLE16(HRGN);
424 DECLARE_HANDLE16(HRSRC);
425 DECLARE_HANDLE16(HTASK);
426 DECLARE_HANDLE16(HWAVE);
427 DECLARE_HANDLE16(HWAVEIN);
428 DECLARE_HANDLE16(HWAVEOUT);
429 DECLARE_HANDLE16(HWINSTA);
430 DECLARE_HANDLE16(HDESK);
431 DECLARE_HANDLE16(HWND);
432 DECLARE_HANDLE16(HKL);
433 DECLARE_HANDLE16(HIC);
434 DECLARE_HANDLE16(HRASCONN);
435 #undef DECLARE_HANDLE16
437 typedef HINSTANCE16 HMODULE16;
438 typedef HANDLE16 HGDIOBJ16;
439 typedef HANDLE16 HGLOBAL16;
440 typedef HANDLE16 HLOCAL16;
442 /* The SIZE structure */
447 } SIZE16, *PSIZE16, *LPSIZE16;
449 /* The POINT structure */
455 } POINT16, *PPOINT16, *LPPOINT16;
457 /* The RECT structure */
467 /* Callback function pointers types */
469 typedef LRESULT CALLBACK (*DRIVERPROC16)(DWORD,HDRVR16,UINT16,LPARAM,LPARAM);
470 typedef WIN_BOOL16 CALLBACK (*DLGPROC16)(HWND16,UINT16,WPARAM16,LPARAM);
471 typedef INT16 CALLBACK (*EDITWORDBREAKPROC16)(LPSTR,INT16,INT16,INT16);
472 typedef LRESULT CALLBACK (*FARPROC16)();
473 typedef INT16 CALLBACK (*PROC16)();
474 typedef WIN_BOOL16 CALLBACK (*GRAYSTRINGPROC16)(HDC16,LPARAM,INT16);
475 typedef LRESULT CALLBACK (*HOOKPROC16)(INT16,WPARAM16,LPARAM);
476 typedef WIN_BOOL16 CALLBACK (*PROPENUMPROC16)(HWND16,SEGPTR,HANDLE16);
477 typedef VOID CALLBACK (*TIMERPROC16)(HWND16,UINT16,UINT16,DWORD);
478 typedef LRESULT CALLBACK (*WNDENUMPROC16)(HWND16,LPARAM);
479 typedef LRESULT CALLBACK (*WNDPROC16)(HWND16,UINT16,WPARAM16,LPARAM);
481 #endif /* __WINE_WINDEF16_H */
483 /* Define some empty macros for compatibility with Windows code. */
495 #endif /* __WINE__ */
497 /* Macro for structure packing. */
501 #define WINE_PACKED __attribute__((packed))
502 #define WINE_UNUSED __attribute__((unused))
503 #define WINE_NORETURN __attribute__((noreturn))
506 #define WINE_PACKED /* nothing */
507 #define WINE_UNUSED /* nothing */
508 #define WINE_NORETURN /* nothing */
511 /* Macros to split words and longs. */
513 #define LOBYTE(w) ((BYTE)(WORD)(w))
514 #define HIBYTE(w) ((BYTE)((WORD)(w) >> 8))
516 #define LOWORD(l) ((WORD)(DWORD)(l))
517 #define HIWORD(l) ((WORD)((DWORD)(l) >> 16))
519 #define SLOWORD(l) ((INT16)(LONG)(l))
520 #define SHIWORD(l) ((INT16)((LONG)(l) >> 16))
522 #define MAKEWORD(low,high) ((WORD)(((BYTE)(low)) | ((WORD)((BYTE)(high))) << 8))
523 #define MAKELONG(low,high) ((LONG)(((WORD)(low)) | (((DWORD)((WORD)(high))) << 16)))
524 #define MAKELPARAM(low,high) ((LPARAM)MAKELONG(low,high))
525 #define MAKEWPARAM(low,high) ((WPARAM)MAKELONG(low,high))
526 #define MAKELRESULT(low,high) ((LRESULT)MAKELONG(low,high))
527 #define MAKEINTATOM(atom) ((LPCSTR)MAKELONG((atom),0))
529 #define SELECTOROF(ptr) (HIWORD(ptr))
530 #define OFFSETOF(ptr) (LOWORD(ptr))
533 /* macros to set parts of a DWORD (not in the Windows API) */
534 #define SET_LOWORD(dw,val) ((dw) = ((dw) & 0xffff0000) | LOWORD(val))
535 #define SET_LOBYTE(dw,val) ((dw) = ((dw) & 0xffffff00) | LOBYTE(val))
536 #define SET_HIBYTE(dw,val) ((dw) = ((dw) & 0xffff00ff) | (LOWORD(val) & 0xff00))
537 #define ADD_LOWORD(dw,val) ((dw) = ((dw) & 0xffff0000) | LOWORD((DWORD)(dw)+(val)))
540 /* Macros to access unaligned or wrong-endian WORDs and DWORDs. */
541 /* Note: These macros are semantically broken, at least for wrc. wrc
542 spits out data in the platform's current binary format, *not* in
543 little-endian format. These macros are used throughout the resource
544 code to load and store data to the resources. Since it is unlikely
545 that we'll ever be dealing with little-endian resource data, the
546 byte-swapping nature of these macros has been disabled. Rather than
547 remove the use of these macros from the resource loading code, the
548 macros have simply been disabled. In the future, someone may want
549 to reactivate these macros for other purposes. In that case, the
550 resource code will have to be modified to use different macros. */
553 #define PUT_WORD(ptr,w) (*(WORD *)(ptr) = (w))
554 #define GET_WORD(ptr) (*(WORD *)(ptr))
555 #define PUT_DWORD(ptr,dw) (*(DWORD *)(ptr) = (dw))
556 #define GET_DWORD(ptr) (*(DWORD *)(ptr))
558 #define PUT_WORD(ptr,w) (*(BYTE *)(ptr) = LOBYTE(w), \
559 *((BYTE *)(ptr) + 1) = HIBYTE(w))
560 #define GET_WORD(ptr) ((WORD)(*(BYTE *)(ptr) | \
561 (WORD)(*((BYTE *)(ptr)+1) << 8)))
562 #define PUT_DWORD(ptr,dw) (PUT_WORD((ptr),LOWORD(dw)), \
563 PUT_WORD((WORD *)(ptr)+1,HIWORD(dw)))
564 #define GET_DWORD(ptr) ((DWORD)(GET_WORD(ptr) | \
565 ((DWORD)GET_WORD((WORD *)(ptr)+1) << 16)))
568 /* min and max macros */
569 #define __max(a,b) (((a) > (b)) ? (a) : (b))
570 #define __min(a,b) (((a) < (b)) ? (a) : (b))
572 #define max(a,b) (((a) > (b)) ? (a) : (b))
575 #define min(a,b) (((a) < (b)) ? (a) : (b))
579 #define _MAX_PATH 260
591 #define _MAX_FNAME 255
597 #define HFILE_ERROR16 ((HFILE16)-1)
598 #define HFILE_ERROR ((HFILE)-1)
600 /* The SIZE structure */
601 typedef struct tagSIZE
605 } SIZE, *PSIZE, *LPSIZE;
608 typedef SIZE SIZEL, *PSIZEL, *LPSIZEL;
610 #define CONV_SIZE16TO32(s16,s32) \
611 ((s32)->cx = (INT)(s16)->cx, (s32)->cy = (INT)(s16)->cy)
612 #define CONV_SIZE32TO16(s32,s16) \
613 ((s16)->cx = (INT16)(s32)->cx, (s16)->cy = (INT16)(s32)->cy)
615 /* The POINT structure */
616 typedef struct tagPOINT
620 } POINT, *PPOINT, *LPPOINT;
622 typedef struct _POINTL
628 #define CONV_POINT16TO32(p16,p32) \
629 ((p32)->x = (INT)(p16)->x, (p32)->y = (INT)(p16)->y)
630 #define CONV_POINT32TO16(p32,p16) \
631 ((p16)->x = (INT16)(p32)->x, (p16)->y = (INT16)(p32)->y)
633 #define MAKEPOINT16(l) (*((POINT16 *)&(l)))
635 /* The POINTS structure */
637 typedef struct tagPOINTS
641 } POINTS, *PPOINTS, *LPPOINTS;
644 #define MAKEPOINTS(l) (*((POINTS *)&(l)))
647 /* The RECT structure */
648 typedef struct tagRECT
654 } RECT, *PRECT, *LPRECT;
655 typedef const RECT *LPCRECT;
658 typedef struct tagRECTL
664 } RECTL, *PRECTL, *LPRECTL;
666 typedef const RECTL *LPCRECTL;
668 #define CONV_RECT16TO32(r16,r32) \
669 ((r32)->left = (INT)(r16)->left, (r32)->top = (INT)(r16)->top, \
670 (r32)->right = (INT)(r16)->right, (r32)->bottom = (INT)(r16)->bottom)
671 #define CONV_RECT32TO16(r32,r16) \
672 ((r16)->left = (INT16)(r32)->left, (r16)->top = (INT16)(r32)->top, \
673 (r16)->right = (INT16)(r32)->right, (r16)->bottom = (INT16)(r32)->bottom)
679 #endif /* __WINE_WINDEF_H */