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__))
121 # error You need gcc >= 2.7 to build Wine on a 386
122 # endif /* __GNUC__ */
126 #endif /* __i386__ */
128 #define CALLBACK __stdcall
129 #define WINAPI __stdcall
130 #define APIPRIVATE __stdcall
131 #define PASCAL __stdcall
132 #define pascal __stdcall
133 #define _pascal __stdcall
134 #define _stdcall __stdcall
135 #define _fastcall __stdcall
136 #define __fastcall __stdcall
137 #define __export __stdcall
138 #define CDECL __cdecl
139 #define _CDECL __cdecl
140 #define cdecl __cdecl
141 #define _cdecl __cdecl
142 #define WINAPIV __cdecl
143 #define APIENTRY WINAPI
149 #define __declspec(x)
154 /* Standard data types. These are the same for emulator and library. */
158 typedef unsigned int UINT
;
159 typedef unsigned short WORD
;
160 typedef unsigned long DWORD
;
161 typedef unsigned long ULONG
;
162 typedef unsigned char BYTE
;
165 typedef unsigned short USHORT
;
167 typedef unsigned char UCHAR
;
168 /* Some systems might have wchar_t, but we really need 16 bit characters */
169 typedef unsigned short WCHAR
;
172 typedef double DOUBLE
;
174 /* FIXME: Wine does not compile with strict on, therefore strict
175 * handles are presently only usable on machines where sizeof(UINT) ==
176 * sizeof(void*). HANDLEs are supposed to be void* but a large amount
177 * of WINE code operates on HANDLES as if they are UINTs. So to WINE
178 * they exist as UINTs but to the Winelib user who turns on strict,
179 * they exist as void*. If there is a size difference between UINT and
180 * void* then things get ugly. */
182 typedef VOID
* HANDLE
;
188 typedef HANDLE
*LPHANDLE
;
190 /* Integer types. These are the same for emulator and library. */
193 typedef LONG HRESULT
;
194 typedef LONG LRESULT
;
196 typedef WORD CATCHBUF
[9];
197 typedef WORD
*LPCATCHBUF
;
198 typedef HANDLE HHOOK
;
199 typedef HANDLE HMONITOR
;
204 /* Pointers types. These are the same for emulator and library. */
207 typedef const void *PCVOID
;
209 typedef UCHAR
*PUCHAR
;
212 typedef USHORT
*PUSHORT
;
213 typedef SHORT
*PSHORT
;
214 typedef ULONG
*PULONG
;
216 typedef DWORD
*PDWORD
;
217 /* common win32 types */
220 typedef const CHAR
*LPCSTR
;
221 typedef const CHAR
*PCSTR
;
222 typedef WCHAR
*LPWSTR
;
223 typedef WCHAR
*PWSTR
;
224 typedef const WCHAR
*LPCWSTR
;
225 typedef const WCHAR
*PCWSTR
;
226 typedef BYTE
*LPBYTE
;
227 typedef WORD
*LPWORD
;
228 typedef DWORD
*LPDWORD
;
229 typedef LONG
*LPLONG
;
230 typedef VOID
*LPVOID
;
231 typedef const VOID
*LPCVOID
;
235 typedef UINT
*LPUINT
;
236 typedef FLOAT
*PFLOAT
;
237 typedef FLOAT
*LPFLOAT
;
239 typedef BOOL
*LPBOOL
;
241 /* Handle types that exist both in Win16 and Win32. */
244 #define DECLARE_HANDLE(a) \
245 typedef struct a##__ { int unused; } *a; \
249 #define DECLARE_HANDLE(a) \
255 DECLARE_HANDLE(HACMDRIVERID
);
256 DECLARE_HANDLE(HACMDRIVER
);
257 DECLARE_HANDLE(HACMOBJ
);
258 DECLARE_HANDLE(HACMSTREAM
);
259 DECLARE_HANDLE(HMETAFILEPICT
);
261 DECLARE_HANDLE(HACCEL
);
262 DECLARE_HANDLE(HBITMAP
);
263 DECLARE_HANDLE(HBRUSH
);
264 DECLARE_HANDLE(HCOLORSPACE
);
266 DECLARE_HANDLE(HDROP
);
267 DECLARE_HANDLE(HDRVR
);
268 DECLARE_HANDLE(HDWP
);
269 DECLARE_HANDLE(HENHMETAFILE
);
271 DECLARE_HANDLE(HFONT
);
272 DECLARE_HANDLE(HICON
);
273 DECLARE_HANDLE(HINSTANCE
);
274 DECLARE_HANDLE(HKEY
);
275 DECLARE_HANDLE(HMENU
);
276 DECLARE_HANDLE(HMETAFILE
);
277 DECLARE_HANDLE(HMIDI
);
278 DECLARE_HANDLE(HMIDIIN
);
279 DECLARE_HANDLE(HMIDIOUT
);
280 DECLARE_HANDLE(HMIDISTRM
);
281 DECLARE_HANDLE(HMIXER
);
282 DECLARE_HANDLE(HMIXEROBJ
);
283 DECLARE_HANDLE(HMMIO
);
284 DECLARE_HANDLE(HPALETTE
);
285 DECLARE_HANDLE(HPEN
);
286 DECLARE_HANDLE(HQUEUE
);
287 DECLARE_HANDLE(HRGN
);
288 DECLARE_HANDLE(HRSRC
);
289 DECLARE_HANDLE(HTASK
);
290 DECLARE_HANDLE(HWAVE
);
291 DECLARE_HANDLE(HWAVEIN
);
292 DECLARE_HANDLE(HWAVEOUT
);
293 DECLARE_HANDLE(HWINSTA
);
294 DECLARE_HANDLE(HDESK
);
295 DECLARE_HANDLE(HWND
);
297 DECLARE_HANDLE(HRASCONN
);
299 /* Handle types that must remain interchangeable even with strict on */
301 typedef HINSTANCE HMODULE
;
302 typedef HANDLE HGDIOBJ
;
303 typedef HANDLE HGLOBAL
;
304 typedef HANDLE HLOCAL
;
305 typedef HANDLE GLOBALHANDLE
;
306 typedef HANDLE LOCALHANDLE
;
307 typedef HICON HCURSOR
;
309 /* Callback function pointers types */
311 typedef BOOL
CALLBACK (*DATEFMT_ENUMPROCA
)(LPSTR
);
312 typedef BOOL
CALLBACK (*DATEFMT_ENUMPROCW
)(LPWSTR
);
313 DECL_WINELIB_TYPE_AW(DATEFMT_ENUMPROC
)
314 typedef BOOL
CALLBACK (*DLGPROC
)(HWND
,UINT
,WPARAM
,LPARAM
);
315 typedef LRESULT
CALLBACK (*DRIVERPROC
)(DWORD
,HDRVR
,UINT
,LPARAM
,LPARAM
);
316 typedef INT
CALLBACK (*EDITWORDBREAKPROCA
)(LPSTR
,INT
,INT
,INT
);
317 typedef INT
CALLBACK (*EDITWORDBREAKPROCW
)(LPWSTR
,INT
,INT
,INT
);
318 DECL_WINELIB_TYPE_AW(EDITWORDBREAKPROC
)
319 typedef LRESULT
CALLBACK (*FARPROC
)();
320 typedef INT
CALLBACK (*PROC
)();
321 typedef BOOL
CALLBACK (*GRAYSTRINGPROC
)(HDC
,LPARAM
,INT
);
322 typedef LRESULT
CALLBACK (*HOOKPROC
)(INT
,WPARAM
,LPARAM
);
323 typedef BOOL
CALLBACK (*PROPENUMPROCA
)(HWND
,LPCSTR
,HANDLE
);
324 typedef BOOL
CALLBACK (*PROPENUMPROCW
)(HWND
,LPCWSTR
,HANDLE
);
325 DECL_WINELIB_TYPE_AW(PROPENUMPROC
)
326 typedef BOOL
CALLBACK (*PROPENUMPROCEXA
)(HWND
,LPCSTR
,HANDLE
,LPARAM
);
327 typedef BOOL
CALLBACK (*PROPENUMPROCEXW
)(HWND
,LPCWSTR
,HANDLE
,LPARAM
);
328 DECL_WINELIB_TYPE_AW(PROPENUMPROCEX
)
329 typedef BOOL
CALLBACK (*TIMEFMT_ENUMPROCA
)(LPSTR
);
330 typedef BOOL
CALLBACK (*TIMEFMT_ENUMPROCW
)(LPWSTR
);
331 DECL_WINELIB_TYPE_AW(TIMEFMT_ENUMPROC
)
332 typedef VOID
CALLBACK (*TIMERPROC
)(HWND
,UINT
,UINT
,DWORD
);
333 typedef BOOL
CALLBACK (*WNDENUMPROC
)(HWND
,LPARAM
);
334 typedef LRESULT
CALLBACK (*WNDPROC
)(HWND
,UINT
,WPARAM
,LPARAM
);
336 /* Define some empty macros for compatibility with Windows code. */
348 #endif /* __WINE__ */
352 /* Macro for structure packing. */
355 #define WINE_PACKED __attribute__((packed))
356 #define WINE_UNUSED __attribute__((unused))
357 #define WINE_NORETURN __attribute__((noreturn))
359 #define WINE_PACKED /* nothing */
360 #define WINE_UNUSED /* nothing */
361 #define WINE_NORETURN /* nothing */
364 /* Macros to split words and longs. */
366 #define LOBYTE(w) ((BYTE)(WORD)(w))
367 #define HIBYTE(w) ((BYTE)((WORD)(w) >> 8))
369 #define LOWORD(l) ((WORD)(DWORD)(l))
370 #define HIWORD(l) ((WORD)((DWORD)(l) >> 16))
372 #define SLOWORD(l) ((SHORT)(LONG)(l))
373 #define SHIWORD(l) ((SHORT)((LONG)(l) >> 16))
375 #define MAKEWORD(low,high) ((WORD)(((BYTE)(low)) | ((WORD)((BYTE)(high))) << 8))
376 #define MAKELONG(low,high) ((LONG)(((WORD)(low)) | (((DWORD)((WORD)(high))) << 16)))
377 #define MAKELPARAM(low,high) ((LPARAM)MAKELONG(low,high))
378 #define MAKEWPARAM(low,high) ((WPARAM)MAKELONG(low,high))
379 #define MAKELRESULT(low,high) ((LRESULT)MAKELONG(low,high))
380 #define MAKEINTATOM(atom) ((LPCSTR)MAKELONG((atom),0))
382 #define SELECTOROF(ptr) (HIWORD(ptr))
383 #define OFFSETOF(ptr) (LOWORD(ptr))
386 /* macros to set parts of a DWORD (not in the Windows API) */
387 #define SET_LOWORD(dw,val) ((dw) = ((dw) & 0xffff0000) | LOWORD(val))
388 #define SET_LOBYTE(dw,val) ((dw) = ((dw) & 0xffffff00) | LOBYTE(val))
389 #define SET_HIBYTE(dw,val) ((dw) = ((dw) & 0xffff00ff) | (LOBYTE(val) << 8))
390 #define ADD_LOWORD(dw,val) ((dw) = ((dw) & 0xffff0000) | LOWORD((DWORD)(dw)+(val)))
393 /* Macros to access unaligned or wrong-endian WORDs and DWORDs. */
394 /* Note: These macros are semantically broken, at least for wrc. wrc
395 spits out data in the platform's current binary format, *not* in
396 little-endian format. These macros are used throughout the resource
397 code to load and store data to the resources. Since it is unlikely
398 that we'll ever be dealing with little-endian resource data, the
399 byte-swapping nature of these macros has been disabled. Rather than
400 remove the use of these macros from the resource loading code, the
401 macros have simply been disabled. In the future, someone may want
402 to reactivate these macros for other purposes. In that case, the
403 resource code will have to be modified to use different macros. */
406 #define PUT_WORD(ptr,w) (*(WORD *)(ptr) = (w))
407 #define GET_WORD(ptr) (*(WORD *)(ptr))
408 #define PUT_DWORD(ptr,dw) (*(DWORD *)(ptr) = (dw))
409 #define GET_DWORD(ptr) (*(DWORD *)(ptr))
411 #define PUT_WORD(ptr,w) (*(BYTE *)(ptr) = LOBYTE(w), \
412 *((BYTE *)(ptr) + 1) = HIBYTE(w))
413 #define GET_WORD(ptr) ((WORD)(*(BYTE *)(ptr) | \
414 (WORD)(*((BYTE *)(ptr)+1) << 8)))
415 #define PUT_DWORD(ptr,dw) (PUT_WORD((ptr),LOWORD(dw)), \
416 PUT_WORD((WORD *)(ptr)+1,HIWORD(dw)))
417 #define GET_DWORD(ptr) ((DWORD)(GET_WORD(ptr) | \
418 ((DWORD)GET_WORD((WORD *)(ptr)+1) << 16)))
421 /* min and max macros */
422 #define __max(a,b) (((a) > (b)) ? (a) : (b))
423 #define __min(a,b) (((a) < (b)) ? (a) : (b))
425 #define max(a,b) (((a) > (b)) ? (a) : (b))
428 #define min(a,b) (((a) < (b)) ? (a) : (b))
431 #define _MAX_PATH 260
435 #define _MAX_FNAME 255
438 #define HFILE_ERROR ((HFILE)-1)
440 /* The SIZE structure */
441 typedef struct tagSIZE
445 } SIZE
, *PSIZE
, *LPSIZE
;
447 typedef SIZE SIZEL
, *PSIZEL
, *LPSIZEL
;
449 /* The POINT structure */
450 typedef struct tagPOINT
454 } POINT
, *PPOINT
, *LPPOINT
;
456 typedef struct _POINTL
462 /* The POINTS structure */
464 typedef struct tagPOINTS
468 } POINTS
, *PPOINTS
, *LPPOINTS
;
470 /* The RECT structure */
471 typedef struct tagRECT
477 } RECT
, *PRECT
, *LPRECT
;
478 typedef const RECT
*LPCRECT
;
481 typedef struct tagRECTL
487 } RECTL
, *PRECTL
, *LPRECTL
;
489 typedef const RECTL
*LPCRECTL
;
495 #endif /* __WINE_WINDEF_H */