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 double DOUBLE
;
117 typedef double LONGLONG
;
118 typedef double ULONGLONG
;
120 /* FIXME: Wine does not compile with strict on, therefore strict
121 * handles are presently only usable on machines where sizeof(UINT) ==
122 * sizeof(void*). HANDLEs are supposed to be void* but a large amount
123 * of WINE code operates on HANDLES as if they are UINTs. So to WINE
124 * they exist as UINTs but to the Winelib user who turns on strict,
125 * they exist as void*. If there is a size difference between UINT and
126 * void* then things get ugly. */
128 typedef UINT16 HANDLE16
;
129 typedef VOID
* HANDLE
;
131 typedef UINT16 HANDLE16
;
135 typedef HANDLE16
*LPHANDLE16
;
136 typedef HANDLE
*LPHANDLE
;
138 /* Integer types. These are the same for emulator and library. */
139 typedef UINT16 WPARAM16
;
142 typedef LONG HRESULT
;
143 typedef LONG LRESULT
;
145 typedef WORD CATCHBUF
[9];
146 typedef WORD
*LPCATCHBUF
;
147 typedef HANDLE HHOOK
;
148 typedef HANDLE HMONITOR
;
151 typedef DWORD LCTYPE
;
154 /* Pointers types. These are the same for emulator and library. */
157 typedef const void *PCVOID
;
159 typedef UCHAR
*PUCHAR
;
161 typedef ULONG
*PULONG
;
163 typedef DWORD
*PDWORD
;
164 /* common win32 types */
167 typedef const CHAR
*LPCSTR
;
168 typedef const CHAR
*PCSTR
;
169 typedef WCHAR
*LPWSTR
;
170 typedef WCHAR
*PWSTR
;
171 typedef const WCHAR
*LPCWSTR
;
172 typedef const WCHAR
*PCWSTR
;
173 typedef BYTE
*LPBYTE
;
174 typedef WORD
*LPWORD
;
175 typedef DWORD
*LPDWORD
;
176 typedef LONG
*LPLONG
;
177 typedef VOID
*LPVOID
;
178 typedef const VOID
*LPCVOID
;
179 typedef INT16
*LPINT16
;
180 typedef UINT16
*LPUINT16
;
184 typedef UINT
*LPUINT
;
185 typedef FLOAT
*PFLOAT
;
186 typedef FLOAT
*LPFLOAT
;
188 typedef BOOL
*LPBOOL
;
190 /* Special case: a segmented pointer is just a pointer in the user's code. */
193 typedef DWORD SEGPTR
;
195 typedef void* SEGPTR
;
196 #endif /* __WINE__ */
198 /* Handle types that exist both in Win16 and Win32. */
201 #define DECLARE_HANDLE(a) \
202 typedef HANDLE16 a##16; \
203 typedef a##16 *P##a##16; \
204 typedef a##16 *NP##a##16; \
205 typedef a##16 *LP##a##16; \
206 typedef struct a##__ { int unused; } *a; \
210 #define DECLARE_HANDLE(a) \
211 typedef HANDLE16 a##16; \
212 typedef a##16 *P##a##16; \
213 typedef a##16 *NP##a##16; \
214 typedef a##16 *LP##a##16; \
220 DECLARE_HANDLE(HACMDRIVERID
);
221 DECLARE_HANDLE(HACMDRIVER
);
222 DECLARE_HANDLE(HACMOBJ
);
223 DECLARE_HANDLE(HACMSTREAM
);
224 DECLARE_HANDLE(HMETAFILEPICT
);
226 DECLARE_HANDLE(HACCEL
);
227 DECLARE_HANDLE(HBITMAP
);
228 DECLARE_HANDLE(HBRUSH
);
229 DECLARE_HANDLE(HCOLORSPACE
);
230 DECLARE_HANDLE(HCURSOR
);
232 DECLARE_HANDLE(HDROP
);
233 DECLARE_HANDLE(HDRVR
);
234 DECLARE_HANDLE(HDWP
);
235 DECLARE_HANDLE(HENHMETAFILE
);
236 DECLARE_HANDLE(HFILE
);
237 DECLARE_HANDLE(HFONT
);
238 DECLARE_HANDLE(HICON
);
239 DECLARE_HANDLE(HINSTANCE
);
240 DECLARE_HANDLE(HKEY
);
241 DECLARE_HANDLE(HMENU
);
242 DECLARE_HANDLE(HMETAFILE
);
243 DECLARE_HANDLE(HMIDI
);
244 DECLARE_HANDLE(HMIDIIN
);
245 DECLARE_HANDLE(HMIDIOUT
);
246 DECLARE_HANDLE(HMIDISTRM
);
247 DECLARE_HANDLE(HMIXER
);
248 DECLARE_HANDLE(HMIXEROBJ
);
249 DECLARE_HANDLE(HMMIO
);
250 DECLARE_HANDLE(HPALETTE
);
251 DECLARE_HANDLE(HPEN
);
252 DECLARE_HANDLE(HQUEUE
);
253 DECLARE_HANDLE(HRGN
);
254 DECLARE_HANDLE(HRSRC
);
255 DECLARE_HANDLE(HTASK
);
256 DECLARE_HANDLE(HWAVE
);
257 DECLARE_HANDLE(HWAVEIN
);
258 DECLARE_HANDLE(HWAVEOUT
);
259 DECLARE_HANDLE(HWINSTA
);
260 DECLARE_HANDLE(HDESK
);
261 DECLARE_HANDLE(HWND
);
264 DECLARE_HANDLE(HRASCONN
);
265 #undef DECLARE_HANDLE
267 /* Handle types that must remain interchangeable even with strict on */
269 typedef HINSTANCE16 HMODULE16
;
270 typedef HINSTANCE HMODULE
;
271 typedef HANDLE16 HGDIOBJ16
;
272 typedef HANDLE16 HGLOBAL16
;
273 typedef HANDLE16 HLOCAL16
;
274 typedef HANDLE HGDIOBJ
;
275 typedef HANDLE HGLOBAL
;
276 typedef HANDLE HLOCAL
;
278 /* Callback function pointers types */
280 typedef BOOL (CALLBACK
* DATEFMT_ENUMPROCA
)(LPSTR
);
281 typedef BOOL (CALLBACK
* DATEFMT_ENUMPROCW
)(LPWSTR
);
282 DECL_WINELIB_TYPE_AW(DATEFMT_ENUMPROC
)
283 typedef BOOL16 (CALLBACK
*DLGPROC16
)(HWND16
,UINT16
,WPARAM16
,LPARAM
);
284 typedef BOOL (CALLBACK
*DLGPROC
)(HWND
,UINT
,WPARAM
,LPARAM
);
285 typedef LRESULT (CALLBACK
*DRIVERPROC16
)(DWORD
,HDRVR16
,UINT16
,LPARAM
,LPARAM
);
286 typedef LRESULT (CALLBACK
*DRIVERPROC
)(DWORD
,HDRVR
,UINT
,LPARAM
,LPARAM
);
287 typedef INT16 (CALLBACK
*EDITWORDBREAKPROC16
)(LPSTR
,INT16
,INT16
,INT16
);
288 typedef INT (CALLBACK
*EDITWORDBREAKPROCA
)(LPSTR
,INT
,INT
,INT
);
289 typedef INT (CALLBACK
*EDITWORDBREAKPROCW
)(LPWSTR
,INT
,INT
,INT
);
290 DECL_WINELIB_TYPE_AW(EDITWORDBREAKPROC
)
291 typedef LRESULT (CALLBACK
*FARPROC16
)();
292 typedef LRESULT (CALLBACK
*FARPROC
)();
293 typedef INT16 (CALLBACK
*PROC16
)();
294 typedef INT (CALLBACK
*PROC
)();
295 typedef BOOL16 (CALLBACK
*GRAYSTRINGPROC16
)(HDC16
,LPARAM
,INT16
);
296 typedef BOOL (CALLBACK
*GRAYSTRINGPROC
)(HDC
,LPARAM
,INT
);
297 typedef LRESULT (CALLBACK
*HOOKPROC16
)(INT16
,WPARAM16
,LPARAM
);
298 typedef LRESULT (CALLBACK
*HOOKPROC
)(INT
,WPARAM
,LPARAM
);
299 typedef BOOL16 (CALLBACK
*PROPENUMPROC16
)(HWND16
,SEGPTR
,HANDLE16
);
300 typedef BOOL (CALLBACK
*PROPENUMPROCA
)(HWND
,LPCSTR
,HANDLE
);
301 typedef BOOL (CALLBACK
*PROPENUMPROCW
)(HWND
,LPCWSTR
,HANDLE
);
302 DECL_WINELIB_TYPE_AW(PROPENUMPROC
)
303 typedef BOOL (CALLBACK
*PROPENUMPROCEXA
)(HWND
,LPCSTR
,HANDLE
,LPARAM
);
304 typedef BOOL (CALLBACK
*PROPENUMPROCEXW
)(HWND
,LPCWSTR
,HANDLE
,LPARAM
);
305 DECL_WINELIB_TYPE_AW(PROPENUMPROCEX
)
306 typedef BOOL (CALLBACK
* TIMEFMT_ENUMPROCA
)(LPSTR
);
307 typedef BOOL (CALLBACK
* TIMEFMT_ENUMPROCW
)(LPWSTR
);
308 DECL_WINELIB_TYPE_AW(TIMEFMT_ENUMPROC
)
309 typedef VOID (CALLBACK
*TIMERPROC16
)(HWND16
,UINT16
,UINT16
,DWORD
);
310 typedef VOID (CALLBACK
*TIMERPROC
)(HWND
,UINT
,UINT
,DWORD
);
311 typedef LRESULT (CALLBACK
*WNDENUMPROC16
)(HWND16
,LPARAM
);
312 typedef LRESULT (CALLBACK
*WNDENUMPROC
)(HWND
,LPARAM
);
313 typedef LRESULT (CALLBACK
*WNDPROC16
)(HWND16
,UINT16
,WPARAM16
,LPARAM
);
314 typedef LRESULT (CALLBACK
*WNDPROC
)(HWND
,UINT
,WPARAM
,LPARAM
);
316 /* Define some empty macros for compatibility with Windows code. */
328 #endif /* __WINE__ */
330 /* Macro for structure packing. */
333 #define WINE_PACKED __attribute__ ((packed))
334 #define WINE_UNUSED __attribute__ ((unused))
336 #define WINE_PACKED /* nothing */
337 #define WINE_UNUSED /* nothing */
340 /* Macros to split words and longs. */
342 #define LOBYTE(w) ((BYTE)(WORD)(w))
343 #define HIBYTE(w) ((BYTE)((WORD)(w) >> 8))
345 #define LOWORD(l) ((WORD)(DWORD)(l))
346 #define HIWORD(l) ((WORD)((DWORD)(l) >> 16))
348 #define SLOWORD(l) ((INT16)(LONG)(l))
349 #define SHIWORD(l) ((INT16)((LONG)(l) >> 16))
351 #define MAKEWORD(low,high) ((WORD)(((BYTE)(low)) | ((WORD)((BYTE)(high))) << 8))
352 #define MAKELONG(low,high) ((LONG)(((WORD)(low)) | (((DWORD)((WORD)(high))) << 16)))
353 #define MAKELPARAM(low,high) ((LPARAM)MAKELONG(low,high))
354 #define MAKEWPARAM(low,high) ((WPARAM)MAKELONG(low,high))
355 #define MAKELRESULT(low,high) ((LRESULT)MAKELONG(low,high))
356 #define MAKEINTATOM(atom) ((LPCSTR)MAKELONG((atom),0))
358 #define SELECTOROF(ptr) (HIWORD(ptr))
359 #define OFFSETOF(ptr) (LOWORD(ptr))
362 /* macros to set parts of a DWORD (not in the Windows API) */
363 #define SET_LOWORD(dw,val) ((dw) = ((dw) & 0xffff0000) | LOWORD(val))
364 #define SET_LOBYTE(dw,val) ((dw) = ((dw) & 0xffffff00) | LOBYTE(val))
365 #define SET_HIBYTE(dw,val) ((dw) = ((dw) & 0xffff00ff) | (LOWORD(val) & 0xff00))
366 #define ADD_LOWORD(dw,val) ((dw) = ((dw) & 0xffff0000) | LOWORD((DWORD)(dw)+(val)))
369 /* Macros to access unaligned or wrong-endian WORDs and DWORDs. */
370 /* Note: These macros are semantically broken, at least for wrc. wrc
371 spits out data in the platform's current binary format, *not* in
372 little-endian format. These macros are used throughout the resource
373 code to load and store data to the resources. Since it is unlikely
374 that we'll ever be dealing with little-endian resource data, the
375 byte-swapping nature of these macros has been disabled. Rather than
376 remove the use of these macros from the resource loading code, the
377 macros have simply been disabled. In the future, someone may want
378 to reactivate these macros for other purposes. In that case, the
379 resource code will have to be modified to use different macros. */
382 #define PUT_WORD(ptr,w) (*(WORD *)(ptr) = (w))
383 #define GET_WORD(ptr) (*(WORD *)(ptr))
384 #define PUT_DWORD(ptr,dw) (*(DWORD *)(ptr) = (dw))
385 #define GET_DWORD(ptr) (*(DWORD *)(ptr))
387 #define PUT_WORD(ptr,w) (*(BYTE *)(ptr) = LOBYTE(w), \
388 *((BYTE *)(ptr) + 1) = HIBYTE(w))
389 #define GET_WORD(ptr) ((WORD)(*(BYTE *)(ptr) | \
390 (WORD)(*((BYTE *)(ptr)+1) << 8)))
391 #define PUT_DWORD(ptr,dw) (PUT_WORD((ptr),LOWORD(dw)), \
392 PUT_WORD((WORD *)(ptr)+1,HIWORD(dw)))
393 #define GET_DWORD(ptr) ((DWORD)(GET_WORD(ptr) | \
394 ((DWORD)GET_WORD((WORD *)(ptr)+1) << 16)))
397 /* MIN and MAX macros */
402 #define MAX(a,b) (((a) > (b)) ? (a) : (b))
407 #define MIN(a,b) (((a) < (b)) ? (a) : (b))
409 #define __max(a,b) MAX(a,b)
410 #define __min(a,b) MIN(a,b)
412 #define max(a,b) MAX(a,b)
415 #define min(a,b) MIN(a,b)
418 #define _MAX_PATH 260
422 #define _MAX_FNAME 255
425 #define HFILE_ERROR16 ((HFILE16)-1)
426 #define HFILE_ERROR ((HFILE)-1)
428 /* Winelib run-time flag */
431 extern int __winelib
;
432 #endif /* __WINE__ */
434 /* The SIZE structure */
440 } SIZE16
, *PSIZE16
, *LPSIZE16
;
442 typedef struct tagSIZE
446 } SIZE
, *PSIZE
, *LPSIZE
;
449 typedef SIZE SIZEL
, *PSIZEL
, *LPSIZEL
;
451 #define CONV_SIZE16TO32(s16,s32) \
452 ((s32)->cx = (INT)(s16)->cx, (s32)->cy = (INT)(s16)->cy)
453 #define CONV_SIZE32TO16(s32,s16) \
454 ((s16)->cx = (INT16)(s32)->cx, (s16)->cy = (INT16)(s32)->cy)
456 /* The POINT structure */
462 } POINT16
, *PPOINT16
, *LPPOINT16
;
464 typedef struct tagPOINT
468 } POINT
, *PPOINT
, *LPPOINT
;
470 typedef struct _POINTL
476 #define CONV_POINT16TO32(p16,p32) \
477 ((p32)->x = (INT)(p16)->x, (p32)->y = (INT)(p16)->y)
478 #define CONV_POINT32TO16(p32,p16) \
479 ((p16)->x = (INT16)(p32)->x, (p16)->y = (INT16)(p32)->y)
481 #define MAKEPOINT16(l) (*((POINT16 *)&(l)))
483 /* The POINTS structure */
485 typedef struct tagPOINTS
489 } POINTS
, *PPOINTS
, *LPPOINTS
;
492 #define MAKEPOINTS(l) (*((POINTS *)&(l)))
495 /* The RECT structure */
505 typedef struct tagRECT
511 } RECT
, *PRECT
, *LPRECT
;
512 typedef const RECT
*LPCRECT
;
515 typedef struct tagRECTL
521 } RECTL
, *PRECTL
, *LPRECTL
;
523 typedef const RECTL
*LPCRECTL
;
525 #define CONV_RECT16TO32(r16,r32) \
526 ((r32)->left = (INT)(r16)->left, (r32)->top = (INT)(r16)->top, \
527 (r32)->right = (INT)(r16)->right, (r32)->bottom = (INT)(r16)->bottom)
528 #define CONV_RECT32TO16(r32,r16) \
529 ((r16)->left = (INT16)(r32)->left, (r16)->top = (INT16)(r32)->top, \
530 (r16)->right = (INT16)(r32)->right, (r16)->bottom = (INT16)(r32)->bottom)
536 #endif /* __WINE_WINDEF_H */