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 BOOL16 (CALLBACK
*GRAYSTRINGPROC16
)(HDC16
,LPARAM
,INT16
);
303 typedef BOOL (CALLBACK
*GRAYSTRINGPROC
)(HDC
,LPARAM
,INT
);
304 typedef LRESULT (CALLBACK
*HOOKPROC16
)(INT16
,WPARAM16
,LPARAM
);
305 typedef LRESULT (CALLBACK
*HOOKPROC
)(INT
,WPARAM
,LPARAM
);
306 typedef BOOL16 (CALLBACK
*PROPENUMPROC16
)(HWND16
,SEGPTR
,HANDLE16
);
307 typedef BOOL (CALLBACK
*PROPENUMPROCA
)(HWND
,LPCSTR
,HANDLE
);
308 typedef BOOL (CALLBACK
*PROPENUMPROCW
)(HWND
,LPCWSTR
,HANDLE
);
309 DECL_WINELIB_TYPE_AW(PROPENUMPROC
)
310 typedef BOOL (CALLBACK
*PROPENUMPROCEXA
)(HWND
,LPCSTR
,HANDLE
,LPARAM
);
311 typedef BOOL (CALLBACK
*PROPENUMPROCEXW
)(HWND
,LPCWSTR
,HANDLE
,LPARAM
);
312 DECL_WINELIB_TYPE_AW(PROPENUMPROCEX
)
313 typedef BOOL (CALLBACK
* TIMEFMT_ENUMPROCA
)(LPSTR
);
314 typedef BOOL (CALLBACK
* TIMEFMT_ENUMPROCW
)(LPWSTR
);
315 DECL_WINELIB_TYPE_AW(TIMEFMT_ENUMPROC
)
316 typedef VOID (CALLBACK
*TIMERPROC16
)(HWND16
,UINT16
,UINT16
,DWORD
);
317 typedef VOID (CALLBACK
*TIMERPROC
)(HWND
,UINT
,UINT
,DWORD
);
318 typedef LRESULT (CALLBACK
*WNDENUMPROC16
)(HWND16
,LPARAM
);
319 typedef LRESULT (CALLBACK
*WNDENUMPROC
)(HWND
,LPARAM
);
320 typedef LRESULT (CALLBACK
*WNDPROC16
)(HWND16
,UINT16
,WPARAM16
,LPARAM
);
321 typedef LRESULT (CALLBACK
*WNDPROC
)(HWND
,UINT
,WPARAM
,LPARAM
);
323 /* TCHAR data types definitions for Winelib. */
324 /* These types are _not_ defined for the emulator, because they */
325 /* depend on the UNICODE macro that only exists in user's code. */
330 typedef LPWSTR LPTSTR
;
331 typedef LPCWSTR LPCTSTR
;
332 #define __TEXT(string) L##string /*probably wrong */
335 typedef LPSTR LPTSTR
;
336 typedef LPCSTR LPCTSTR
;
337 #define __TEXT(string) string
338 # endif /* UNICODE */
339 #endif /* __WINE__ */
340 #define TEXT(quote) __TEXT(quote)
342 /* Data types specific to the library. These do _not_ exist in the emulator. */
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))
366 #define WINE_PACKED /* nothing */
367 #define WINE_UNUSED /* 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) ((INT16)(LONG)(l))
379 #define SHIWORD(l) ((INT16)((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))
391 /* Macros to access unaligned or wrong-endian WORDs and DWORDs. */
392 /* Note: These macros are semantically broken, at least for wrc. wrc
393 spits out data in the platform's current binary format, *not* in
394 little-endian format. These macros are used throughout the resource
395 code to load and store data to the resources. Since it is unlikely
396 that we'll ever be dealing with little-endian resource data, the
397 byte-swapping nature of these macros has been disabled. Rather than
398 remove the use of these macros from the resource loading code, the
399 macros have simply been disabled. In the future, someone may want
400 to reactivate these macros for other purposes. In that case, the
401 resource code will have to be modified to use different macros. */
404 #define PUT_WORD(ptr,w) (*(WORD *)(ptr) = (w))
405 #define GET_WORD(ptr) (*(WORD *)(ptr))
406 #define PUT_DWORD(ptr,dw) (*(DWORD *)(ptr) = (dw))
407 #define GET_DWORD(ptr) (*(DWORD *)(ptr))
409 #define PUT_WORD(ptr,w) (*(BYTE *)(ptr) = LOBYTE(w), \
410 *((BYTE *)(ptr) + 1) = HIBYTE(w))
411 #define GET_WORD(ptr) ((WORD)(*(BYTE *)(ptr) | \
412 (WORD)(*((BYTE *)(ptr)+1) << 8)))
413 #define PUT_DWORD(ptr,dw) (PUT_WORD((ptr),LOWORD(dw)), \
414 PUT_WORD((WORD *)(ptr)+1,HIWORD(dw)))
415 #define GET_DWORD(ptr) ((DWORD)(GET_WORD(ptr) | \
416 ((DWORD)GET_WORD((WORD *)(ptr)+1) << 16)))
419 /* MIN and MAX macros */
424 #define MAX(a,b) (((a) > (b)) ? (a) : (b))
429 #define MIN(a,b) (((a) < (b)) ? (a) : (b))
431 #define __max(a,b) MAX(a,b)
432 #define __min(a,b) MIN(a,b)
433 #define max(a,b) MAX(a,b)
434 #define min(a,b) MIN(a,b)
436 #define _MAX_PATH 260
440 #define _MAX_FNAME 255
443 #define HFILE_ERROR16 ((HFILE16)-1)
444 #define HFILE_ERROR ((HFILE)-1)
446 /* Winelib run-time flag */
449 extern int __winelib
;
450 #endif /* __WINE__ */
452 /* The SIZE structure */
458 } SIZE16
, *PSIZE16
, *LPSIZE16
;
460 typedef struct tagSIZE
464 } SIZE
, *PSIZE
, *LPSIZE
;
467 typedef SIZE SIZEL
, *PSIZEL
, *LPSIZEL
;
469 #define CONV_SIZE16TO32(s16,s32) \
470 ((s32)->cx = (INT)(s16)->cx, (s32)->cy = (INT)(s16)->cy)
471 #define CONV_SIZE32TO16(s32,s16) \
472 ((s16)->cx = (INT16)(s32)->cx, (s16)->cy = (INT16)(s32)->cy)
474 /* The POINT structure */
480 } POINT16
, *PPOINT16
, *LPPOINT16
;
482 typedef struct tagPOINT
486 } POINT
, *PPOINT
, *LPPOINT
;
488 typedef struct _POINTL
494 #define CONV_POINT16TO32(p16,p32) \
495 ((p32)->x = (INT)(p16)->x, (p32)->y = (INT)(p16)->y)
496 #define CONV_POINT32TO16(p32,p16) \
497 ((p16)->x = (INT16)(p32)->x, (p16)->y = (INT16)(p32)->y)
499 #define MAKEPOINT16(l) (*((POINT16 *)&(l)))
501 /* The POINTS structure */
503 typedef struct tagPOINTS
507 } POINTS
, *PPOINTS
, *LPPOINTS
;
510 #define MAKEPOINTS(l) (*((POINTS *)&(l)))
513 /* The RECT structure */
523 typedef struct tagRECT
529 } RECT
, *PRECT
, *LPRECT
;
530 typedef const RECT
*LPCRECT
;
533 typedef struct tagRECTL
539 } RECTL
, *PRECTL
, *LPRECTL
;
541 typedef const RECTL
*LPCRECTL
;
543 #define CONV_RECT16TO32(r16,r32) \
544 ((r32)->left = (INT)(r16)->left, (r32)->top = (INT)(r16)->top, \
545 (r32)->right = (INT)(r16)->right, (r32)->bottom = (INT)(r16)->bottom)
546 #define CONV_RECT32TO16(r32,r16) \
547 ((r16)->left = (INT16)(r32)->left, (r16)->top = (INT16)(r32)->top, \
548 (r16)->right = (INT16)(r32)->right, (r16)->bottom = (INT16)(r32)->bottom)
554 #endif /* __WINE_WINDEF_H */