2 * Basic types definitions
4 * Copyright 1996 Alexandre Julliard
7 #ifndef __WINE_WINDEF_H
8 #define __WINE_WINDEF_H
18 /* Misc. constants. */
37 /* Macros to map Winelib names to the correct implementation name */
38 /* depending on __WINE__ and UNICODE macros. */
39 /* Note that Winelib is purely Win32. */
42 # define WINELIB_NAME_AW(func) \
43 func##_must_be_suffixed_with_W_or_A_in_this_context \
44 func##_must_be_suffixed_with_W_or_A_in_this_context
47 # define WINELIB_NAME_AW(func) func##W
49 # define WINELIB_NAME_AW(func) func##A
54 # define DECL_WINELIB_TYPE_AW(type) /* nothing */
56 # define DECL_WINELIB_TYPE_AW(type) typedef WINELIB_NAME_AW(type) type;
60 # define NONAMELESSSTRUCT
61 # define NONAMELESSUNION
63 /* Anonymous struct support starts with gcc/g++ 2.96 */
64 # if !defined(NONAMELESSSTRUCT) && defined(__GNUC__) && ((__GNUC__ < 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ < 96)))
65 # define NONAMELESSSTRUCT
67 /* Anonymous unions support starts with gcc 2.96/g++ 2.95 */
68 # if !defined(NONAMELESSUNION) && defined(__GNUC__) && ((__GNUC__ < 2) || ((__GNUC__ == 2) && ((__GNUC_MINOR__ < 95) || ((__GNUC_MINOR__ == 95) && !defined(__cplusplus)))))
69 # define NONAMELESSUNION
73 #ifndef NONAMELESSSTRUCT
74 #define DUMMYSTRUCTNAME
75 #define DUMMYSTRUCTNAME1
76 #define DUMMYSTRUCTNAME2
77 #define DUMMYSTRUCTNAME3
78 #define DUMMYSTRUCTNAME4
79 #define DUMMYSTRUCTNAME5
80 #else /* !defined(NONAMELESSSTRUCT) */
81 #define DUMMYSTRUCTNAME s
82 #define DUMMYSTRUCTNAME1 s1
83 #define DUMMYSTRUCTNAME2 s2
84 #define DUMMYSTRUCTNAME3 s3
85 #define DUMMYSTRUCTNAME4 s4
86 #define DUMMYSTRUCTNAME5 s5
87 #endif /* !defined(NONAMELESSSTRUCT) */
89 #ifndef NONAMELESSUNION
90 #define DUMMYUNIONNAME
91 #define DUMMYUNIONNAME1
92 #define DUMMYUNIONNAME2
93 #define DUMMYUNIONNAME3
94 #define DUMMYUNIONNAME4
95 #define DUMMYUNIONNAME5
96 #define DUMMYUNIONNAME6
97 #define DUMMYUNIONNAME7
98 #define DUMMYUNIONNAME8
99 #else /* !defined(NONAMELESSUNION) */
100 #define DUMMYUNIONNAME u
101 #define DUMMYUNIONNAME1 u1
102 #define DUMMYUNIONNAME2 u2
103 #define DUMMYUNIONNAME3 u3
104 #define DUMMYUNIONNAME4 u4
105 #define DUMMYUNIONNAME5 u5
106 #define DUMMYUNIONNAME6 u6
107 #define DUMMYUNIONNAME7 u7
108 #define DUMMYUNIONNAME8 u8
109 #endif /* !defined(NONAMELESSUNION) */
111 /* Calling conventions definitions */
117 # if defined(__GNUC__) && ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 7)))
118 # define __stdcall __attribute__((__stdcall__))
119 # define __cdecl __attribute__((__cdecl__))
120 # define __RESTORE_ES __asm__ __volatile__("pushl %ds\n\tpopl %es")
122 # error You need gcc >= 2.7 to build Wine on a 386
123 # endif /* __GNUC__ */
127 # define __RESTORE_ES
128 #endif /* __i386__ */
130 #define CALLBACK __stdcall
131 #define WINAPI __stdcall
132 #define APIPRIVATE __stdcall
133 #define PASCAL __stdcall
134 #define pascal __stdcall
135 #define _pascal __stdcall
136 #define _stdcall __stdcall
137 #define _fastcall __stdcall
138 #define __fastcall __stdcall
139 #define __export __stdcall
140 #define CDECL __cdecl
141 #define _CDECL __cdecl
142 #define cdecl __cdecl
143 #define _cdecl __cdecl
144 #define WINAPIV __cdecl
145 #define APIENTRY WINAPI
148 #define __declspec(x)
152 /* Standard data types. These are the same for emulator and library. */
156 typedef unsigned int UINT
;
157 typedef unsigned short WORD
;
158 typedef unsigned long DWORD
;
159 typedef unsigned long ULONG
;
160 typedef unsigned char BYTE
;
163 typedef unsigned short USHORT
;
165 typedef unsigned char UCHAR
;
166 /* Some systems might have wchar_t, but we really need 16 bit characters */
167 typedef unsigned short WCHAR
;
170 typedef double DOUBLE
;
172 /* FIXME: Wine does not compile with strict on, therefore strict
173 * handles are presently only usable on machines where sizeof(UINT) ==
174 * sizeof(void*). HANDLEs are supposed to be void* but a large amount
175 * of WINE code operates on HANDLES as if they are UINTs. So to WINE
176 * they exist as UINTs but to the Winelib user who turns on strict,
177 * they exist as void*. If there is a size difference between UINT and
178 * void* then things get ugly. */
180 typedef VOID
* HANDLE
;
186 typedef HANDLE
*LPHANDLE
;
188 /* Integer types. These are the same for emulator and library. */
191 typedef LONG HRESULT
;
192 typedef LONG LRESULT
;
194 typedef WORD CATCHBUF
[9];
195 typedef WORD
*LPCATCHBUF
;
196 typedef HANDLE HHOOK
;
197 typedef HANDLE HMONITOR
;
202 /* Pointers types. These are the same for emulator and library. */
205 typedef const void *PCVOID
;
207 typedef UCHAR
*PUCHAR
;
210 typedef USHORT
*PUSHORT
;
211 typedef SHORT
*PSHORT
;
212 typedef ULONG
*PULONG
;
214 typedef DWORD
*PDWORD
;
215 /* common win32 types */
218 typedef const CHAR
*LPCSTR
;
219 typedef const CHAR
*PCSTR
;
220 typedef WCHAR
*LPWSTR
;
221 typedef WCHAR
*PWSTR
;
222 typedef const WCHAR
*LPCWSTR
;
223 typedef const WCHAR
*PCWSTR
;
224 typedef BYTE
*LPBYTE
;
225 typedef WORD
*LPWORD
;
226 typedef DWORD
*LPDWORD
;
227 typedef LONG
*LPLONG
;
228 typedef VOID
*LPVOID
;
229 typedef const VOID
*LPCVOID
;
233 typedef UINT
*LPUINT
;
234 typedef FLOAT
*PFLOAT
;
235 typedef FLOAT
*LPFLOAT
;
237 typedef BOOL
*LPBOOL
;
239 /* Special case: a segmented pointer is just a pointer in the user's code. */
242 typedef DWORD SEGPTR
;
244 typedef void* SEGPTR
;
245 #endif /* __WINE__ */
247 /* Handle types that exist both in Win16 and Win32. */
250 #define DECLARE_HANDLE(a) \
251 typedef struct a##__ { int unused; } *a; \
255 #define DECLARE_HANDLE(a) \
261 DECLARE_HANDLE(HACMDRIVERID
);
262 DECLARE_HANDLE(HACMDRIVER
);
263 DECLARE_HANDLE(HACMOBJ
);
264 DECLARE_HANDLE(HACMSTREAM
);
265 DECLARE_HANDLE(HMETAFILEPICT
);
267 DECLARE_HANDLE(HACCEL
);
268 DECLARE_HANDLE(HBITMAP
);
269 DECLARE_HANDLE(HBRUSH
);
270 DECLARE_HANDLE(HCOLORSPACE
);
271 DECLARE_HANDLE(HCURSOR
);
273 DECLARE_HANDLE(HDROP
);
274 DECLARE_HANDLE(HDRVR
);
275 DECLARE_HANDLE(HDWP
);
276 DECLARE_HANDLE(HENHMETAFILE
);
278 DECLARE_HANDLE(HFONT
);
279 DECLARE_HANDLE(HICON
);
280 DECLARE_HANDLE(HINSTANCE
);
281 DECLARE_HANDLE(HKEY
);
282 DECLARE_HANDLE(HMENU
);
283 DECLARE_HANDLE(HMETAFILE
);
284 DECLARE_HANDLE(HMIDI
);
285 DECLARE_HANDLE(HMIDIIN
);
286 DECLARE_HANDLE(HMIDIOUT
);
287 DECLARE_HANDLE(HMIDISTRM
);
288 DECLARE_HANDLE(HMIXER
);
289 DECLARE_HANDLE(HMIXEROBJ
);
290 DECLARE_HANDLE(HMMIO
);
291 DECLARE_HANDLE(HPALETTE
);
292 DECLARE_HANDLE(HPEN
);
293 DECLARE_HANDLE(HQUEUE
);
294 DECLARE_HANDLE(HRGN
);
295 DECLARE_HANDLE(HRSRC
);
296 DECLARE_HANDLE(HTASK
);
297 DECLARE_HANDLE(HWAVE
);
298 DECLARE_HANDLE(HWAVEIN
);
299 DECLARE_HANDLE(HWAVEOUT
);
300 DECLARE_HANDLE(HWINSTA
);
301 DECLARE_HANDLE(HDESK
);
302 DECLARE_HANDLE(HWND
);
304 DECLARE_HANDLE(HRASCONN
);
306 /* Handle types that must remain interchangeable even with strict on */
308 typedef HINSTANCE HMODULE
;
309 typedef HANDLE HGDIOBJ
;
310 typedef HANDLE HGLOBAL
;
311 typedef HANDLE HLOCAL
;
312 typedef HANDLE GLOBALHANDLE
;
313 typedef HANDLE LOCALHANDLE
;
315 /* Callback function pointers types */
317 typedef BOOL
CALLBACK (*DATEFMT_ENUMPROCA
)(LPSTR
);
318 typedef BOOL
CALLBACK (*DATEFMT_ENUMPROCW
)(LPWSTR
);
319 DECL_WINELIB_TYPE_AW(DATEFMT_ENUMPROC
)
320 typedef BOOL
CALLBACK (*DLGPROC
)(HWND
,UINT
,WPARAM
,LPARAM
);
321 typedef LRESULT
CALLBACK (*DRIVERPROC
)(DWORD
,HDRVR
,UINT
,LPARAM
,LPARAM
);
322 typedef INT
CALLBACK (*EDITWORDBREAKPROCA
)(LPSTR
,INT
,INT
,INT
);
323 typedef INT
CALLBACK (*EDITWORDBREAKPROCW
)(LPWSTR
,INT
,INT
,INT
);
324 DECL_WINELIB_TYPE_AW(EDITWORDBREAKPROC
)
325 typedef LRESULT
CALLBACK (*FARPROC
)();
326 typedef INT
CALLBACK (*PROC
)();
327 typedef BOOL
CALLBACK (*GRAYSTRINGPROC
)(HDC
,LPARAM
,INT
);
328 typedef LRESULT
CALLBACK (*HOOKPROC
)(INT
,WPARAM
,LPARAM
);
329 typedef BOOL
CALLBACK (*PROPENUMPROCA
)(HWND
,LPCSTR
,HANDLE
);
330 typedef BOOL
CALLBACK (*PROPENUMPROCW
)(HWND
,LPCWSTR
,HANDLE
);
331 DECL_WINELIB_TYPE_AW(PROPENUMPROC
)
332 typedef BOOL
CALLBACK (*PROPENUMPROCEXA
)(HWND
,LPCSTR
,HANDLE
,LPARAM
);
333 typedef BOOL
CALLBACK (*PROPENUMPROCEXW
)(HWND
,LPCWSTR
,HANDLE
,LPARAM
);
334 DECL_WINELIB_TYPE_AW(PROPENUMPROCEX
)
335 typedef BOOL
CALLBACK (*TIMEFMT_ENUMPROCA
)(LPSTR
);
336 typedef BOOL
CALLBACK (*TIMEFMT_ENUMPROCW
)(LPWSTR
);
337 DECL_WINELIB_TYPE_AW(TIMEFMT_ENUMPROC
)
338 typedef VOID
CALLBACK (*TIMERPROC
)(HWND
,UINT
,UINT
,DWORD
);
339 typedef BOOL
CALLBACK (*WNDENUMPROC
)(HWND
,LPARAM
);
340 typedef LRESULT
CALLBACK (*WNDPROC
)(HWND
,UINT
,WPARAM
,LPARAM
);
342 /* Define some empty macros for compatibility with Windows code. */
354 #endif /* __WINE__ */
358 /* Macro for structure packing. */
361 #define WINE_PACKED __attribute__((packed))
362 #define WINE_UNUSED __attribute__((unused))
363 #define WINE_NORETURN __attribute__((noreturn))
365 #define WINE_PACKED /* nothing */
366 #define WINE_UNUSED /* nothing */
367 #define WINE_NORETURN /* nothing */
370 /* Macros to split words and longs. */
372 #define LOBYTE(w) ((BYTE)(WORD)(w))
373 #define HIBYTE(w) ((BYTE)((WORD)(w) >> 8))
375 #define LOWORD(l) ((WORD)(DWORD)(l))
376 #define HIWORD(l) ((WORD)((DWORD)(l) >> 16))
378 #define SLOWORD(l) ((SHORT)(LONG)(l))
379 #define SHIWORD(l) ((SHORT)((LONG)(l) >> 16))
381 #define MAKEWORD(low,high) ((WORD)(((BYTE)(low)) | ((WORD)((BYTE)(high))) << 8))
382 #define MAKELONG(low,high) ((LONG)(((WORD)(low)) | (((DWORD)((WORD)(high))) << 16)))
383 #define MAKELPARAM(low,high) ((LPARAM)MAKELONG(low,high))
384 #define MAKEWPARAM(low,high) ((WPARAM)MAKELONG(low,high))
385 #define MAKELRESULT(low,high) ((LRESULT)MAKELONG(low,high))
386 #define MAKEINTATOM(atom) ((LPCSTR)MAKELONG((atom),0))
388 #define SELECTOROF(ptr) (HIWORD(ptr))
389 #define OFFSETOF(ptr) (LOWORD(ptr))
392 /* macros to set parts of a DWORD (not in the Windows API) */
393 #define SET_LOWORD(dw,val) ((dw) = ((dw) & 0xffff0000) | LOWORD(val))
394 #define SET_LOBYTE(dw,val) ((dw) = ((dw) & 0xffffff00) | LOBYTE(val))
395 #define SET_HIBYTE(dw,val) ((dw) = ((dw) & 0xffff00ff) | (LOBYTE(val) << 8))
396 #define ADD_LOWORD(dw,val) ((dw) = ((dw) & 0xffff0000) | LOWORD((DWORD)(dw)+(val)))
399 /* Macros to access unaligned or wrong-endian WORDs and DWORDs. */
400 /* Note: These macros are semantically broken, at least for wrc. wrc
401 spits out data in the platform's current binary format, *not* in
402 little-endian format. These macros are used throughout the resource
403 code to load and store data to the resources. Since it is unlikely
404 that we'll ever be dealing with little-endian resource data, the
405 byte-swapping nature of these macros has been disabled. Rather than
406 remove the use of these macros from the resource loading code, the
407 macros have simply been disabled. In the future, someone may want
408 to reactivate these macros for other purposes. In that case, the
409 resource code will have to be modified to use different macros. */
412 #define PUT_WORD(ptr,w) (*(WORD *)(ptr) = (w))
413 #define GET_WORD(ptr) (*(WORD *)(ptr))
414 #define PUT_DWORD(ptr,dw) (*(DWORD *)(ptr) = (dw))
415 #define GET_DWORD(ptr) (*(DWORD *)(ptr))
417 #define PUT_WORD(ptr,w) (*(BYTE *)(ptr) = LOBYTE(w), \
418 *((BYTE *)(ptr) + 1) = HIBYTE(w))
419 #define GET_WORD(ptr) ((WORD)(*(BYTE *)(ptr) | \
420 (WORD)(*((BYTE *)(ptr)+1) << 8)))
421 #define PUT_DWORD(ptr,dw) (PUT_WORD((ptr),LOWORD(dw)), \
422 PUT_WORD((WORD *)(ptr)+1,HIWORD(dw)))
423 #define GET_DWORD(ptr) ((DWORD)(GET_WORD(ptr) | \
424 ((DWORD)GET_WORD((WORD *)(ptr)+1) << 16)))
427 /* min and max macros */
428 #define __max(a,b) (((a) > (b)) ? (a) : (b))
429 #define __min(a,b) (((a) < (b)) ? (a) : (b))
431 #define max(a,b) (((a) > (b)) ? (a) : (b))
434 #define min(a,b) (((a) < (b)) ? (a) : (b))
437 #define _MAX_PATH 260
441 #define _MAX_FNAME 255
444 #define HFILE_ERROR ((HFILE)-1)
446 /* The SIZE structure */
447 typedef struct tagSIZE
451 } SIZE
, *PSIZE
, *LPSIZE
;
453 typedef SIZE SIZEL
, *PSIZEL
, *LPSIZEL
;
455 /* The POINT structure */
456 typedef struct tagPOINT
460 } POINT
, *PPOINT
, *LPPOINT
;
462 typedef struct _POINTL
468 /* The POINTS structure */
470 typedef struct tagPOINTS
474 } POINTS
, *PPOINTS
, *LPPOINTS
;
476 /* The RECT structure */
477 typedef struct tagRECT
483 } RECT
, *PRECT
, *LPRECT
;
484 typedef const RECT
*LPCRECT
;
487 typedef struct tagRECTL
493 } RECTL
, *PRECTL
, *LPRECTL
;
495 typedef const RECTL
*LPCRECTL
;
501 #endif /* __WINE_WINDEF_H */