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) \
42 func##_must_be_suffixed_with_W_or_A_in_this_context \
43 func##_must_be_suffixed_with_W_or_A_in_this_context
46 # define WINELIB_NAME_AW(func) func##W
48 # define WINELIB_NAME_AW(func) func##A
53 # define DECL_WINELIB_TYPE_AW(type) /* nothing */
55 # define DECL_WINELIB_TYPE_AW(type) typedef WINELIB_NAME_AW(type) type;
58 #ifndef NONAMELESSSTRUCT
59 # if defined(__WINE__) || !defined(_FORCENAMELESSSTRUCT)
60 # define NONAMELESSSTRUCT
62 #endif /* !defined(NONAMELESSSTRUCT) */
64 #ifndef NONAMELESSUNION
65 # if defined(__WINE__) || !defined(_FORCENAMELESSUNION) || !defined(__cplusplus)
66 # define NONAMELESSUNION
68 #endif /* !defined(NONAMELESSUNION) */
70 #ifndef NONAMELESSSTRUCT
71 #define DUMMYSTRUCTNAME
72 #define DUMMYSTRUCTNAME1
73 #define DUMMYSTRUCTNAME2
74 #define DUMMYSTRUCTNAME3
75 #define DUMMYSTRUCTNAME4
76 #define DUMMYSTRUCTNAME5
77 #else /* !defined(NONAMELESSSTRUCT) */
78 #define DUMMYSTRUCTNAME s
79 #define DUMMYSTRUCTNAME1 s1
80 #define DUMMYSTRUCTNAME2 s2
81 #define DUMMYSTRUCTNAME3 s3
82 #define DUMMYSTRUCTNAME4 s4
83 #define DUMMYSTRUCTNAME5 s5
84 #endif /* !defined(NONAMELESSSTRUCT) */
86 #ifndef NONAMELESSUNION
87 #define DUMMYUNIONNAME
88 #define DUMMYUNIONNAME1
89 #define DUMMYUNIONNAME2
90 #define DUMMYUNIONNAME3
91 #define DUMMYUNIONNAME4
92 #define DUMMYUNIONNAME5
93 #define DUMMYUNIONNAME6
94 #define DUMMYUNIONNAME7
95 #define DUMMYUNIONNAME8
96 #else /* !defined(NONAMELESSUNION) */
97 #define DUMMYUNIONNAME u
98 #define DUMMYUNIONNAME1 u1
99 #define DUMMYUNIONNAME2 u2
100 #define DUMMYUNIONNAME3 u3
101 #define DUMMYUNIONNAME4 u4
102 #define DUMMYUNIONNAME5 u5
103 #define DUMMYUNIONNAME6 u6
104 #define DUMMYUNIONNAME7 u7
105 #define DUMMYUNIONNAME8 u8
106 #endif /* !defined(NONAMELESSUNION) */
108 /* Calling conventions definitions */
114 # if defined(__GNUC__) && ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 7)))
115 # define __stdcall __attribute__((__stdcall__))
116 # define __cdecl __attribute__((__cdecl__))
117 # define __RESTORE_ES __asm__ __volatile__("pushl %ds\n\tpopl %es")
119 # error You need gcc >= 2.7 to build Wine on a 386
120 # endif /* __GNUC__ */
124 # define __RESTORE_ES
125 #endif /* __i386__ */
127 #define CALLBACK __stdcall
128 #define WINAPI __stdcall
129 #define APIPRIVATE __stdcall
130 #define PASCAL __stdcall
131 #define pascal __stdcall
132 #define _pascal __stdcall
133 #define _stdcall __stdcall
134 #define _fastcall __stdcall
135 #define __fastcall __stdcall
136 #define __export __stdcall
137 #define CDECL __cdecl
138 #define _CDECL __cdecl
139 #define cdecl __cdecl
140 #define _cdecl __cdecl
141 #define WINAPIV __cdecl
142 #define APIENTRY WINAPI
145 #define __declspec(x)
149 /* Standard data types. These are the same for emulator and library. */
153 typedef unsigned int UINT
;
154 typedef unsigned short WORD
;
155 typedef unsigned long DWORD
;
156 typedef unsigned long ULONG
;
157 typedef unsigned char BYTE
;
160 typedef unsigned short USHORT
;
162 typedef unsigned char UCHAR
;
163 /* Some systems might have wchar_t, but we really need 16 bit characters */
164 typedef unsigned short WCHAR
;
167 typedef double DOUBLE
;
169 /* FIXME: Wine does not compile with strict on, therefore strict
170 * handles are presently only usable on machines where sizeof(UINT) ==
171 * sizeof(void*). HANDLEs are supposed to be void* but a large amount
172 * of WINE code operates on HANDLES as if they are UINTs. So to WINE
173 * they exist as UINTs but to the Winelib user who turns on strict,
174 * they exist as void*. If there is a size difference between UINT and
175 * void* then things get ugly. */
177 typedef VOID
* HANDLE
;
183 typedef HANDLE
*LPHANDLE
;
185 /* Integer types. These are the same for emulator and library. */
188 typedef LONG HRESULT
;
189 typedef LONG LRESULT
;
191 typedef WORD CATCHBUF
[9];
192 typedef WORD
*LPCATCHBUF
;
193 typedef HANDLE HHOOK
;
194 typedef HANDLE HMONITOR
;
197 typedef DWORD LCTYPE
;
200 /* Pointers types. These are the same for emulator and library. */
203 typedef const void *PCVOID
;
205 typedef UCHAR
*PUCHAR
;
208 typedef USHORT
*PUSHORT
;
209 typedef SHORT
*PSHORT
;
210 typedef ULONG
*PULONG
;
212 typedef DWORD
*PDWORD
;
213 /* common win32 types */
216 typedef const CHAR
*LPCSTR
;
217 typedef const CHAR
*PCSTR
;
218 typedef WCHAR
*LPWSTR
;
219 typedef WCHAR
*PWSTR
;
220 typedef const WCHAR
*LPCWSTR
;
221 typedef const WCHAR
*PCWSTR
;
222 typedef BYTE
*LPBYTE
;
223 typedef WORD
*LPWORD
;
224 typedef DWORD
*LPDWORD
;
225 typedef LONG
*LPLONG
;
226 typedef VOID
*LPVOID
;
227 typedef const VOID
*LPCVOID
;
231 typedef UINT
*LPUINT
;
232 typedef FLOAT
*PFLOAT
;
233 typedef FLOAT
*LPFLOAT
;
235 typedef BOOL
*LPBOOL
;
237 /* Special case: a segmented pointer is just a pointer in the user's code. */
240 typedef DWORD SEGPTR
;
242 typedef void* SEGPTR
;
243 #endif /* __WINE__ */
245 /* Handle types that exist both in Win16 and Win32. */
248 #define DECLARE_HANDLE(a) \
249 typedef struct a##__ { int unused; } *a; \
253 #define DECLARE_HANDLE(a) \
259 DECLARE_HANDLE(HACMDRIVERID
);
260 DECLARE_HANDLE(HACMDRIVER
);
261 DECLARE_HANDLE(HACMOBJ
);
262 DECLARE_HANDLE(HACMSTREAM
);
263 DECLARE_HANDLE(HMETAFILEPICT
);
265 DECLARE_HANDLE(HACCEL
);
266 DECLARE_HANDLE(HBITMAP
);
267 DECLARE_HANDLE(HBRUSH
);
268 DECLARE_HANDLE(HCOLORSPACE
);
269 DECLARE_HANDLE(HCURSOR
);
271 DECLARE_HANDLE(HDROP
);
272 DECLARE_HANDLE(HDRVR
);
273 DECLARE_HANDLE(HDWP
);
274 DECLARE_HANDLE(HENHMETAFILE
);
275 DECLARE_HANDLE(HFILE
);
276 DECLARE_HANDLE(HFONT
);
277 DECLARE_HANDLE(HICON
);
278 DECLARE_HANDLE(HINSTANCE
);
279 DECLARE_HANDLE(HKEY
);
280 DECLARE_HANDLE(HMENU
);
281 DECLARE_HANDLE(HMETAFILE
);
282 DECLARE_HANDLE(HMIDI
);
283 DECLARE_HANDLE(HMIDIIN
);
284 DECLARE_HANDLE(HMIDIOUT
);
285 DECLARE_HANDLE(HMIDISTRM
);
286 DECLARE_HANDLE(HMIXER
);
287 DECLARE_HANDLE(HMIXEROBJ
);
288 DECLARE_HANDLE(HMMIO
);
289 DECLARE_HANDLE(HPALETTE
);
290 DECLARE_HANDLE(HPEN
);
291 DECLARE_HANDLE(HQUEUE
);
292 DECLARE_HANDLE(HRGN
);
293 DECLARE_HANDLE(HRSRC
);
294 DECLARE_HANDLE(HTASK
);
295 DECLARE_HANDLE(HWAVE
);
296 DECLARE_HANDLE(HWAVEIN
);
297 DECLARE_HANDLE(HWAVEOUT
);
298 DECLARE_HANDLE(HWINSTA
);
299 DECLARE_HANDLE(HDESK
);
300 DECLARE_HANDLE(HWND
);
302 DECLARE_HANDLE(HRASCONN
);
304 /* Handle types that must remain interchangeable even with strict on */
306 typedef HINSTANCE HMODULE
;
307 typedef HANDLE HGDIOBJ
;
308 typedef HANDLE HGLOBAL
;
309 typedef HANDLE HLOCAL
;
310 typedef HANDLE GLOBALHANDLE
;
311 typedef HANDLE LOCALHANDLE
;
313 /* Callback function pointers types */
315 typedef BOOL
CALLBACK (*DATEFMT_ENUMPROCA
)(LPSTR
);
316 typedef BOOL
CALLBACK (*DATEFMT_ENUMPROCW
)(LPWSTR
);
317 DECL_WINELIB_TYPE_AW(DATEFMT_ENUMPROC
)
318 typedef BOOL
CALLBACK (*DLGPROC
)(HWND
,UINT
,WPARAM
,LPARAM
);
319 typedef LRESULT
CALLBACK (*DRIVERPROC
)(DWORD
,HDRVR
,UINT
,LPARAM
,LPARAM
);
320 typedef INT
CALLBACK (*EDITWORDBREAKPROCA
)(LPSTR
,INT
,INT
,INT
);
321 typedef INT
CALLBACK (*EDITWORDBREAKPROCW
)(LPWSTR
,INT
,INT
,INT
);
322 DECL_WINELIB_TYPE_AW(EDITWORDBREAKPROC
)
323 typedef LRESULT
CALLBACK (*FARPROC
)();
324 typedef INT
CALLBACK (*PROC
)();
325 typedef BOOL
CALLBACK (*GRAYSTRINGPROC
)(HDC
,LPARAM
,INT
);
326 typedef LRESULT
CALLBACK (*HOOKPROC
)(INT
,WPARAM
,LPARAM
);
327 typedef BOOL
CALLBACK (*PROPENUMPROCA
)(HWND
,LPCSTR
,HANDLE
);
328 typedef BOOL
CALLBACK (*PROPENUMPROCW
)(HWND
,LPCWSTR
,HANDLE
);
329 DECL_WINELIB_TYPE_AW(PROPENUMPROC
)
330 typedef BOOL
CALLBACK (*PROPENUMPROCEXA
)(HWND
,LPCSTR
,HANDLE
,LPARAM
);
331 typedef BOOL
CALLBACK (*PROPENUMPROCEXW
)(HWND
,LPCWSTR
,HANDLE
,LPARAM
);
332 DECL_WINELIB_TYPE_AW(PROPENUMPROCEX
)
333 typedef BOOL
CALLBACK (*TIMEFMT_ENUMPROCA
)(LPSTR
);
334 typedef BOOL
CALLBACK (*TIMEFMT_ENUMPROCW
)(LPWSTR
);
335 DECL_WINELIB_TYPE_AW(TIMEFMT_ENUMPROC
)
336 typedef VOID
CALLBACK (*TIMERPROC
)(HWND
,UINT
,UINT
,DWORD
);
337 typedef BOOL
CALLBACK (*WNDENUMPROC
)(HWND
,LPARAM
);
338 typedef LRESULT
CALLBACK (*WNDPROC
)(HWND
,UINT
,WPARAM
,LPARAM
);
340 /*----------------------------------------------------------------------------
341 ** FIXME: Better isolate Wine's reliance on the xxx16 type definitions.
342 ** For now, we just isolate them to make the situation clear.
343 **--------------------------------------------------------------------------*/
344 #include "wine/windef16.h"
346 /* Define some empty macros for compatibility with Windows code. */
358 #endif /* __WINE__ */
360 /* Macro for structure packing. */
363 #define WINE_PACKED __attribute__((packed))
364 #define WINE_UNUSED __attribute__((unused))
365 #define WINE_NORETURN __attribute__((noreturn))
367 #define WINE_PACKED /* nothing */
368 #define WINE_UNUSED /* nothing */
369 #define WINE_NORETURN /* nothing */
372 /* Macros to split words and longs. */
374 #define LOBYTE(w) ((BYTE)(WORD)(w))
375 #define HIBYTE(w) ((BYTE)((WORD)(w) >> 8))
377 #define LOWORD(l) ((WORD)(DWORD)(l))
378 #define HIWORD(l) ((WORD)((DWORD)(l) >> 16))
380 #define SLOWORD(l) ((INT16)(LONG)(l))
381 #define SHIWORD(l) ((INT16)((LONG)(l) >> 16))
383 #define MAKEWORD(low,high) ((WORD)(((BYTE)(low)) | ((WORD)((BYTE)(high))) << 8))
384 #define MAKELONG(low,high) ((LONG)(((WORD)(low)) | (((DWORD)((WORD)(high))) << 16)))
385 #define MAKELPARAM(low,high) ((LPARAM)MAKELONG(low,high))
386 #define MAKEWPARAM(low,high) ((WPARAM)MAKELONG(low,high))
387 #define MAKELRESULT(low,high) ((LRESULT)MAKELONG(low,high))
388 #define MAKEINTATOM(atom) ((LPCSTR)MAKELONG((atom),0))
390 #define SELECTOROF(ptr) (HIWORD(ptr))
391 #define OFFSETOF(ptr) (LOWORD(ptr))
394 /* macros to set parts of a DWORD (not in the Windows API) */
395 #define SET_LOWORD(dw,val) ((dw) = ((dw) & 0xffff0000) | LOWORD(val))
396 #define SET_LOBYTE(dw,val) ((dw) = ((dw) & 0xffffff00) | LOBYTE(val))
397 #define SET_HIBYTE(dw,val) ((dw) = ((dw) & 0xffff00ff) | (LOBYTE(val) << 8))
398 #define ADD_LOWORD(dw,val) ((dw) = ((dw) & 0xffff0000) | LOWORD((DWORD)(dw)+(val)))
401 /* Macros to access unaligned or wrong-endian WORDs and DWORDs. */
402 /* Note: These macros are semantically broken, at least for wrc. wrc
403 spits out data in the platform's current binary format, *not* in
404 little-endian format. These macros are used throughout the resource
405 code to load and store data to the resources. Since it is unlikely
406 that we'll ever be dealing with little-endian resource data, the
407 byte-swapping nature of these macros has been disabled. Rather than
408 remove the use of these macros from the resource loading code, the
409 macros have simply been disabled. In the future, someone may want
410 to reactivate these macros for other purposes. In that case, the
411 resource code will have to be modified to use different macros. */
414 #define PUT_WORD(ptr,w) (*(WORD *)(ptr) = (w))
415 #define GET_WORD(ptr) (*(WORD *)(ptr))
416 #define PUT_DWORD(ptr,dw) (*(DWORD *)(ptr) = (dw))
417 #define GET_DWORD(ptr) (*(DWORD *)(ptr))
419 #define PUT_WORD(ptr,w) (*(BYTE *)(ptr) = LOBYTE(w), \
420 *((BYTE *)(ptr) + 1) = HIBYTE(w))
421 #define GET_WORD(ptr) ((WORD)(*(BYTE *)(ptr) | \
422 (WORD)(*((BYTE *)(ptr)+1) << 8)))
423 #define PUT_DWORD(ptr,dw) (PUT_WORD((ptr),LOWORD(dw)), \
424 PUT_WORD((WORD *)(ptr)+1,HIWORD(dw)))
425 #define GET_DWORD(ptr) ((DWORD)(GET_WORD(ptr) | \
426 ((DWORD)GET_WORD((WORD *)(ptr)+1) << 16)))
429 /* min and max macros */
430 #define __max(a,b) (((a) > (b)) ? (a) : (b))
431 #define __min(a,b) (((a) < (b)) ? (a) : (b))
433 #define max(a,b) (((a) > (b)) ? (a) : (b))
436 #define min(a,b) (((a) < (b)) ? (a) : (b))
439 #define _MAX_PATH 260
443 #define _MAX_FNAME 255
446 #define HFILE_ERROR16 ((HFILE16)-1)
447 #define HFILE_ERROR ((HFILE)-1)
449 /* The SIZE structure */
450 typedef struct tagSIZE
454 } SIZE
, *PSIZE
, *LPSIZE
;
456 typedef SIZE SIZEL
, *PSIZEL
, *LPSIZEL
;
458 #define CONV_SIZE16TO32(s16,s32) \
459 ((s32)->cx = (INT)(s16)->cx, (s32)->cy = (INT)(s16)->cy)
460 #define CONV_SIZE32TO16(s32,s16) \
461 ((s16)->cx = (INT16)(s32)->cx, (s16)->cy = (INT16)(s32)->cy)
463 /* The POINT structure */
464 typedef struct tagPOINT
468 } POINT
, *PPOINT
, *LPPOINT
;
470 typedef struct _POINTL
476 #define CONV_POINT16TO32(p16,p32) \
477 ((p32)->x = (INT)(p16)->x, (p32)->y = (INT)(p16)->y)
478 #define CONV_POINT32TO16(p32,p16) \
479 ((p16)->x = (INT16)(p32)->x, (p16)->y = (INT16)(p32)->y)
481 #define MAKEPOINT16(l) (*((POINT16 *)&(l)))
483 /* The POINTS structure */
485 typedef struct tagPOINTS
489 } POINTS
, *PPOINTS
, *LPPOINTS
;
492 #define MAKEPOINTS(l) (*((POINTS *)&(l)))
495 /* The RECT structure */
496 typedef struct tagRECT
502 } RECT
, *PRECT
, *LPRECT
;
503 typedef const RECT
*LPCRECT
;
506 typedef struct tagRECTL
512 } RECTL
, *PRECTL
, *LPRECTL
;
514 typedef const RECTL
*LPCRECTL
;
516 #define CONV_RECT16TO32(r16,r32) \
517 ((r32)->left = (INT)(r16)->left, (r32)->top = (INT)(r16)->top, \
518 (r32)->right = (INT)(r16)->right, (r32)->bottom = (INT)(r16)->bottom)
519 #define CONV_RECT32TO16(r32,r16) \
520 ((r16)->left = (INT16)(r32)->left, (r16)->top = (INT16)(r32)->top, \
521 (r16)->right = (INT16)(r32)->right, (r16)->bottom = (INT16)(r32)->bottom)
527 #endif /* __WINE_WINDEF_H */