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) \
187 typedef HANDLE16 a##16; \
189 typedef a##16 *P##a##16; \
190 typedef a##16 *NP##a##16; \
191 typedef a##16 *LP##a##16; \
194 DECLARE_HANDLE(HACMDRIVERID);
195 DECLARE_HANDLE(HACMDRIVER);
196 DECLARE_HANDLE(HACMOBJ);
197 DECLARE_HANDLE(HACMSTREAM);
198 DECLARE_HANDLE(HMETAFILEPICT);
200 DECLARE_HANDLE(HACCEL);
201 DECLARE_HANDLE(HBITMAP);
202 DECLARE_HANDLE(HBRUSH);
203 DECLARE_HANDLE(HCOLORSPACE);
204 DECLARE_HANDLE(HCURSOR);
206 DECLARE_HANDLE(HDROP);
207 DECLARE_HANDLE(HDRVR);
208 DECLARE_HANDLE(HDWP);
209 DECLARE_HANDLE(HENHMETAFILE);
210 DECLARE_HANDLE(HFILE);
211 DECLARE_HANDLE(HFONT);
212 DECLARE_HANDLE(HGDIOBJ);
213 DECLARE_HANDLE(HGLOBAL);
214 DECLARE_HANDLE(HICON);
215 DECLARE_HANDLE(HINSTANCE);
216 DECLARE_HANDLE(HLOCAL);
217 DECLARE_HANDLE(HMENU);
218 DECLARE_HANDLE(HMETAFILE);
219 DECLARE_HANDLE(HMIDI);
220 DECLARE_HANDLE(HMIDIIN);
221 DECLARE_HANDLE(HMIDIOUT);
222 DECLARE_HANDLE(HMIDISTRM);
223 DECLARE_HANDLE(HMIXER);
224 DECLARE_HANDLE(HMIXEROBJ);
225 DECLARE_HANDLE(HMMIO);
226 DECLARE_HANDLE(HMODULE);
227 DECLARE_HANDLE(HPALETTE);
228 DECLARE_HANDLE(HPEN);
229 DECLARE_HANDLE(HQUEUE);
230 DECLARE_HANDLE(HRGN);
231 DECLARE_HANDLE(HRSRC);
232 DECLARE_HANDLE(HTASK);
233 DECLARE_HANDLE(HWAVE);
234 DECLARE_HANDLE(HWAVEIN);
235 DECLARE_HANDLE(HWAVEOUT);
236 DECLARE_HANDLE(HWINSTA);
237 DECLARE_HANDLE(HDESK);
238 DECLARE_HANDLE(HWND);
241 DECLARE_HANDLE(HRASCONN);
242 #undef DECLARE_HANDLE
244 /* Callback function pointers types */
246 typedef BOOL (CALLBACK* DATEFMT_ENUMPROCA)(LPSTR);
247 typedef BOOL (CALLBACK* DATEFMT_ENUMPROCW)(LPWSTR);
248 DECL_WINELIB_TYPE_AW(DATEFMT_ENUMPROC)
249 typedef BOOL16 (CALLBACK *DLGPROC16)(HWND16,UINT16,WPARAM16,LPARAM);
250 typedef BOOL (CALLBACK *DLGPROC)(HWND,UINT,WPARAM,LPARAM);
251 typedef LRESULT (CALLBACK *DRIVERPROC16)(DWORD,HDRVR16,UINT16,LPARAM,LPARAM);
252 typedef LRESULT (CALLBACK *DRIVERPROC)(DWORD,HDRVR,UINT,LPARAM,LPARAM);
253 typedef INT16 (CALLBACK *EDITWORDBREAKPROC16)(LPSTR,INT16,INT16,INT16);
254 typedef INT (CALLBACK *EDITWORDBREAKPROCA)(LPSTR,INT,INT,INT);
255 typedef INT (CALLBACK *EDITWORDBREAKPROCW)(LPWSTR,INT,INT,INT);
256 DECL_WINELIB_TYPE_AW(EDITWORDBREAKPROC)
257 typedef LRESULT (CALLBACK *FARPROC16)();
258 typedef LRESULT (CALLBACK *FARPROC)();
259 typedef INT16 (CALLBACK *PROC16)();
260 typedef INT (CALLBACK *PROC)();
261 typedef INT16 (CALLBACK *GOBJENUMPROC16)(SEGPTR,LPARAM);
262 typedef INT (CALLBACK *GOBJENUMPROC)(LPVOID,LPARAM);
263 typedef BOOL16 (CALLBACK *GRAYSTRINGPROC16)(HDC16,LPARAM,INT16);
264 typedef BOOL (CALLBACK *GRAYSTRINGPROC)(HDC,LPARAM,INT);
265 typedef LRESULT (CALLBACK *HOOKPROC16)(INT16,WPARAM16,LPARAM);
266 typedef LRESULT (CALLBACK *HOOKPROC)(INT,WPARAM,LPARAM);
267 typedef VOID (CALLBACK *LINEDDAPROC16)(INT16,INT16,LPARAM);
268 typedef VOID (CALLBACK *LINEDDAPROC)(INT,INT,LPARAM);
269 typedef BOOL16 (CALLBACK *PROPENUMPROC16)(HWND16,SEGPTR,HANDLE16);
270 typedef BOOL (CALLBACK *PROPENUMPROCA)(HWND,LPCSTR,HANDLE);
271 typedef BOOL (CALLBACK *PROPENUMPROCW)(HWND,LPCWSTR,HANDLE);
272 DECL_WINELIB_TYPE_AW(PROPENUMPROC)
273 typedef BOOL (CALLBACK *PROPENUMPROCEXA)(HWND,LPCSTR,HANDLE,LPARAM);
274 typedef BOOL (CALLBACK *PROPENUMPROCEXW)(HWND,LPCWSTR,HANDLE,LPARAM);
275 DECL_WINELIB_TYPE_AW(PROPENUMPROCEX)
276 typedef BOOL (CALLBACK* TIMEFMT_ENUMPROCA)(LPSTR);
277 typedef BOOL (CALLBACK* TIMEFMT_ENUMPROCW)(LPWSTR);
278 DECL_WINELIB_TYPE_AW(TIMEFMT_ENUMPROC)
279 typedef VOID (CALLBACK *TIMERPROC16)(HWND16,UINT16,UINT16,DWORD);
280 typedef VOID (CALLBACK *TIMERPROC)(HWND,UINT,UINT,DWORD);
281 typedef LRESULT (CALLBACK *WNDENUMPROC16)(HWND16,LPARAM);
282 typedef LRESULT (CALLBACK *WNDENUMPROC)(HWND,LPARAM);
283 typedef LRESULT (CALLBACK *WNDPROC16)(HWND16,UINT16,WPARAM16,LPARAM);
284 typedef LRESULT (CALLBACK *WNDPROC)(HWND,UINT,WPARAM,LPARAM);
286 /* TCHAR data types definitions for Winelib. */
287 /* These types are _not_ defined for the emulator, because they */
288 /* depend on the UNICODE macro that only exists in user's code. */
293 typedef LPWSTR LPTSTR;
294 typedef LPCWSTR LPCTSTR;
295 #define __TEXT(string) L##string /*probably wrong */
298 typedef LPSTR LPTSTR;
299 typedef LPCSTR LPCTSTR;
300 #define __TEXT(string) string
301 # endif /* UNICODE */
302 #endif /* __WINE__ */
303 #define TEXT(quote) __TEXT(quote)
305 /* Data types specific to the library. These do _not_ exist in the emulator. */
309 /* Define some empty macros for compatibility with Windows code. */
321 #endif /* __WINE__ */
323 /* Macro for structure packing. */
326 #define WINE_PACKED __attribute__ ((packed))
327 #define WINE_UNUSED __attribute__ ((unused))
329 #define WINE_PACKED /* nothing */
330 #define WINE_UNUSED /* nothing */
333 /* Macros to split words and longs. */
335 #define LOBYTE(w) ((BYTE)(WORD)(w))
336 #define HIBYTE(w) ((BYTE)((WORD)(w) >> 8))
338 #define LOWORD(l) ((WORD)(DWORD)(l))
339 #define HIWORD(l) ((WORD)((DWORD)(l) >> 16))
341 #define SLOWORD(l) ((INT16)(LONG)(l))
342 #define SHIWORD(l) ((INT16)((LONG)(l) >> 16))
344 #define MAKEWORD(low,high) ((WORD)(((BYTE)(low)) | ((WORD)((BYTE)(high))) << 8))
345 #define MAKELONG(low,high) ((LONG)(((WORD)(low)) | (((DWORD)((WORD)(high))) << 16)))
346 #define MAKELPARAM(low,high) ((LPARAM)MAKELONG(low,high))
347 #define MAKEWPARAM(low,high) ((WPARAM)MAKELONG(low,high))
348 #define MAKELRESULT(low,high) ((LRESULT)MAKELONG(low,high))
349 #define MAKEINTATOM(atom) ((LPCSTR)MAKELONG((atom),0))
351 #define SELECTOROF(ptr) (HIWORD(ptr))
352 #define OFFSETOF(ptr) (LOWORD(ptr))
354 /* Macros to access unaligned or wrong-endian WORDs and DWORDs. */
355 /* Note: These macros are semantically broken, at least for wrc. wrc
356 spits out data in the platform's current binary format, *not* in
357 little-endian format. These macros are used throughout the resource
358 code to load and store data to the resources. Since it is unlikely
359 that we'll ever be dealing with little-endian resource data, the
360 byte-swapping nature of these macros has been disabled. Rather than
361 remove the use of these macros from the resource loading code, the
362 macros have simply been disabled. In the future, someone may want
363 to reactivate these macros for other purposes. In that case, the
364 resource code will have to be modified to use different macros. */
367 #define PUT_WORD(ptr,w) (*(WORD *)(ptr) = (w))
368 #define GET_WORD(ptr) (*(WORD *)(ptr))
369 #define PUT_DWORD(ptr,dw) (*(DWORD *)(ptr) = (dw))
370 #define GET_DWORD(ptr) (*(DWORD *)(ptr))
372 #define PUT_WORD(ptr,w) (*(BYTE *)(ptr) = LOBYTE(w), \
373 *((BYTE *)(ptr) + 1) = HIBYTE(w))
374 #define GET_WORD(ptr) ((WORD)(*(BYTE *)(ptr) | \
375 (WORD)(*((BYTE *)(ptr)+1) << 8)))
376 #define PUT_DWORD(ptr,dw) (PUT_WORD((ptr),LOWORD(dw)), \
377 PUT_WORD((WORD *)(ptr)+1,HIWORD(dw)))
378 #define GET_DWORD(ptr) ((DWORD)(GET_WORD(ptr) | \
379 ((DWORD)GET_WORD((WORD *)(ptr)+1) << 16)))
382 /* MIN and MAX macros */
387 #define MAX(a,b) (((a) > (b)) ? (a) : (b))
392 #define MIN(a,b) (((a) < (b)) ? (a) : (b))
394 #define __max(a,b) MAX(a,b)
395 #define __min(a,b) MIN(a,b)
396 #define max(a,b) MAX(a,b)
397 #define min(a,b) MIN(a,b)
399 #define _MAX_PATH 260
403 #define _MAX_FNAME 255
406 #define HFILE_ERROR16 ((HFILE16)-1)
407 #define HFILE_ERROR ((HFILE)-1)
409 /* Winelib run-time flag */
412 extern int __winelib;
413 #endif /* __WINE__ */
415 /* The SIZE structure */
421 } SIZE16, *PSIZE16, *LPSIZE16;
423 typedef struct tagSIZE
427 } SIZE, *PSIZE, *LPSIZE;
430 typedef SIZE SIZEL, *PSIZEL, *LPSIZEL;
432 #define CONV_SIZE16TO32(s16,s32) \
433 ((s32)->cx = (INT)(s16)->cx, (s32)->cy = (INT)(s16)->cy)
434 #define CONV_SIZE32TO16(s32,s16) \
435 ((s16)->cx = (INT16)(s32)->cx, (s16)->cy = (INT16)(s32)->cy)
437 /* The POINT structure */
443 } POINT16, *PPOINT16, *LPPOINT16;
445 typedef struct tagPOINT
449 } POINT, *PPOINT, *LPPOINT;
451 typedef struct _POINTL
457 #define CONV_POINT16TO32(p16,p32) \
458 ((p32)->x = (INT)(p16)->x, (p32)->y = (INT)(p16)->y)
459 #define CONV_POINT32TO16(p32,p16) \
460 ((p16)->x = (INT16)(p32)->x, (p16)->y = (INT16)(p32)->y)
462 #define MAKEPOINT16(l) (*((POINT16 *)&(l)))
464 /* The POINTS structure */
466 typedef struct tagPOINTS
470 } POINTS, *PPOINTS, *LPPOINTS;
473 #define MAKEPOINTS(l) (*((POINTS *)&(l)))
476 /* The RECT structure */
486 typedef struct tagRECT
492 } RECT, *PRECT, *LPRECT;
493 typedef const RECT *LPCRECT;
496 typedef struct tagRECTL
502 } RECTL, *PRECTL, *LPRECTL;
504 typedef const RECTL *LPCRECTL;
506 #define CONV_RECT16TO32(r16,r32) \
507 ((r32)->left = (INT)(r16)->left, (r32)->top = (INT)(r16)->top, \
508 (r32)->right = (INT)(r16)->right, (r32)->bottom = (INT)(r16)->bottom)
509 #define CONV_RECT32TO16(r32,r16) \
510 ((r16)->left = (INT16)(r32)->left, (r16)->top = (INT16)(r32)->top, \
511 (r16)->right = (INT16)(r32)->right, (r16)->bottom = (INT16)(r32)->bottom)
517 #endif /* __WINE_WINDEF_H */