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) this_is_a_syntax_error this_is_a_syntax_error
44 # define WINELIB_NAME_AW(func) func##W
46 # define WINELIB_NAME_AW(func) func##A
51 # define DECL_WINELIB_TYPE_AW(type) /* nothing */
53 # define DECL_WINELIB_TYPE_AW(type) typedef WINELIB_NAME_AW(type) type;
57 /* Calling conventions definitions */
60 # if defined(__GNUC__) && (__GNUC__ == 2) && (__GNUC_MINOR__ >= 7)
61 # define __stdcall __attribute__((__stdcall__))
62 # define __cdecl __attribute__((__cdecl__))
63 # define __RESTORE_ES __asm__ __volatile__("pushl %ds\n\tpopl %es")
65 # error You need gcc >= 2.7 to build Wine on a 386
66 # endif /* __GNUC__ */
73 #define CALLBACK __stdcall
74 #define WINAPI __stdcall
75 #define APIPRIVATE __stdcall
76 #define PASCAL __stdcall
77 #define pascal __stdcall
78 #define _pascal __stdcall
79 #define _stdcall __stdcall
80 #define _fastcall __stdcall
81 #define __export __stdcall
83 #define _CDECL __cdecl
85 #define _cdecl __cdecl
86 #define WINAPIV __cdecl
87 #define APIENTRY WINAPI
95 /* Standard data types. These are the same for emulator and library. */
99 typedef unsigned short UINT16
;
101 typedef unsigned int UINT
;
102 typedef unsigned short WORD
;
103 typedef unsigned long DWORD
;
104 typedef unsigned long ULONG
;
105 typedef unsigned char BYTE
;
108 typedef unsigned short USHORT
;
110 typedef unsigned char UCHAR
;
111 /* Some systems might have wchar_t, but we really need 16 bit characters */
112 typedef unsigned short WCHAR
;
113 typedef unsigned short BOOL16
;
116 typedef long LONG_PTR
;
117 typedef unsigned long ULONG_PTR
;
118 typedef double DOUBLE
;
119 typedef double LONGLONG
;
120 typedef double ULONGLONG
;
122 /* FIXME: Wine does not compile with strict on, therefore strict
123 * handles are presently only usable on machines where sizeof(UINT) ==
124 * sizeof(void*). HANDLEs are supposed to be void* but a large amount
125 * of WINE code operates on HANDLES as if they are UINTs. So to WINE
126 * they exist as UINTs but to the Winelib user who turns on strict,
127 * they exist as void*. If there is a size difference between UINT and
128 * void* then things get ugly. */
130 typedef UINT16 HANDLE16
;
131 typedef VOID
* HANDLE
;
133 typedef UINT16 HANDLE16
;
137 typedef HANDLE16
*LPHANDLE16
;
138 typedef HANDLE
*LPHANDLE
;
140 /* Integer types. These are the same for emulator and library. */
141 typedef UINT16 WPARAM16
;
144 typedef LONG HRESULT
;
145 typedef LONG LRESULT
;
147 typedef WORD CATCHBUF
[9];
148 typedef WORD
*LPCATCHBUF
;
149 typedef DWORD ACCESS_MASK
;
150 typedef ACCESS_MASK REGSAM
;
151 typedef HANDLE HHOOK
;
153 typedef HANDLE HMONITOR
;
156 typedef DWORD LCTYPE
;
158 typedef long long __int64
;
160 /* Pointers types. These are the same for emulator and library. */
163 typedef const void *PCVOID
;
165 typedef UCHAR
*PUCHAR
;
167 typedef ULONG
*PULONG
;
169 typedef DWORD
*PDWORD
;
170 /* common win32 types */
173 typedef const CHAR
*LPCSTR
;
174 typedef const CHAR
*PCSTR
;
175 typedef WCHAR
*LPWSTR
;
176 typedef WCHAR
*PWSTR
;
177 typedef const WCHAR
*LPCWSTR
;
178 typedef const WCHAR
*PCWSTR
;
179 typedef BYTE
*LPBYTE
;
180 typedef WORD
*LPWORD
;
181 typedef DWORD
*LPDWORD
;
182 typedef LONG
*LPLONG
;
183 typedef VOID
*LPVOID
;
184 typedef const VOID
*LPCVOID
;
185 typedef INT16
*LPINT16
;
186 typedef UINT16
*LPUINT16
;
190 typedef UINT
*LPUINT
;
191 typedef HKEY
*LPHKEY
;
193 typedef FLOAT
*PFLOAT
;
194 typedef FLOAT
*LPFLOAT
;
196 typedef BOOL
*LPBOOL
;
198 /* Special case: a segmented pointer is just a pointer in the user's code. */
201 typedef DWORD SEGPTR
;
203 typedef void* SEGPTR
;
204 #endif /* __WINE__ */
206 /* Handle types that exist both in Win16 and Win32. */
209 #define DECLARE_HANDLE(a) \
210 typedef HANDLE16 a##16; \
211 typedef a##16 *P##a##16; \
212 typedef a##16 *NP##a##16; \
213 typedef a##16 *LP##a##16; \
214 typedef struct a##__ { int unused; } *a; \
218 #define DECLARE_HANDLE(a) \
219 typedef HANDLE16 a##16; \
220 typedef a##16 *P##a##16; \
221 typedef a##16 *NP##a##16; \
222 typedef a##16 *LP##a##16; \
228 DECLARE_HANDLE(HACMDRIVERID
);
229 DECLARE_HANDLE(HACMDRIVER
);
230 DECLARE_HANDLE(HACMOBJ
);
231 DECLARE_HANDLE(HACMSTREAM
);
232 DECLARE_HANDLE(HMETAFILEPICT
);
234 DECLARE_HANDLE(HACCEL
);
235 DECLARE_HANDLE(HBITMAP
);
236 DECLARE_HANDLE(HBRUSH
);
237 DECLARE_HANDLE(HCOLORSPACE
);
238 DECLARE_HANDLE(HCURSOR
);
240 DECLARE_HANDLE(HDROP
);
241 DECLARE_HANDLE(HDRVR
);
242 DECLARE_HANDLE(HDWP
);
243 DECLARE_HANDLE(HENHMETAFILE
);
244 DECLARE_HANDLE(HFILE
);
245 DECLARE_HANDLE(HFONT
);
246 DECLARE_HANDLE(HICON
);
247 DECLARE_HANDLE(HINSTANCE
);
248 DECLARE_HANDLE(HMENU
);
249 DECLARE_HANDLE(HMETAFILE
);
250 DECLARE_HANDLE(HMIDI
);
251 DECLARE_HANDLE(HMIDIIN
);
252 DECLARE_HANDLE(HMIDIOUT
);
253 DECLARE_HANDLE(HMIDISTRM
);
254 DECLARE_HANDLE(HMIXER
);
255 DECLARE_HANDLE(HMIXEROBJ
);
256 DECLARE_HANDLE(HMMIO
);
257 DECLARE_HANDLE(HPALETTE
);
258 DECLARE_HANDLE(HPEN
);
259 DECLARE_HANDLE(HQUEUE
);
260 DECLARE_HANDLE(HRGN
);
261 DECLARE_HANDLE(HRSRC
);
262 DECLARE_HANDLE(HTASK
);
263 DECLARE_HANDLE(HWAVE
);
264 DECLARE_HANDLE(HWAVEIN
);
265 DECLARE_HANDLE(HWAVEOUT
);
266 DECLARE_HANDLE(HWINSTA
);
267 DECLARE_HANDLE(HDESK
);
268 DECLARE_HANDLE(HWND
);
271 DECLARE_HANDLE(HRASCONN
);
272 #undef DECLARE_HANDLE
274 /* Handle types that must remain interchangeable even with strict on */
276 typedef HINSTANCE16 HMODULE16
;
277 typedef HINSTANCE HMODULE
;
278 typedef HANDLE16 HGDIOBJ16
;
279 typedef HANDLE16 HGLOBAL16
;
280 typedef HANDLE16 HLOCAL16
;
281 typedef HANDLE HGDIOBJ
;
282 typedef HANDLE HGLOBAL
;
283 typedef HANDLE HLOCAL
;
285 /* Callback function pointers types */
287 typedef BOOL (CALLBACK
* DATEFMT_ENUMPROCA
)(LPSTR
);
288 typedef BOOL (CALLBACK
* DATEFMT_ENUMPROCW
)(LPWSTR
);
289 DECL_WINELIB_TYPE_AW(DATEFMT_ENUMPROC
)
290 typedef BOOL16 (CALLBACK
*DLGPROC16
)(HWND16
,UINT16
,WPARAM16
,LPARAM
);
291 typedef BOOL (CALLBACK
*DLGPROC
)(HWND
,UINT
,WPARAM
,LPARAM
);
292 typedef LRESULT (CALLBACK
*DRIVERPROC16
)(DWORD
,HDRVR16
,UINT16
,LPARAM
,LPARAM
);
293 typedef LRESULT (CALLBACK
*DRIVERPROC
)(DWORD
,HDRVR
,UINT
,LPARAM
,LPARAM
);
294 typedef INT16 (CALLBACK
*EDITWORDBREAKPROC16
)(LPSTR
,INT16
,INT16
,INT16
);
295 typedef INT (CALLBACK
*EDITWORDBREAKPROCA
)(LPSTR
,INT
,INT
,INT
);
296 typedef INT (CALLBACK
*EDITWORDBREAKPROCW
)(LPWSTR
,INT
,INT
,INT
);
297 DECL_WINELIB_TYPE_AW(EDITWORDBREAKPROC
)
298 typedef LRESULT (CALLBACK
*FARPROC16
)();
299 typedef LRESULT (CALLBACK
*FARPROC
)();
300 typedef INT16 (CALLBACK
*PROC16
)();
301 typedef INT (CALLBACK
*PROC
)();
302 typedef INT16 (CALLBACK
*GOBJENUMPROC16
)(SEGPTR
,LPARAM
);
303 typedef INT (CALLBACK
*GOBJENUMPROC
)(LPVOID
,LPARAM
);
304 typedef BOOL16 (CALLBACK
*GRAYSTRINGPROC16
)(HDC16
,LPARAM
,INT16
);
305 typedef BOOL (CALLBACK
*GRAYSTRINGPROC
)(HDC
,LPARAM
,INT
);
306 typedef LRESULT (CALLBACK
*HOOKPROC16
)(INT16
,WPARAM16
,LPARAM
);
307 typedef LRESULT (CALLBACK
*HOOKPROC
)(INT
,WPARAM
,LPARAM
);
308 typedef VOID (CALLBACK
*LINEDDAPROC16
)(INT16
,INT16
,LPARAM
);
309 typedef VOID (CALLBACK
*LINEDDAPROC
)(INT
,INT
,LPARAM
);
310 typedef BOOL16 (CALLBACK
*PROPENUMPROC16
)(HWND16
,SEGPTR
,HANDLE16
);
311 typedef BOOL (CALLBACK
*PROPENUMPROCA
)(HWND
,LPCSTR
,HANDLE
);
312 typedef BOOL (CALLBACK
*PROPENUMPROCW
)(HWND
,LPCWSTR
,HANDLE
);
313 DECL_WINELIB_TYPE_AW(PROPENUMPROC
)
314 typedef BOOL (CALLBACK
*PROPENUMPROCEXA
)(HWND
,LPCSTR
,HANDLE
,LPARAM
);
315 typedef BOOL (CALLBACK
*PROPENUMPROCEXW
)(HWND
,LPCWSTR
,HANDLE
,LPARAM
);
316 DECL_WINELIB_TYPE_AW(PROPENUMPROCEX
)
317 typedef BOOL (CALLBACK
* TIMEFMT_ENUMPROCA
)(LPSTR
);
318 typedef BOOL (CALLBACK
* TIMEFMT_ENUMPROCW
)(LPWSTR
);
319 DECL_WINELIB_TYPE_AW(TIMEFMT_ENUMPROC
)
320 typedef VOID (CALLBACK
*TIMERPROC16
)(HWND16
,UINT16
,UINT16
,DWORD
);
321 typedef VOID (CALLBACK
*TIMERPROC
)(HWND
,UINT
,UINT
,DWORD
);
322 typedef LRESULT (CALLBACK
*WNDENUMPROC16
)(HWND16
,LPARAM
);
323 typedef LRESULT (CALLBACK
*WNDENUMPROC
)(HWND
,LPARAM
);
324 typedef LRESULT (CALLBACK
*WNDPROC16
)(HWND16
,UINT16
,WPARAM16
,LPARAM
);
325 typedef LRESULT (CALLBACK
*WNDPROC
)(HWND
,UINT
,WPARAM
,LPARAM
);
327 /* TCHAR data types definitions for Winelib. */
328 /* These types are _not_ defined for the emulator, because they */
329 /* depend on the UNICODE macro that only exists in user's code. */
334 typedef LPWSTR LPTSTR
;
335 typedef LPCWSTR LPCTSTR
;
336 #define __TEXT(string) L##string /*probably wrong */
339 typedef LPSTR LPTSTR
;
340 typedef LPCSTR LPCTSTR
;
341 #define __TEXT(string) string
342 # endif /* UNICODE */
343 #endif /* __WINE__ */
344 #define TEXT(quote) __TEXT(quote)
346 /* Data types specific to the library. These do _not_ exist in the emulator. */
350 /* Define some empty macros for compatibility with Windows code. */
362 #endif /* __WINE__ */
364 /* Macro for structure packing. */
367 #define WINE_PACKED __attribute__ ((packed))
368 #define WINE_UNUSED __attribute__ ((unused))
370 #define WINE_PACKED /* nothing */
371 #define WINE_UNUSED /* nothing */
374 /* Macros to split words and longs. */
376 #define LOBYTE(w) ((BYTE)(WORD)(w))
377 #define HIBYTE(w) ((BYTE)((WORD)(w) >> 8))
379 #define LOWORD(l) ((WORD)(DWORD)(l))
380 #define HIWORD(l) ((WORD)((DWORD)(l) >> 16))
382 #define SLOWORD(l) ((INT16)(LONG)(l))
383 #define SHIWORD(l) ((INT16)((LONG)(l) >> 16))
385 #define MAKEWORD(low,high) ((WORD)(((BYTE)(low)) | ((WORD)((BYTE)(high))) << 8))
386 #define MAKELONG(low,high) ((LONG)(((WORD)(low)) | (((DWORD)((WORD)(high))) << 16)))
387 #define MAKELPARAM(low,high) ((LPARAM)MAKELONG(low,high))
388 #define MAKEWPARAM(low,high) ((WPARAM)MAKELONG(low,high))
389 #define MAKELRESULT(low,high) ((LRESULT)MAKELONG(low,high))
390 #define MAKEINTATOM(atom) ((LPCSTR)MAKELONG((atom),0))
392 #define SELECTOROF(ptr) (HIWORD(ptr))
393 #define OFFSETOF(ptr) (LOWORD(ptr))
395 /* Macros to access unaligned or wrong-endian WORDs and DWORDs. */
396 /* Note: These macros are semantically broken, at least for wrc. wrc
397 spits out data in the platform's current binary format, *not* in
398 little-endian format. These macros are used throughout the resource
399 code to load and store data to the resources. Since it is unlikely
400 that we'll ever be dealing with little-endian resource data, the
401 byte-swapping nature of these macros has been disabled. Rather than
402 remove the use of these macros from the resource loading code, the
403 macros have simply been disabled. In the future, someone may want
404 to reactivate these macros for other purposes. In that case, the
405 resource code will have to be modified to use different macros. */
408 #define PUT_WORD(ptr,w) (*(WORD *)(ptr) = (w))
409 #define GET_WORD(ptr) (*(WORD *)(ptr))
410 #define PUT_DWORD(ptr,dw) (*(DWORD *)(ptr) = (dw))
411 #define GET_DWORD(ptr) (*(DWORD *)(ptr))
413 #define PUT_WORD(ptr,w) (*(BYTE *)(ptr) = LOBYTE(w), \
414 *((BYTE *)(ptr) + 1) = HIBYTE(w))
415 #define GET_WORD(ptr) ((WORD)(*(BYTE *)(ptr) | \
416 (WORD)(*((BYTE *)(ptr)+1) << 8)))
417 #define PUT_DWORD(ptr,dw) (PUT_WORD((ptr),LOWORD(dw)), \
418 PUT_WORD((WORD *)(ptr)+1,HIWORD(dw)))
419 #define GET_DWORD(ptr) ((DWORD)(GET_WORD(ptr) | \
420 ((DWORD)GET_WORD((WORD *)(ptr)+1) << 16)))
423 /* MIN and MAX macros */
428 #define MAX(a,b) (((a) > (b)) ? (a) : (b))
433 #define MIN(a,b) (((a) < (b)) ? (a) : (b))
435 #define __max(a,b) MAX(a,b)
436 #define __min(a,b) MIN(a,b)
437 #define max(a,b) MAX(a,b)
438 #define min(a,b) MIN(a,b)
440 #define _MAX_PATH 260
444 #define _MAX_FNAME 255
447 #define HFILE_ERROR16 ((HFILE16)-1)
448 #define HFILE_ERROR ((HFILE)-1)
450 /* Winelib run-time flag */
453 extern int __winelib
;
454 #endif /* __WINE__ */
456 /* The SIZE structure */
462 } SIZE16
, *PSIZE16
, *LPSIZE16
;
464 typedef struct tagSIZE
468 } SIZE
, *PSIZE
, *LPSIZE
;
471 typedef SIZE SIZEL
, *PSIZEL
, *LPSIZEL
;
473 #define CONV_SIZE16TO32(s16,s32) \
474 ((s32)->cx = (INT)(s16)->cx, (s32)->cy = (INT)(s16)->cy)
475 #define CONV_SIZE32TO16(s32,s16) \
476 ((s16)->cx = (INT16)(s32)->cx, (s16)->cy = (INT16)(s32)->cy)
478 /* The POINT structure */
484 } POINT16
, *PPOINT16
, *LPPOINT16
;
486 typedef struct tagPOINT
490 } POINT
, *PPOINT
, *LPPOINT
;
492 typedef struct _POINTL
498 #define CONV_POINT16TO32(p16,p32) \
499 ((p32)->x = (INT)(p16)->x, (p32)->y = (INT)(p16)->y)
500 #define CONV_POINT32TO16(p32,p16) \
501 ((p16)->x = (INT16)(p32)->x, (p16)->y = (INT16)(p32)->y)
503 #define MAKEPOINT16(l) (*((POINT16 *)&(l)))
505 /* The POINTS structure */
507 typedef struct tagPOINTS
511 } POINTS
, *PPOINTS
, *LPPOINTS
;
514 #define MAKEPOINTS(l) (*((POINTS *)&(l)))
517 /* The RECT structure */
527 typedef struct tagRECT
533 } RECT
, *PRECT
, *LPRECT
;
534 typedef const RECT
*LPCRECT
;
537 typedef struct tagRECTL
543 } RECTL
, *PRECTL
, *LPRECTL
;
545 typedef const RECTL
*LPCRECTL
;
547 #define CONV_RECT16TO32(r16,r32) \
548 ((r32)->left = (INT)(r16)->left, (r32)->top = (INT)(r16)->top, \
549 (r32)->right = (INT)(r16)->right, (r32)->bottom = (INT)(r16)->bottom)
550 #define CONV_RECT32TO16(r32,r16) \
551 ((r16)->left = (INT16)(r32)->left, (r16)->top = (INT16)(r32)->top, \
552 (r16)->right = (INT16)(r32)->right, (r16)->bottom = (INT16)(r32)->bottom)
558 #endif /* __WINE_WINDEF_H */