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