Changed INSTR_EmulateInstruction to use a CONTEXT86 instead of a
[wine] / include / windef.h
1 /*
2  * Basic types definitions
3  *
4  * Copyright 1996 Alexandre Julliard
5  */
6
7 #ifndef __WINE_WINDEF_H
8 #define __WINE_WINDEF_H
9
10 #ifdef __WINE__
11 # include "config.h"
12 # undef UNICODE
13 #endif  /* __WINE__ */
14
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18
19 /* Misc. constants. */
20
21 #ifdef FALSE
22 #undef FALSE
23 #endif
24 #define FALSE 0
25
26 #ifdef TRUE
27 #undef TRUE
28 #endif
29 #define TRUE  1
30
31 #ifdef NULL
32 #undef NULL
33 #endif
34 #define NULL  0
35
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.                             */
39
40 #ifdef __WINE__
41 # define WINELIB_NAME_AW(func)   this_is_a_syntax_error this_is_a_syntax_error
42 #else  /* __WINE__ */
43 # ifdef UNICODE
44 #  define WINELIB_NAME_AW(func) func##W
45 # else
46 #  define WINELIB_NAME_AW(func) func##A
47 # endif  /* UNICODE */
48 #endif  /* __WINE__ */
49
50 #ifdef __WINE__
51 # define DECL_WINELIB_TYPE_AW(type)  /* nothing */
52 #else   /* __WINE__ */
53 # define DECL_WINELIB_TYPE_AW(type)  typedef WINELIB_NAME_AW(type) type;
54 #endif  /* __WINE__ */
55
56
57 /* Calling conventions definitions */
58
59 #ifdef __i386__
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")
64 # else
65 #  error You need gcc >= 2.7 to build Wine on a 386
66 # endif  /* __GNUC__ */
67 #else  /* __i386__ */
68 # define __stdcall
69 # define __cdecl
70 # define __RESTORE_ES
71 #endif  /* __i386__ */
72
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
82 #define CDECL       __cdecl
83 #define _CDECL      __cdecl
84 #define cdecl       __cdecl
85 #define _cdecl      __cdecl
86 #define WINAPIV     __cdecl
87 #define APIENTRY    WINAPI
88
89 #define __declspec(x)
90 #define dllimport
91 #define dllexport
92
93 #define CONST       const
94
95 /* Standard data types. These are the same for emulator and library. */
96
97 typedef void            VOID;
98 typedef short           INT16;
99 typedef unsigned short  UINT16;
100 typedef int             INT;
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;
106 typedef long            LONG;
107 typedef short           SHORT;
108 typedef unsigned short  USHORT;
109 typedef char            CHAR;
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;
114 typedef int             BOOL;
115 typedef double          DATE;
116 typedef double          DOUBLE;
117 typedef double          LONGLONG;
118 typedef double          ULONGLONG;
119
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.  */
127 #ifdef STRICT
128 typedef UINT16          HANDLE16;
129 typedef VOID*           HANDLE;
130 #else
131 typedef UINT16          HANDLE16;
132 typedef UINT            HANDLE;
133 #endif
134
135 typedef HANDLE16       *LPHANDLE16;
136 typedef HANDLE         *LPHANDLE;
137
138 /* Integer types. These are the same for emulator and library. */
139 typedef UINT16          WPARAM16;
140 typedef UINT            WPARAM;
141 typedef LONG            LPARAM;
142 typedef LONG            HRESULT;
143 typedef LONG            LRESULT;
144 typedef WORD            ATOM;
145 typedef WORD            CATCHBUF[9];
146 typedef WORD           *LPCATCHBUF;
147 typedef HANDLE          HHOOK;
148 typedef HANDLE          HMONITOR;
149 typedef DWORD           LCID;
150 typedef WORD            LANGID;
151 typedef DWORD           LCTYPE;
152 typedef float           FLOAT;
153
154 /* Pointers types. These are the same for emulator and library. */
155 /* winnt types */
156 typedef VOID           *PVOID;
157 typedef const void     *PCVOID;
158 typedef CHAR           *PCHAR;
159 typedef UCHAR          *PUCHAR;
160 typedef BYTE           *PBYTE;
161 typedef ULONG          *PULONG;
162 typedef LONG           *PLONG;
163 typedef DWORD          *PDWORD;
164 /* common win32 types */
165 typedef CHAR           *LPSTR;
166 typedef CHAR           *PSTR;
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;
181 typedef INT            *PINT;
182 typedef INT            *LPINT;
183 typedef UINT           *PUINT;
184 typedef UINT           *LPUINT;
185 typedef FLOAT          *PFLOAT;
186 typedef FLOAT          *LPFLOAT;
187 typedef BOOL           *PBOOL;
188 typedef BOOL           *LPBOOL;
189
190 /* Special case: a segmented pointer is just a pointer in the user's code. */
191
192 #ifdef __WINE__
193 typedef DWORD SEGPTR;
194 #else
195 typedef void* SEGPTR;
196 #endif /* __WINE__ */
197
198 /* Handle types that exist both in Win16 and Win32. */
199
200 #ifdef STRICT
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; \
207         typedef a *P##a; \
208         typedef a *LP##a
209 #else /*STRICT*/
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; \
215         typedef HANDLE a; \
216         typedef a *P##a; \
217         typedef a *LP##a
218 #endif /*STRICT*/
219
220 DECLARE_HANDLE(HACMDRIVERID);
221 DECLARE_HANDLE(HACMDRIVER);
222 DECLARE_HANDLE(HACMOBJ);
223 DECLARE_HANDLE(HACMSTREAM);
224 DECLARE_HANDLE(HMETAFILEPICT);
225
226 DECLARE_HANDLE(HACCEL);
227 DECLARE_HANDLE(HBITMAP);
228 DECLARE_HANDLE(HBRUSH);
229 DECLARE_HANDLE(HCOLORSPACE);
230 DECLARE_HANDLE(HCURSOR);
231 DECLARE_HANDLE(HDC);
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);
262 DECLARE_HANDLE(HKL);
263 DECLARE_HANDLE(HIC);
264 DECLARE_HANDLE(HRASCONN);
265 #undef DECLARE_HANDLE
266
267 /* Handle types that must remain interchangeable even with strict on */
268
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;
277
278 /* Callback function pointers types */
279
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);
315
316 /* Define some empty macros for compatibility with Windows code. */
317
318 #ifndef __WINE__
319 #define NEAR
320 #define FAR
321 #define near
322 #define far
323 #define _near
324 #define _far
325 #define IN
326 #define OUT
327 #define OPTIONAL
328 #endif  /* __WINE__ */
329
330 /* Macro for structure packing. */
331
332 #ifdef __GNUC__
333 #define WINE_PACKED __attribute__ ((packed))
334 #define WINE_UNUSED __attribute__ ((unused))
335 #else
336 #define WINE_PACKED  /* nothing */
337 #define WINE_UNUSED  /* nothing */
338 #endif
339
340 /* Macros to split words and longs. */
341
342 #define LOBYTE(w)              ((BYTE)(WORD)(w))
343 #define HIBYTE(w)              ((BYTE)((WORD)(w) >> 8))
344
345 #define LOWORD(l)              ((WORD)(DWORD)(l))
346 #define HIWORD(l)              ((WORD)((DWORD)(l) >> 16))
347
348 #define SLOWORD(l)             ((INT16)(LONG)(l))
349 #define SHIWORD(l)             ((INT16)((LONG)(l) >> 16))
350
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))
357
358 #define SELECTOROF(ptr)     (HIWORD(ptr))
359 #define OFFSETOF(ptr)       (LOWORD(ptr))
360
361 #ifdef __WINE__
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)))
367 #endif
368
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. */ 
380
381 #if 1
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))
386 #else
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)))
395 #endif  /* 1 */
396
397 /* MIN and MAX macros */
398
399 #ifdef MAX
400 #undef MAX
401 #endif
402 #define MAX(a,b) (((a) > (b)) ? (a) : (b))
403
404 #ifdef MIN
405 #undef MIN
406 #endif
407 #define MIN(a,b) (((a) < (b)) ? (a) : (b))
408
409 #define __max(a,b) MAX(a,b)
410 #define __min(a,b) MIN(a,b)
411 #ifndef max
412 #define max(a,b)   MAX(a,b)
413 #endif
414 #ifndef min
415 #define min(a,b)   MIN(a,b)
416 #endif
417
418 #define _MAX_PATH  260
419 #define MAX_PATH   260
420 #define _MAX_DRIVE 3
421 #define _MAX_DIR   256
422 #define _MAX_FNAME 255
423 #define _MAX_EXT   256
424
425 #define HFILE_ERROR16   ((HFILE16)-1)
426 #define HFILE_ERROR     ((HFILE)-1)
427
428 /* Winelib run-time flag */
429
430 #ifdef __WINE__
431 extern int __winelib;
432 #endif  /* __WINE__ */
433
434 /* The SIZE structure */
435
436 typedef struct
437 {
438     INT16  cx;
439     INT16  cy;
440 } SIZE16, *PSIZE16, *LPSIZE16;
441
442 typedef struct tagSIZE
443 {
444     INT  cx;
445     INT  cy;
446 } SIZE, *PSIZE, *LPSIZE;
447
448
449 typedef SIZE SIZEL, *PSIZEL, *LPSIZEL;
450
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)
455
456 /* The POINT structure */
457
458 typedef struct
459 {
460     INT16  x;
461     INT16  y;
462 } POINT16, *PPOINT16, *LPPOINT16;
463
464 typedef struct tagPOINT
465 {
466     LONG  x;
467     LONG  y;
468 } POINT, *PPOINT, *LPPOINT;
469
470 typedef struct _POINTL
471 {
472     LONG x;
473     LONG y;
474 } POINTL;
475
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)
480
481 #define MAKEPOINT16(l) (*((POINT16 *)&(l)))
482
483 /* The POINTS structure */
484
485 typedef struct tagPOINTS
486 {
487         SHORT x;
488         SHORT y;
489 } POINTS, *PPOINTS, *LPPOINTS;
490
491
492 #define MAKEPOINTS(l)  (*((POINTS *)&(l)))
493
494
495 /* The RECT structure */
496
497 typedef struct
498 {
499     INT16  left;
500     INT16  top;
501     INT16  right;
502     INT16  bottom;
503 } RECT16, *LPRECT16;
504
505 typedef struct tagRECT
506 {
507     INT  left;
508     INT  top;
509     INT  right;
510     INT  bottom;
511 } RECT, *PRECT, *LPRECT;
512 typedef const RECT *LPCRECT;
513
514
515 typedef struct tagRECTL
516 {
517     LONG left;
518     LONG top;  
519     LONG right;
520     LONG bottom;
521 } RECTL, *PRECTL, *LPRECTL;
522
523 typedef const RECTL *LPCRECTL;
524
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)
531
532 #ifdef __cplusplus
533 }
534 #endif
535
536 #endif /* __WINE_WINDEF_H */