Added typedefs for PSHORT and PUSHORT.
[wine.git] / include / windef.h
blob6a5c9db634ecca11cbd2d9fe92c851ea38a07cb5
1 /*
2 * Basic types definitions
4 * Copyright 1996 Alexandre Julliard
5 */
7 #ifndef __WINE_WINDEF_H
8 #define __WINE_WINDEF_H
10 #ifdef __WINE__
11 # include "config.h"
12 # undef UNICODE
13 #endif /* __WINE__ */
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
19 /* Misc. constants. */
21 #ifdef FALSE
22 #undef FALSE
23 #endif
24 #define FALSE 0
26 #ifdef TRUE
27 #undef TRUE
28 #endif
29 #define TRUE 1
31 #ifdef NULL
32 #undef NULL
33 #endif
34 #define NULL 0
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. */
40 #ifdef __WINE__
41 # define WINELIB_NAME_AW(func) \
42 func##_must_be_suffixed_with_W_or_A_in_this_context \
43 func##_must_be_suffixed_with_W_or_A_in_this_context
44 #else /* __WINE__ */
45 # ifdef UNICODE
46 # define WINELIB_NAME_AW(func) func##W
47 # else
48 # define WINELIB_NAME_AW(func) func##A
49 # endif /* UNICODE */
50 #endif /* __WINE__ */
52 #ifdef __WINE__
53 # define DECL_WINELIB_TYPE_AW(type) /* nothing */
54 #else /* __WINE__ */
55 # define DECL_WINELIB_TYPE_AW(type) typedef WINELIB_NAME_AW(type) type;
56 #endif /* __WINE__ */
58 #ifndef NONAMELESSSTRUCT
59 # if defined(__WINE__) || !defined(_FORCENAMELESSSTRUCT)
60 # define NONAMELESSSTRUCT
61 # endif
62 #endif /* !defined(NONAMELESSSTRUCT) */
64 #ifndef NONAMELESSUNION
65 # if defined(__WINE__) || !defined(_FORCENAMELESSUNION) || !defined(__cplusplus)
66 # define NONAMELESSUNION
67 # endif
68 #endif /* !defined(NONAMELESSUNION) */
70 #ifndef NONAMELESSSTRUCT
71 #define DUMMYSTRUCTNAME
72 #define DUMMYSTRUCTNAME1
73 #define DUMMYSTRUCTNAME2
74 #define DUMMYSTRUCTNAME3
75 #define DUMMYSTRUCTNAME4
76 #define DUMMYSTRUCTNAME5
77 #else /* !defined(NONAMELESSSTRUCT) */
78 #define DUMMYSTRUCTNAME s
79 #define DUMMYSTRUCTNAME1 s1
80 #define DUMMYSTRUCTNAME2 s2
81 #define DUMMYSTRUCTNAME3 s3
82 #define DUMMYSTRUCTNAME4 s4
83 #define DUMMYSTRUCTNAME5 s5
84 #endif /* !defined(NONAMELESSSTRUCT) */
86 #ifndef NONAMELESSUNION
87 #define DUMMYUNIONNAME
88 #define DUMMYUNIONNAME1
89 #define DUMMYUNIONNAME2
90 #define DUMMYUNIONNAME3
91 #define DUMMYUNIONNAME4
92 #define DUMMYUNIONNAME5
93 #else /* !defined(NONAMELESSUNION) */
94 #define DUMMYUNIONNAME u
95 #define DUMMYUNIONNAME1 u1
96 #define DUMMYUNIONNAME2 u2
97 #define DUMMYUNIONNAME3 u3
98 #define DUMMYUNIONNAME4 u4
99 #define DUMMYUNIONNAME5 u5
100 #endif /* !defined(NONAMELESSUNION) */
102 /* Calling conventions definitions */
104 #ifdef __i386__
105 # if defined(__GNUC__) && ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 7)))
106 # define __stdcall __attribute__((__stdcall__))
107 # define __cdecl __attribute__((__cdecl__))
108 # define __RESTORE_ES __asm__ __volatile__("pushl %ds\n\tpopl %es")
109 # else
110 # error You need gcc >= 2.7 to build Wine on a 386
111 # endif /* __GNUC__ */
112 #else /* __i386__ */
113 # define __stdcall
114 # define __cdecl
115 # define __RESTORE_ES
116 #endif /* __i386__ */
118 #define CALLBACK __stdcall
119 #define WINAPI __stdcall
120 #define APIPRIVATE __stdcall
121 #define PASCAL __stdcall
122 #define pascal __stdcall
123 #define _pascal __stdcall
124 #define _stdcall __stdcall
125 #define _fastcall __stdcall
126 #define __export __stdcall
127 #define CDECL __cdecl
128 #define _CDECL __cdecl
129 #define cdecl __cdecl
130 #define _cdecl __cdecl
131 #define WINAPIV __cdecl
132 #define APIENTRY WINAPI
134 #define __declspec(x)
135 #define dllimport
136 #define dllexport
138 #define CONST const
140 /* Standard data types. These are the same for emulator and library. */
142 typedef void VOID;
143 typedef int INT;
144 typedef unsigned int UINT;
145 typedef unsigned short WORD;
146 typedef unsigned long DWORD;
147 typedef unsigned long ULONG;
148 typedef unsigned char BYTE;
149 typedef long LONG;
150 typedef short SHORT;
151 typedef unsigned short USHORT;
152 typedef char CHAR;
153 typedef unsigned char UCHAR;
154 /* Some systems might have wchar_t, but we really need 16 bit characters */
155 typedef unsigned short WCHAR;
156 typedef int BOOL;
157 typedef double DATE;
158 typedef double DOUBLE;
159 typedef double LONGLONG;
160 typedef double ULONGLONG;
162 /* FIXME: Wine does not compile with strict on, therefore strict
163 * handles are presently only usable on machines where sizeof(UINT) ==
164 * sizeof(void*). HANDLEs are supposed to be void* but a large amount
165 * of WINE code operates on HANDLES as if they are UINTs. So to WINE
166 * they exist as UINTs but to the Winelib user who turns on strict,
167 * they exist as void*. If there is a size difference between UINT and
168 * void* then things get ugly. */
169 #ifdef STRICT
170 typedef VOID* HANDLE;
171 #else
172 typedef UINT HANDLE;
173 #endif
176 typedef HANDLE *LPHANDLE;
178 /* Integer types. These are the same for emulator and library. */
179 typedef UINT WPARAM;
180 typedef LONG LPARAM;
181 typedef LONG HRESULT;
182 typedef LONG LRESULT;
183 typedef WORD ATOM;
184 typedef WORD CATCHBUF[9];
185 typedef WORD *LPCATCHBUF;
186 typedef HANDLE HHOOK;
187 typedef HANDLE HMONITOR;
188 typedef DWORD LCID;
189 typedef WORD LANGID;
190 typedef DWORD LCTYPE;
191 typedef float FLOAT;
193 /* Pointers types. These are the same for emulator and library. */
194 /* winnt types */
195 typedef VOID *PVOID;
196 typedef const void *PCVOID;
197 typedef CHAR *PCHAR;
198 typedef UCHAR *PUCHAR;
199 typedef BYTE *PBYTE;
200 typedef WORD *PWORD;
201 typedef USHORT *PUSHORT;
202 typedef SHORT *PSHORT;
203 typedef ULONG *PULONG;
204 typedef LONG *PLONG;
205 typedef DWORD *PDWORD;
206 /* common win32 types */
207 typedef CHAR *LPSTR;
208 typedef CHAR *PSTR;
209 typedef const CHAR *LPCSTR;
210 typedef const CHAR *PCSTR;
211 typedef WCHAR *LPWSTR;
212 typedef WCHAR *PWSTR;
213 typedef const WCHAR *LPCWSTR;
214 typedef const WCHAR *PCWSTR;
215 typedef BYTE *LPBYTE;
216 typedef WORD *LPWORD;
217 typedef DWORD *LPDWORD;
218 typedef LONG *LPLONG;
219 typedef VOID *LPVOID;
220 typedef const VOID *LPCVOID;
221 typedef INT *PINT;
222 typedef INT *LPINT;
223 typedef UINT *PUINT;
224 typedef UINT *LPUINT;
225 typedef FLOAT *PFLOAT;
226 typedef FLOAT *LPFLOAT;
227 typedef BOOL *PBOOL;
228 typedef BOOL *LPBOOL;
230 /* Special case: a segmented pointer is just a pointer in the user's code. */
232 #ifdef __WINE__
233 typedef DWORD SEGPTR;
234 #else
235 typedef void* SEGPTR;
236 #endif /* __WINE__ */
238 /* Handle types that exist both in Win16 and Win32. */
240 #ifdef STRICT
241 #define DECLARE_HANDLE(a) \
242 typedef struct a##__ { int unused; } *a; \
243 typedef a *P##a; \
244 typedef a *LP##a
245 #else /*STRICT*/
246 #define DECLARE_HANDLE(a) \
247 typedef HANDLE a; \
248 typedef a *P##a; \
249 typedef a *LP##a
250 #endif /*STRICT*/
252 DECLARE_HANDLE(HACMDRIVERID);
253 DECLARE_HANDLE(HACMDRIVER);
254 DECLARE_HANDLE(HACMOBJ);
255 DECLARE_HANDLE(HACMSTREAM);
256 DECLARE_HANDLE(HMETAFILEPICT);
258 DECLARE_HANDLE(HACCEL);
259 DECLARE_HANDLE(HBITMAP);
260 DECLARE_HANDLE(HBRUSH);
261 DECLARE_HANDLE(HCOLORSPACE);
262 DECLARE_HANDLE(HCURSOR);
263 DECLARE_HANDLE(HDC);
264 DECLARE_HANDLE(HDROP);
265 DECLARE_HANDLE(HDRVR);
266 DECLARE_HANDLE(HDWP);
267 DECLARE_HANDLE(HENHMETAFILE);
268 DECLARE_HANDLE(HFILE);
269 DECLARE_HANDLE(HFONT);
270 DECLARE_HANDLE(HICON);
271 DECLARE_HANDLE(HINSTANCE);
272 DECLARE_HANDLE(HKEY);
273 DECLARE_HANDLE(HMENU);
274 DECLARE_HANDLE(HMETAFILE);
275 DECLARE_HANDLE(HMIDI);
276 DECLARE_HANDLE(HMIDIIN);
277 DECLARE_HANDLE(HMIDIOUT);
278 DECLARE_HANDLE(HMIDISTRM);
279 DECLARE_HANDLE(HMIXER);
280 DECLARE_HANDLE(HMIXEROBJ);
281 DECLARE_HANDLE(HMMIO);
282 DECLARE_HANDLE(HPALETTE);
283 DECLARE_HANDLE(HPEN);
284 DECLARE_HANDLE(HQUEUE);
285 DECLARE_HANDLE(HRGN);
286 DECLARE_HANDLE(HRSRC);
287 DECLARE_HANDLE(HTASK);
288 DECLARE_HANDLE(HWAVE);
289 DECLARE_HANDLE(HWAVEIN);
290 DECLARE_HANDLE(HWAVEOUT);
291 DECLARE_HANDLE(HWINSTA);
292 DECLARE_HANDLE(HDESK);
293 DECLARE_HANDLE(HWND);
294 DECLARE_HANDLE(HKL);
295 DECLARE_HANDLE(HIC);
296 DECLARE_HANDLE(HRASCONN);
297 #undef DECLARE_HANDLE
299 /* Handle types that must remain interchangeable even with strict on */
301 typedef HINSTANCE HMODULE;
302 typedef HANDLE HGDIOBJ;
303 typedef HANDLE HGLOBAL;
304 typedef HANDLE HLOCAL;
306 /* Callback function pointers types */
308 typedef BOOL (CALLBACK* DATEFMT_ENUMPROCA)(LPSTR);
309 typedef BOOL (CALLBACK* DATEFMT_ENUMPROCW)(LPWSTR);
310 DECL_WINELIB_TYPE_AW(DATEFMT_ENUMPROC)
311 typedef BOOL (CALLBACK *DLGPROC)(HWND,UINT,WPARAM,LPARAM);
312 typedef LRESULT (CALLBACK *DRIVERPROC)(DWORD,HDRVR,UINT,LPARAM,LPARAM);
313 typedef INT (CALLBACK *EDITWORDBREAKPROCA)(LPSTR,INT,INT,INT);
314 typedef INT (CALLBACK *EDITWORDBREAKPROCW)(LPWSTR,INT,INT,INT);
315 DECL_WINELIB_TYPE_AW(EDITWORDBREAKPROC)
316 typedef LRESULT (CALLBACK *FARPROC)();
317 typedef INT (CALLBACK *PROC)();
318 typedef BOOL (CALLBACK *GRAYSTRINGPROC)(HDC,LPARAM,INT);
319 typedef LRESULT (CALLBACK *HOOKPROC)(INT,WPARAM,LPARAM);
320 typedef BOOL (CALLBACK *PROPENUMPROCA)(HWND,LPCSTR,HANDLE);
321 typedef BOOL (CALLBACK *PROPENUMPROCW)(HWND,LPCWSTR,HANDLE);
322 DECL_WINELIB_TYPE_AW(PROPENUMPROC)
323 typedef BOOL (CALLBACK *PROPENUMPROCEXA)(HWND,LPCSTR,HANDLE,LPARAM);
324 typedef BOOL (CALLBACK *PROPENUMPROCEXW)(HWND,LPCWSTR,HANDLE,LPARAM);
325 DECL_WINELIB_TYPE_AW(PROPENUMPROCEX)
326 typedef BOOL (CALLBACK* TIMEFMT_ENUMPROCA)(LPSTR);
327 typedef BOOL (CALLBACK* TIMEFMT_ENUMPROCW)(LPWSTR);
328 DECL_WINELIB_TYPE_AW(TIMEFMT_ENUMPROC)
329 typedef VOID (CALLBACK *TIMERPROC)(HWND,UINT,UINT,DWORD);
330 typedef LRESULT (CALLBACK *WNDENUMPROC)(HWND,LPARAM);
331 typedef LRESULT (CALLBACK *WNDPROC)(HWND,UINT,WPARAM,LPARAM);
333 /*----------------------------------------------------------------------------
334 ** FIXME: Better isolate Wine's reliance on the xxx16 type definitions.
335 ** For now, we just isolate them to make the situation clear.
336 **--------------------------------------------------------------------------*/
337 #include "wine/windef16.h"
339 /* Define some empty macros for compatibility with Windows code. */
341 #ifndef __WINE__
342 #define NEAR
343 #define FAR
344 #define near
345 #define far
346 #define _near
347 #define _far
348 #define IN
349 #define OUT
350 #define OPTIONAL
351 #endif /* __WINE__ */
353 /* Macro for structure packing. */
355 #ifdef __GNUC__
356 #define WINE_PACKED __attribute__ ((packed))
357 #define WINE_UNUSED __attribute__ ((unused))
358 #else
359 #define WINE_PACKED /* nothing */
360 #define WINE_UNUSED /* nothing */
361 #endif
363 /* Macros to split words and longs. */
365 #define LOBYTE(w) ((BYTE)(WORD)(w))
366 #define HIBYTE(w) ((BYTE)((WORD)(w) >> 8))
368 #define LOWORD(l) ((WORD)(DWORD)(l))
369 #define HIWORD(l) ((WORD)((DWORD)(l) >> 16))
371 #define SLOWORD(l) ((INT16)(LONG)(l))
372 #define SHIWORD(l) ((INT16)((LONG)(l) >> 16))
374 #define MAKEWORD(low,high) ((WORD)(((BYTE)(low)) | ((WORD)((BYTE)(high))) << 8))
375 #define MAKELONG(low,high) ((LONG)(((WORD)(low)) | (((DWORD)((WORD)(high))) << 16)))
376 #define MAKELPARAM(low,high) ((LPARAM)MAKELONG(low,high))
377 #define MAKEWPARAM(low,high) ((WPARAM)MAKELONG(low,high))
378 #define MAKELRESULT(low,high) ((LRESULT)MAKELONG(low,high))
379 #define MAKEINTATOM(atom) ((LPCSTR)MAKELONG((atom),0))
381 #define SELECTOROF(ptr) (HIWORD(ptr))
382 #define OFFSETOF(ptr) (LOWORD(ptr))
384 #ifdef __WINE__
385 /* macros to set parts of a DWORD (not in the Windows API) */
386 #define SET_LOWORD(dw,val) ((dw) = ((dw) & 0xffff0000) | LOWORD(val))
387 #define SET_LOBYTE(dw,val) ((dw) = ((dw) & 0xffffff00) | LOBYTE(val))
388 #define SET_HIBYTE(dw,val) ((dw) = ((dw) & 0xffff00ff) | (LOWORD(val) & 0xff00))
389 #define ADD_LOWORD(dw,val) ((dw) = ((dw) & 0xffff0000) | LOWORD((DWORD)(dw)+(val)))
390 #endif
392 /* Macros to access unaligned or wrong-endian WORDs and DWORDs. */
393 /* Note: These macros are semantically broken, at least for wrc. wrc
394 spits out data in the platform's current binary format, *not* in
395 little-endian format. These macros are used throughout the resource
396 code to load and store data to the resources. Since it is unlikely
397 that we'll ever be dealing with little-endian resource data, the
398 byte-swapping nature of these macros has been disabled. Rather than
399 remove the use of these macros from the resource loading code, the
400 macros have simply been disabled. In the future, someone may want
401 to reactivate these macros for other purposes. In that case, the
402 resource code will have to be modified to use different macros. */
404 #if 1
405 #define PUT_WORD(ptr,w) (*(WORD *)(ptr) = (w))
406 #define GET_WORD(ptr) (*(WORD *)(ptr))
407 #define PUT_DWORD(ptr,dw) (*(DWORD *)(ptr) = (dw))
408 #define GET_DWORD(ptr) (*(DWORD *)(ptr))
409 #else
410 #define PUT_WORD(ptr,w) (*(BYTE *)(ptr) = LOBYTE(w), \
411 *((BYTE *)(ptr) + 1) = HIBYTE(w))
412 #define GET_WORD(ptr) ((WORD)(*(BYTE *)(ptr) | \
413 (WORD)(*((BYTE *)(ptr)+1) << 8)))
414 #define PUT_DWORD(ptr,dw) (PUT_WORD((ptr),LOWORD(dw)), \
415 PUT_WORD((WORD *)(ptr)+1,HIWORD(dw)))
416 #define GET_DWORD(ptr) ((DWORD)(GET_WORD(ptr) | \
417 ((DWORD)GET_WORD((WORD *)(ptr)+1) << 16)))
418 #endif /* 1 */
420 /* MIN and MAX macros */
422 #ifdef MAX
423 #undef MAX
424 #endif
425 #define MAX(a,b) (((a) > (b)) ? (a) : (b))
427 #ifdef MIN
428 #undef MIN
429 #endif
430 #define MIN(a,b) (((a) < (b)) ? (a) : (b))
432 #define __max(a,b) MAX(a,b)
433 #define __min(a,b) MIN(a,b)
434 #ifndef max
435 #define max(a,b) MAX(a,b)
436 #endif
437 #ifndef min
438 #define min(a,b) MIN(a,b)
439 #endif
441 #define _MAX_PATH 260
442 #define MAX_PATH 260
443 #define _MAX_DRIVE 3
444 #define _MAX_DIR 256
445 #define _MAX_FNAME 255
446 #define _MAX_EXT 256
448 #define HFILE_ERROR16 ((HFILE16)-1)
449 #define HFILE_ERROR ((HFILE)-1)
451 /* The SIZE structure */
452 typedef struct tagSIZE
454 INT cx;
455 INT cy;
456 } SIZE, *PSIZE, *LPSIZE;
459 typedef SIZE SIZEL, *PSIZEL, *LPSIZEL;
461 #define CONV_SIZE16TO32(s16,s32) \
462 ((s32)->cx = (INT)(s16)->cx, (s32)->cy = (INT)(s16)->cy)
463 #define CONV_SIZE32TO16(s32,s16) \
464 ((s16)->cx = (INT16)(s32)->cx, (s16)->cy = (INT16)(s32)->cy)
466 /* The POINT structure */
467 typedef struct tagPOINT
469 LONG x;
470 LONG y;
471 } POINT, *PPOINT, *LPPOINT;
473 typedef struct _POINTL
475 LONG x;
476 LONG y;
477 } POINTL;
479 #define CONV_POINT16TO32(p16,p32) \
480 ((p32)->x = (INT)(p16)->x, (p32)->y = (INT)(p16)->y)
481 #define CONV_POINT32TO16(p32,p16) \
482 ((p16)->x = (INT16)(p32)->x, (p16)->y = (INT16)(p32)->y)
484 #define MAKEPOINT16(l) (*((POINT16 *)&(l)))
486 /* The POINTS structure */
488 typedef struct tagPOINTS
490 SHORT x;
491 SHORT y;
492 } POINTS, *PPOINTS, *LPPOINTS;
495 #define MAKEPOINTS(l) (*((POINTS *)&(l)))
498 /* The RECT structure */
499 typedef struct tagRECT
501 INT left;
502 INT top;
503 INT right;
504 INT bottom;
505 } RECT, *PRECT, *LPRECT;
506 typedef const RECT *LPCRECT;
509 typedef struct tagRECTL
511 LONG left;
512 LONG top;
513 LONG right;
514 LONG bottom;
515 } RECTL, *PRECTL, *LPRECTL;
517 typedef const RECTL *LPCRECTL;
519 #define CONV_RECT16TO32(r16,r32) \
520 ((r32)->left = (INT)(r16)->left, (r32)->top = (INT)(r16)->top, \
521 (r32)->right = (INT)(r16)->right, (r32)->bottom = (INT)(r16)->bottom)
522 #define CONV_RECT32TO16(r32,r16) \
523 ((r16)->left = (INT16)(r32)->left, (r16)->top = (INT16)(r32)->top, \
524 (r16)->right = (INT16)(r32)->right, (r16)->bottom = (INT16)(r32)->bottom)
526 #ifdef __cplusplus
528 #endif
530 #endif /* __WINE_WINDEF_H */