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 _stdcall __stdcall
79 #define _fastcall __stdcall
80 #define __export __stdcall
81 #define WINAPIV __cdecl
82 #define APIENTRY WINAPI
86 /* Standard data types. These are the same for emulator and library. */
90 typedef unsigned short UINT16
;
92 typedef unsigned int UINT
;
93 typedef unsigned short WORD
;
94 typedef unsigned long DWORD
;
95 typedef unsigned long ULONG
;
96 typedef unsigned char BYTE
;
99 typedef unsigned short USHORT
;
101 typedef unsigned char UCHAR
;
102 /* Some systems might have wchar_t, but we really need 16 bit characters */
103 typedef unsigned short WCHAR
;
104 typedef unsigned short BOOL16
;
107 typedef long LONG_PTR
;
108 typedef unsigned long ULONG_PTR
;
109 typedef double DOUBLE
;
110 typedef double LONGLONG
;
111 typedef double ULONGLONG
;
113 /* Integer types. These are the same for emulator and library. */
115 typedef UINT16 HANDLE16
;
117 typedef UINT16
*LPHANDLE16
;
118 typedef UINT
*LPHANDLE
;
119 typedef UINT16 WPARAM16
;
122 typedef LONG HRESULT
;
123 typedef LONG LRESULT
;
125 typedef WORD CATCHBUF
[9];
126 typedef WORD
*LPCATCHBUF
;
127 typedef DWORD ACCESS_MASK
;
128 typedef ACCESS_MASK REGSAM
;
129 typedef HANDLE HHOOK
;
131 typedef HANDLE HMONITOR
;
134 typedef DWORD LCTYPE
;
136 typedef long long __int64
;
138 /* Pointers types. These are the same for emulator and library. */
141 typedef const void *PCVOID
;
143 typedef UCHAR
*PUCHAR
;
145 typedef ULONG
*PULONG
;
147 typedef DWORD
*PDWORD
;
148 /* common win32 types */
151 typedef const CHAR
*LPCSTR
;
152 typedef const CHAR
*PCSTR
;
153 typedef WCHAR
*LPWSTR
;
154 typedef WCHAR
*PWSTR
;
155 typedef const WCHAR
*LPCWSTR
;
156 typedef const WCHAR
*PCWSTR
;
157 typedef BYTE
*LPBYTE
;
158 typedef WORD
*LPWORD
;
159 typedef DWORD
*LPDWORD
;
160 typedef LONG
*LPLONG
;
161 typedef VOID
*LPVOID
;
162 typedef const VOID
*LPCVOID
;
163 typedef INT16
*LPINT16
;
164 typedef UINT16
*LPUINT16
;
168 typedef UINT
*LPUINT
;
169 typedef HKEY
*LPHKEY
;
171 typedef FLOAT
*PFLOAT
;
172 typedef FLOAT
*LPFLOAT
;
174 typedef BOOL
*LPBOOL
;
176 /* Special case: a segmented pointer is just a pointer in the user's code. */
179 typedef DWORD SEGPTR
;
181 typedef void* SEGPTR
;
182 #endif /* __WINE__ */
184 /* Handle types that exist both in Win16 and Win32. */
186 #define DECLARE_HANDLE(a) typedef HANDLE16 a##16; typedef HANDLE a
187 DECLARE_HANDLE(HACCEL
);
188 DECLARE_HANDLE(HBITMAP
);
189 DECLARE_HANDLE(HBRUSH
);
190 DECLARE_HANDLE(HCOLORSPACE
);
191 DECLARE_HANDLE(HCURSOR
);
193 DECLARE_HANDLE(HDROP
);
194 DECLARE_HANDLE(HDRVR
);
195 DECLARE_HANDLE(HDWP
);
196 DECLARE_HANDLE(HENHMETAFILE
);
197 DECLARE_HANDLE(HFILE
);
198 DECLARE_HANDLE(HFONT
);
199 DECLARE_HANDLE(HGDIOBJ
);
200 DECLARE_HANDLE(HGLOBAL
);
201 DECLARE_HANDLE(HICON
);
202 DECLARE_HANDLE(HINSTANCE
);
203 DECLARE_HANDLE(HLOCAL
);
204 DECLARE_HANDLE(HMENU
);
205 DECLARE_HANDLE(HMETAFILE
);
206 DECLARE_HANDLE(HMIDI
);
207 DECLARE_HANDLE(HMIDIIN
);
208 DECLARE_HANDLE(HMIDIOUT
);
209 DECLARE_HANDLE(HMIDISTRM
);
210 DECLARE_HANDLE(HMIXER
);
211 DECLARE_HANDLE(HMIXEROBJ
);
212 DECLARE_HANDLE(HMMIO
);
213 DECLARE_HANDLE(HMODULE
);
214 DECLARE_HANDLE(HPALETTE
);
215 DECLARE_HANDLE(HPEN
);
216 DECLARE_HANDLE(HQUEUE
);
217 DECLARE_HANDLE(HRGN
);
218 DECLARE_HANDLE(HRSRC
);
219 DECLARE_HANDLE(HTASK
);
220 DECLARE_HANDLE(HWAVE
);
221 DECLARE_HANDLE(HWAVEIN
);
222 DECLARE_HANDLE(HWAVEOUT
);
223 DECLARE_HANDLE(HWINSTA
);
224 DECLARE_HANDLE(HDESK
);
225 DECLARE_HANDLE(HWND
);
228 DECLARE_HANDLE(HRASCONN
);
229 #undef DECLARE_HANDLE
231 /* Callback function pointers types */
233 typedef BOOL (CALLBACK
* DATEFMT_ENUMPROCA
)(LPSTR
);
234 typedef BOOL (CALLBACK
* DATEFMT_ENUMPROCW
)(LPWSTR
);
235 DECL_WINELIB_TYPE_AW(DATEFMT_ENUMPROC
)
236 typedef BOOL16 (CALLBACK
*DLGPROC16
)(HWND16
,UINT16
,WPARAM16
,LPARAM
);
237 typedef BOOL (CALLBACK
*DLGPROC
)(HWND
,UINT
,WPARAM
,LPARAM
);
238 typedef LRESULT (CALLBACK
*DRIVERPROC16
)(DWORD
,HDRVR16
,UINT16
,LPARAM
,LPARAM
);
239 typedef LRESULT (CALLBACK
*DRIVERPROC
)(DWORD
,HDRVR
,UINT
,LPARAM
,LPARAM
);
240 typedef INT16 (CALLBACK
*EDITWORDBREAKPROC16
)(LPSTR
,INT16
,INT16
,INT16
);
241 typedef INT (CALLBACK
*EDITWORDBREAKPROCA
)(LPSTR
,INT
,INT
,INT
);
242 typedef INT (CALLBACK
*EDITWORDBREAKPROCW
)(LPWSTR
,INT
,INT
,INT
);
243 DECL_WINELIB_TYPE_AW(EDITWORDBREAKPROC
)
244 typedef LRESULT (CALLBACK
*FARPROC16
)();
245 typedef LRESULT (CALLBACK
*FARPROC
)();
246 typedef INT16 (CALLBACK
*PROC16
)();
247 typedef INT (CALLBACK
*PROC
)();
248 typedef INT16 (CALLBACK
*GOBJENUMPROC16
)(SEGPTR
,LPARAM
);
249 typedef INT (CALLBACK
*GOBJENUMPROC
)(LPVOID
,LPARAM
);
250 typedef BOOL16 (CALLBACK
*GRAYSTRINGPROC16
)(HDC16
,LPARAM
,INT16
);
251 typedef BOOL (CALLBACK
*GRAYSTRINGPROC
)(HDC
,LPARAM
,INT
);
252 typedef LRESULT (CALLBACK
*HOOKPROC16
)(INT16
,WPARAM16
,LPARAM
);
253 typedef LRESULT (CALLBACK
*HOOKPROC
)(INT
,WPARAM
,LPARAM
);
254 typedef VOID (CALLBACK
*LINEDDAPROC16
)(INT16
,INT16
,LPARAM
);
255 typedef VOID (CALLBACK
*LINEDDAPROC
)(INT
,INT
,LPARAM
);
256 typedef BOOL16 (CALLBACK
*PROPENUMPROC16
)(HWND16
,SEGPTR
,HANDLE16
);
257 typedef BOOL (CALLBACK
*PROPENUMPROCA
)(HWND
,LPCSTR
,HANDLE
);
258 typedef BOOL (CALLBACK
*PROPENUMPROCW
)(HWND
,LPCWSTR
,HANDLE
);
259 DECL_WINELIB_TYPE_AW(PROPENUMPROC
)
260 typedef BOOL (CALLBACK
*PROPENUMPROCEXA
)(HWND
,LPCSTR
,HANDLE
,LPARAM
);
261 typedef BOOL (CALLBACK
*PROPENUMPROCEXW
)(HWND
,LPCWSTR
,HANDLE
,LPARAM
);
262 DECL_WINELIB_TYPE_AW(PROPENUMPROCEX
)
263 typedef BOOL (CALLBACK
* TIMEFMT_ENUMPROCA
)(LPSTR
);
264 typedef BOOL (CALLBACK
* TIMEFMT_ENUMPROCW
)(LPWSTR
);
265 DECL_WINELIB_TYPE_AW(TIMEFMT_ENUMPROC
)
266 typedef VOID (CALLBACK
*TIMERPROC16
)(HWND16
,UINT16
,UINT16
,DWORD
);
267 typedef VOID (CALLBACK
*TIMERPROC
)(HWND
,UINT
,UINT
,DWORD
);
268 typedef LRESULT (CALLBACK
*WNDENUMPROC16
)(HWND16
,LPARAM
);
269 typedef LRESULT (CALLBACK
*WNDENUMPROC
)(HWND
,LPARAM
);
270 typedef LRESULT (CALLBACK
*WNDPROC16
)(HWND16
,UINT16
,WPARAM16
,LPARAM
);
271 typedef LRESULT (CALLBACK
*WNDPROC
)(HWND
,UINT
,WPARAM
,LPARAM
);
273 /* TCHAR data types definitions for Winelib. */
274 /* These types are _not_ defined for the emulator, because they */
275 /* depend on the UNICODE macro that only exists in user's code. */
280 typedef LPWSTR LPTSTR
;
281 typedef LPCWSTR LPCTSTR
;
282 #define __TEXT(string) L##string /*probably wrong */
285 typedef LPSTR LPTSTR
;
286 typedef LPCSTR LPCTSTR
;
287 #define __TEXT(string) string
288 # endif /* UNICODE */
289 #endif /* __WINE__ */
290 #define TEXT(quote) __TEXT(quote)
292 /* Data types specific to the library. These do _not_ exist in the emulator. */
296 /* Define some empty macros for compatibility with Windows code. */
308 #endif /* __WINE__ */
310 /* Macro for structure packing. */
313 #define WINE_PACKED __attribute__ ((packed))
314 #define WINE_UNUSED __attribute__ ((unused))
316 #define WINE_PACKED /* nothing */
317 #define WINE_UNUSED /* nothing */
320 /* Macros to split words and longs. */
322 #define LOBYTE(w) ((BYTE)(WORD)(w))
323 #define HIBYTE(w) ((BYTE)((WORD)(w) >> 8))
325 #define LOWORD(l) ((WORD)(DWORD)(l))
326 #define HIWORD(l) ((WORD)((DWORD)(l) >> 16))
328 #define SLOWORD(l) ((INT16)(LONG)(l))
329 #define SHIWORD(l) ((INT16)((LONG)(l) >> 16))
331 #define MAKEWORD(low,high) ((WORD)(((BYTE)(low)) | ((WORD)((BYTE)(high))) << 8))
332 #define MAKELONG(low,high) ((LONG)(((WORD)(low)) | (((DWORD)((WORD)(high))) << 16)))
333 #define MAKELPARAM(low,high) ((LPARAM)MAKELONG(low,high))
334 #define MAKEWPARAM(low,high) ((WPARAM)MAKELONG(low,high))
335 #define MAKELRESULT(low,high) ((LRESULT)MAKELONG(low,high))
336 #define MAKEINTATOM(atom) ((LPCSTR)MAKELONG((atom),0))
338 #define SELECTOROF(ptr) (HIWORD(ptr))
339 #define OFFSETOF(ptr) (LOWORD(ptr))
341 /* Macros to access unaligned or wrong-endian WORDs and DWORDs. */
342 /* Note: These macros are semantically broken, at least for wrc. wrc
343 spits out data in the platform's current binary format, *not* in
344 little-endian format. These macros are used throughout the resource
345 code to load and store data to the resources. Since it is unlikely
346 that we'll ever be dealing with little-endian resource data, the
347 byte-swapping nature of these macros has been disabled. Rather than
348 remove the use of these macros from the resource loading code, the
349 macros have simply been disabled. In the future, someone may want
350 to reactivate these macros for other purposes. In that case, the
351 resource code will have to be modified to use different macros. */
354 #define PUT_WORD(ptr,w) (*(WORD *)(ptr) = (w))
355 #define GET_WORD(ptr) (*(WORD *)(ptr))
356 #define PUT_DWORD(ptr,dw) (*(DWORD *)(ptr) = (dw))
357 #define GET_DWORD(ptr) (*(DWORD *)(ptr))
359 #define PUT_WORD(ptr,w) (*(BYTE *)(ptr) = LOBYTE(w), \
360 *((BYTE *)(ptr) + 1) = HIBYTE(w))
361 #define GET_WORD(ptr) ((WORD)(*(BYTE *)(ptr) | \
362 (WORD)(*((BYTE *)(ptr)+1) << 8)))
363 #define PUT_DWORD(ptr,dw) (PUT_WORD((ptr),LOWORD(dw)), \
364 PUT_WORD((WORD *)(ptr)+1,HIWORD(dw)))
365 #define GET_DWORD(ptr) ((DWORD)(GET_WORD(ptr) | \
366 ((DWORD)GET_WORD((WORD *)(ptr)+1) << 16)))
369 /* MIN and MAX macros */
374 #define MAX(a,b) (((a) > (b)) ? (a) : (b))
379 #define MIN(a,b) (((a) < (b)) ? (a) : (b))
381 #define __max(a,b) MAX(a,b)
382 #define __min(a,b) MIN(a,b)
383 #define max(a,b) MAX(a,b)
384 #define min(a,b) MIN(a,b)
386 #define _MAX_PATH 260
390 #define _MAX_FNAME 255
393 #define HFILE_ERROR16 ((HFILE16)-1)
394 #define HFILE_ERROR ((HFILE)-1)
396 /* Winelib run-time flag */
399 extern int __winelib
;
400 #endif /* __WINE__ */
402 /* The SIZE structure */
408 } SIZE16
, *PSIZE16
, *LPSIZE16
;
410 typedef struct tagSIZE
414 } SIZE
, *PSIZE
, *LPSIZE
;
417 typedef SIZE SIZEL
, *PSIZEL
, *LPSIZEL
;
419 #define CONV_SIZE16TO32(s16,s32) \
420 ((s32)->cx = (INT)(s16)->cx, (s32)->cy = (INT)(s16)->cy)
421 #define CONV_SIZE32TO16(s32,s16) \
422 ((s16)->cx = (INT16)(s32)->cx, (s16)->cy = (INT16)(s32)->cy)
424 /* The POINT structure */
430 } POINT16
, *PPOINT16
, *LPPOINT16
;
432 typedef struct tagPOINT
436 } POINT
, *PPOINT
, *LPPOINT
;
438 typedef struct _POINTL
444 #define CONV_POINT16TO32(p16,p32) \
445 ((p32)->x = (INT)(p16)->x, (p32)->y = (INT)(p16)->y)
446 #define CONV_POINT32TO16(p32,p16) \
447 ((p16)->x = (INT16)(p32)->x, (p16)->y = (INT16)(p32)->y)
449 #define MAKEPOINT16(l) (*((POINT16 *)&(l)))
451 /* The POINTS structure */
453 typedef struct tagPOINTS
457 } POINTS
, *PPOINTS
, *LPPOINTS
;
460 #define MAKEPOINTS(l) (*((POINTS *)&(l)))
463 /* The RECT structure */
473 typedef struct tagRECT
479 } RECT
, *PRECT
, *LPRECT
;
480 typedef const RECT
*LPCRECT
;
483 typedef struct tagRECTL
489 } RECTL
, *PRECTL
, *LPRECTL
;
491 typedef const RECTL
*LPCRECTL
;
493 #define CONV_RECT16TO32(r16,r32) \
494 ((r32)->left = (INT)(r16)->left, (r32)->top = (INT)(r16)->top, \
495 (r32)->right = (INT)(r16)->right, (r32)->bottom = (INT)(r16)->bottom)
496 #define CONV_RECT32TO16(r32,r16) \
497 ((r16)->left = (INT16)(r32)->left, (r16)->top = (INT16)(r32)->top, \
498 (r16)->right = (INT16)(r32)->right, (r16)->bottom = (INT16)(r32)->bottom)
504 #endif /* __WINE_WINTYPES_H */