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 #else /* !defined(NONAMELESSUNION) */
94 #define DUMMYUNIONNAME u
95 #define DUMMYUNIONNAME1 u1
96 #define DUMMYUNIONNAME2 u2
97 #define DUMMYUNIONNAME3 u3
98 #define DUMMYUNIONNAME4 u4
99 #define DUMMYUNIONNAME5 u5
100 #endif /* !defined(NONAMELESSUNION) */
102 /* Calling conventions definitions */
105 # if defined(__GNUC__) && ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 7)))
106 # define __stdcall __attribute__((__stdcall__))
107 # define __cdecl __attribute__((__cdecl__))
108 # define __RESTORE_ES __asm__ __volatile__("pushl %ds\n\tpopl %es")
110 # error You need gcc >= 2.7 to build Wine on a 386
111 # endif /* __GNUC__ */
115 # define __RESTORE_ES
116 #endif /* __i386__ */
118 #define CALLBACK __stdcall
119 #define WINAPI __stdcall
120 #define APIPRIVATE __stdcall
121 #define PASCAL __stdcall
122 #define pascal __stdcall
123 #define _pascal __stdcall
124 #define _stdcall __stdcall
125 #define _fastcall __stdcall
126 #define __export __stdcall
127 #define CDECL __cdecl
128 #define _CDECL __cdecl
129 #define cdecl __cdecl
130 #define _cdecl __cdecl
131 #define WINAPIV __cdecl
132 #define APIENTRY WINAPI
134 #define __declspec(x)
140 /* Standard data types. These are the same for emulator and library. */
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
;
158 typedef double DOUBLE
;
159 typedef double LONGLONG
;
160 typedef double ULONGLONG
;
162 /* FIXME: Wine does not compile with strict on, therefore strict
163 * handles are presently only usable on machines where sizeof(UINT) ==
164 * sizeof(void*). HANDLEs are supposed to be void* but a large amount
165 * of WINE code operates on HANDLES as if they are UINTs. So to WINE
166 * they exist as UINTs but to the Winelib user who turns on strict,
167 * they exist as void*. If there is a size difference between UINT and
168 * void* then things get ugly. */
170 typedef VOID
* HANDLE
;
176 typedef HANDLE
*LPHANDLE
;
178 /* Integer types. These are the same for emulator and library. */
181 typedef LONG HRESULT
;
182 typedef LONG LRESULT
;
184 typedef WORD CATCHBUF
[9];
185 typedef WORD
*LPCATCHBUF
;
186 typedef HANDLE HHOOK
;
187 typedef HANDLE HMONITOR
;
190 typedef DWORD LCTYPE
;
193 /* Pointers types. These are the same for emulator and library. */
196 typedef const void *PCVOID
;
198 typedef UCHAR
*PUCHAR
;
201 typedef ULONG
*PULONG
;
203 typedef DWORD
*PDWORD
;
204 /* common win32 types */
207 typedef const CHAR
*LPCSTR
;
208 typedef const CHAR
*PCSTR
;
209 typedef WCHAR
*LPWSTR
;
210 typedef WCHAR
*PWSTR
;
211 typedef const WCHAR
*LPCWSTR
;
212 typedef const WCHAR
*PCWSTR
;
213 typedef BYTE
*LPBYTE
;
214 typedef WORD
*LPWORD
;
215 typedef DWORD
*LPDWORD
;
216 typedef LONG
*LPLONG
;
217 typedef VOID
*LPVOID
;
218 typedef const VOID
*LPCVOID
;
222 typedef UINT
*LPUINT
;
223 typedef FLOAT
*PFLOAT
;
224 typedef FLOAT
*LPFLOAT
;
226 typedef BOOL
*LPBOOL
;
228 /* Special case: a segmented pointer is just a pointer in the user's code. */
231 typedef DWORD SEGPTR
;
233 typedef void* SEGPTR
;
234 #endif /* __WINE__ */
236 /* Handle types that exist both in Win16 and Win32. */
239 #define DECLARE_HANDLE(a) \
240 typedef struct a##__ { int unused; } *a; \
244 #define DECLARE_HANDLE(a) \
250 DECLARE_HANDLE(HACMDRIVERID
);
251 DECLARE_HANDLE(HACMDRIVER
);
252 DECLARE_HANDLE(HACMOBJ
);
253 DECLARE_HANDLE(HACMSTREAM
);
254 DECLARE_HANDLE(HMETAFILEPICT
);
256 DECLARE_HANDLE(HACCEL
);
257 DECLARE_HANDLE(HBITMAP
);
258 DECLARE_HANDLE(HBRUSH
);
259 DECLARE_HANDLE(HCOLORSPACE
);
260 DECLARE_HANDLE(HCURSOR
);
262 DECLARE_HANDLE(HDROP
);
263 DECLARE_HANDLE(HDRVR
);
264 DECLARE_HANDLE(HDWP
);
265 DECLARE_HANDLE(HENHMETAFILE
);
266 DECLARE_HANDLE(HFILE
);
267 DECLARE_HANDLE(HFONT
);
268 DECLARE_HANDLE(HICON
);
269 DECLARE_HANDLE(HINSTANCE
);
270 DECLARE_HANDLE(HKEY
);
271 DECLARE_HANDLE(HMENU
);
272 DECLARE_HANDLE(HMETAFILE
);
273 DECLARE_HANDLE(HMIDI
);
274 DECLARE_HANDLE(HMIDIIN
);
275 DECLARE_HANDLE(HMIDIOUT
);
276 DECLARE_HANDLE(HMIDISTRM
);
277 DECLARE_HANDLE(HMIXER
);
278 DECLARE_HANDLE(HMIXEROBJ
);
279 DECLARE_HANDLE(HMMIO
);
280 DECLARE_HANDLE(HPALETTE
);
281 DECLARE_HANDLE(HPEN
);
282 DECLARE_HANDLE(HQUEUE
);
283 DECLARE_HANDLE(HRGN
);
284 DECLARE_HANDLE(HRSRC
);
285 DECLARE_HANDLE(HTASK
);
286 DECLARE_HANDLE(HWAVE
);
287 DECLARE_HANDLE(HWAVEIN
);
288 DECLARE_HANDLE(HWAVEOUT
);
289 DECLARE_HANDLE(HWINSTA
);
290 DECLARE_HANDLE(HDESK
);
291 DECLARE_HANDLE(HWND
);
294 DECLARE_HANDLE(HRASCONN
);
295 #undef DECLARE_HANDLE
297 /* Handle types that must remain interchangeable even with strict on */
299 typedef HINSTANCE HMODULE
;
300 typedef HANDLE HGDIOBJ
;
301 typedef HANDLE HGLOBAL
;
302 typedef HANDLE HLOCAL
;
304 /* Callback function pointers types */
306 typedef BOOL (CALLBACK
* DATEFMT_ENUMPROCA
)(LPSTR
);
307 typedef BOOL (CALLBACK
* DATEFMT_ENUMPROCW
)(LPWSTR
);
308 DECL_WINELIB_TYPE_AW(DATEFMT_ENUMPROC
)
309 typedef BOOL (CALLBACK
*DLGPROC
)(HWND
,UINT
,WPARAM
,LPARAM
);
310 typedef LRESULT (CALLBACK
*DRIVERPROC
)(DWORD
,HDRVR
,UINT
,LPARAM
,LPARAM
);
311 typedef INT (CALLBACK
*EDITWORDBREAKPROCA
)(LPSTR
,INT
,INT
,INT
);
312 typedef INT (CALLBACK
*EDITWORDBREAKPROCW
)(LPWSTR
,INT
,INT
,INT
);
313 DECL_WINELIB_TYPE_AW(EDITWORDBREAKPROC
)
314 typedef LRESULT (CALLBACK
*FARPROC
)();
315 typedef INT (CALLBACK
*PROC
)();
316 typedef BOOL (CALLBACK
*GRAYSTRINGPROC
)(HDC
,LPARAM
,INT
);
317 typedef LRESULT (CALLBACK
*HOOKPROC
)(INT
,WPARAM
,LPARAM
);
318 typedef BOOL (CALLBACK
*PROPENUMPROCA
)(HWND
,LPCSTR
,HANDLE
);
319 typedef BOOL (CALLBACK
*PROPENUMPROCW
)(HWND
,LPCWSTR
,HANDLE
);
320 DECL_WINELIB_TYPE_AW(PROPENUMPROC
)
321 typedef BOOL (CALLBACK
*PROPENUMPROCEXA
)(HWND
,LPCSTR
,HANDLE
,LPARAM
);
322 typedef BOOL (CALLBACK
*PROPENUMPROCEXW
)(HWND
,LPCWSTR
,HANDLE
,LPARAM
);
323 DECL_WINELIB_TYPE_AW(PROPENUMPROCEX
)
324 typedef BOOL (CALLBACK
* TIMEFMT_ENUMPROCA
)(LPSTR
);
325 typedef BOOL (CALLBACK
* TIMEFMT_ENUMPROCW
)(LPWSTR
);
326 DECL_WINELIB_TYPE_AW(TIMEFMT_ENUMPROC
)
327 typedef VOID (CALLBACK
*TIMERPROC
)(HWND
,UINT
,UINT
,DWORD
);
328 typedef LRESULT (CALLBACK
*WNDENUMPROC
)(HWND
,LPARAM
);
329 typedef LRESULT (CALLBACK
*WNDPROC
)(HWND
,UINT
,WPARAM
,LPARAM
);
331 /*----------------------------------------------------------------------------
332 ** FIXME: Better isolate Wine's reliance on the xxx16 type definitions.
333 ** For now, we just isolate them to make the situation clear.
334 **--------------------------------------------------------------------------*/
335 #include "wine/windef16.h"
337 /* Define some empty macros for compatibility with Windows code. */
349 #endif /* __WINE__ */
351 /* Macro for structure packing. */
354 #define WINE_PACKED __attribute__ ((packed))
355 #define WINE_UNUSED __attribute__ ((unused))
357 #define WINE_PACKED /* nothing */
358 #define WINE_UNUSED /* nothing */
361 /* Macros to split words and longs. */
363 #define LOBYTE(w) ((BYTE)(WORD)(w))
364 #define HIBYTE(w) ((BYTE)((WORD)(w) >> 8))
366 #define LOWORD(l) ((WORD)(DWORD)(l))
367 #define HIWORD(l) ((WORD)((DWORD)(l) >> 16))
369 #define SLOWORD(l) ((INT16)(LONG)(l))
370 #define SHIWORD(l) ((INT16)((LONG)(l) >> 16))
372 #define MAKEWORD(low,high) ((WORD)(((BYTE)(low)) | ((WORD)((BYTE)(high))) << 8))
373 #define MAKELONG(low,high) ((LONG)(((WORD)(low)) | (((DWORD)((WORD)(high))) << 16)))
374 #define MAKELPARAM(low,high) ((LPARAM)MAKELONG(low,high))
375 #define MAKEWPARAM(low,high) ((WPARAM)MAKELONG(low,high))
376 #define MAKELRESULT(low,high) ((LRESULT)MAKELONG(low,high))
377 #define MAKEINTATOM(atom) ((LPCSTR)MAKELONG((atom),0))
379 #define SELECTOROF(ptr) (HIWORD(ptr))
380 #define OFFSETOF(ptr) (LOWORD(ptr))
383 /* macros to set parts of a DWORD (not in the Windows API) */
384 #define SET_LOWORD(dw,val) ((dw) = ((dw) & 0xffff0000) | LOWORD(val))
385 #define SET_LOBYTE(dw,val) ((dw) = ((dw) & 0xffffff00) | LOBYTE(val))
386 #define SET_HIBYTE(dw,val) ((dw) = ((dw) & 0xffff00ff) | (LOWORD(val) & 0xff00))
387 #define ADD_LOWORD(dw,val) ((dw) = ((dw) & 0xffff0000) | LOWORD((DWORD)(dw)+(val)))
390 /* Macros to access unaligned or wrong-endian WORDs and DWORDs. */
391 /* Note: These macros are semantically broken, at least for wrc. wrc
392 spits out data in the platform's current binary format, *not* in
393 little-endian format. These macros are used throughout the resource
394 code to load and store data to the resources. Since it is unlikely
395 that we'll ever be dealing with little-endian resource data, the
396 byte-swapping nature of these macros has been disabled. Rather than
397 remove the use of these macros from the resource loading code, the
398 macros have simply been disabled. In the future, someone may want
399 to reactivate these macros for other purposes. In that case, the
400 resource code will have to be modified to use different macros. */
403 #define PUT_WORD(ptr,w) (*(WORD *)(ptr) = (w))
404 #define GET_WORD(ptr) (*(WORD *)(ptr))
405 #define PUT_DWORD(ptr,dw) (*(DWORD *)(ptr) = (dw))
406 #define GET_DWORD(ptr) (*(DWORD *)(ptr))
408 #define PUT_WORD(ptr,w) (*(BYTE *)(ptr) = LOBYTE(w), \
409 *((BYTE *)(ptr) + 1) = HIBYTE(w))
410 #define GET_WORD(ptr) ((WORD)(*(BYTE *)(ptr) | \
411 (WORD)(*((BYTE *)(ptr)+1) << 8)))
412 #define PUT_DWORD(ptr,dw) (PUT_WORD((ptr),LOWORD(dw)), \
413 PUT_WORD((WORD *)(ptr)+1,HIWORD(dw)))
414 #define GET_DWORD(ptr) ((DWORD)(GET_WORD(ptr) | \
415 ((DWORD)GET_WORD((WORD *)(ptr)+1) << 16)))
418 /* MIN and MAX macros */
423 #define MAX(a,b) (((a) > (b)) ? (a) : (b))
428 #define MIN(a,b) (((a) < (b)) ? (a) : (b))
430 #define __max(a,b) MAX(a,b)
431 #define __min(a,b) MIN(a,b)
433 #define max(a,b) MAX(a,b)
436 #define min(a,b) MIN(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
;
457 typedef SIZE SIZEL
, *PSIZEL
, *LPSIZEL
;
459 #define CONV_SIZE16TO32(s16,s32) \
460 ((s32)->cx = (INT)(s16)->cx, (s32)->cy = (INT)(s16)->cy)
461 #define CONV_SIZE32TO16(s32,s16) \
462 ((s16)->cx = (INT16)(s32)->cx, (s16)->cy = (INT16)(s32)->cy)
464 /* The POINT structure */
465 typedef struct tagPOINT
469 } POINT
, *PPOINT
, *LPPOINT
;
471 typedef struct _POINTL
477 #define CONV_POINT16TO32(p16,p32) \
478 ((p32)->x = (INT)(p16)->x, (p32)->y = (INT)(p16)->y)
479 #define CONV_POINT32TO16(p32,p16) \
480 ((p16)->x = (INT16)(p32)->x, (p16)->y = (INT16)(p32)->y)
482 #define MAKEPOINT16(l) (*((POINT16 *)&(l)))
484 /* The POINTS structure */
486 typedef struct tagPOINTS
490 } POINTS
, *PPOINTS
, *LPPOINTS
;
493 #define MAKEPOINTS(l) (*((POINTS *)&(l)))
496 /* The RECT structure */
497 typedef struct tagRECT
503 } RECT
, *PRECT
, *LPRECT
;
504 typedef const RECT
*LPCRECT
;
507 typedef struct tagRECTL
513 } RECTL
, *PRECTL
, *LPRECTL
;
515 typedef const RECTL
*LPCRECTL
;
517 #define CONV_RECT16TO32(r16,r32) \
518 ((r32)->left = (INT)(r16)->left, (r32)->top = (INT)(r16)->top, \
519 (r32)->right = (INT)(r16)->right, (r32)->bottom = (INT)(r16)->bottom)
520 #define CONV_RECT32TO16(r32,r16) \
521 ((r16)->left = (INT16)(r32)->left, (r16)->top = (INT16)(r32)->top, \
522 (r16)->right = (INT16)(r32)->right, (r16)->bottom = (INT16)(r32)->bottom)
528 #endif /* __WINE_WINDEF_H */