source: trunk/include/win/windef.h@ 13

Last change on this file since 13 was 13, checked in by phaller, 26 years ago

Refined compiler definition support.

File size: 16.4 KB
Line 
1/* $Id: windef.h,v 1.2 1999-05-31 17:04:19 phaller Exp $ */
2
3/*
4 * Basic types definitions
5 *
6 * Copyright 1996 Alexandre Julliard
7 */
8
9#ifndef __WINE_WINDEF_H
10#define __WINE_WINDEF_H
11
12#ifdef __WINE__
13# include "config.h"
14# undef UNICODE
15#endif /* __WINE__ */
16
17#ifdef __cplusplus
18extern "C" {
19#endif
20
21/* Misc. constants. */
22
23#ifdef FALSE
24#undef FALSE
25#endif
26#define FALSE 0
27
28#ifdef TRUE
29#undef TRUE
30#endif
31#define TRUE 1
32
33#ifdef NULL
34#undef NULL
35#endif
36#define NULL 0
37
38/* Macros to map Winelib names to the correct implementation name */
39/* depending on __WINE__ and UNICODE macros. */
40/* Note that Winelib is purely Win32. */
41
42#ifdef __WINE__
43#ifdef __WIN32OS2__
44# define WINELIB_NAME_AW(func) this_is_a_syntax_error this_is_a_syntax_error
45#else
46# define WINELIB_NAME_AW(func) this_is_a_syntax_error this_is_a_syntax_error
47#endif
48#else /* __WINE__ */
49# ifdef UNICODE
50# define WINELIB_NAME_AW(func) func##W
51# else
52# define WINELIB_NAME_AW(func) func##A
53# endif /* UNICODE */
54#endif /* __WINE__ */
55
56#ifdef __WINE__
57# define DECL_WINELIB_TYPE_AW(type) /* nothing */
58#else /* __WINE__ */
59# define DECL_WINELIB_TYPE_AW(type) typedef WINELIB_NAME_AW(type) type;
60#endif /* __WINE__ */
61
62
63/* Calling conventions definitions */
64
65#ifdef __i386__
66# if defined(__GNUC__) && (__GNUC__ == 2) && (__GNUC_MINOR__ >= 7)
67# define __stdcall __attribute__((__stdcall__))
68# define __cdecl __attribute__((__cdecl__))
69# define __RESTORE_ES __asm__ __volatile__("pushl %ds\n\tpopl %es")
70# else
71# error You need gcc >= 2.7 to build Wine on a 386
72# endif /* __GNUC__ */
73#else /* __i386__ */
74#ifndef __WIN32OS2__
75# define __stdcall
76# define __cdecl
77# define __RESTORE_ES
78#endif
79#endif /* __i386__ */
80
81
82/* define needed macros as required */
83#ifndef CALLBACK
84 #define CALLBACK __stdcall
85#endif
86
87#ifndef WINAPI
88 #define WINAPI __stdcall
89#endif
90
91#ifndef APIPRIVATE
92 #define APIPRIVATE __stdcall
93#endif
94
95#ifndef PASCAL
96 #define PASCAL __stdcall
97#endif
98
99#ifndef pascal
100 #define pascal __stdcall
101#endif
102
103#ifndef _pascal
104 #define _pascal __stdcall
105#endif
106
107#ifndef _stdcall
108 #define _stdcall __stdcall
109#endif
110
111#ifndef _fastcall
112 #define _fastcall __stdcall
113#endif
114
115#ifndef __export
116 #define __export __stdcall
117#endif
118
119#ifndef CDECL
120 #define CDECL __cdecl
121#endif
122
123#ifndef _CDECL
124 #define _CDECL __cdecl
125#endif
126
127#ifndef cdecl
128 #define cdecl __cdecl
129#endif
130
131#ifndef _cdecl
132 #define _cdecl __cdecl
133#endif
134
135#ifndef WINAPIV
136 #define WINAPIV __cdecl
137#endif
138
139#ifndef APIENTRY
140 #define APIENTRY WINAPI
141#endif
142
143#ifndef __declspec
144 #define __declspec(x)
145#endif
146
147#ifndef dllimport
148 #define dllimport
149#endif
150
151#ifndef dllexport
152 #define dllexport
153#endif
154
155#ifndef CONST
156 #define CONST const
157#endif
158
159
160
161/* Standard data types. These are the same for emulator and library. */
162
163typedef void VOID;
164typedef short INT16;
165typedef unsigned short UINT16;
166typedef int INT;
167typedef unsigned int UINT;
168typedef unsigned short WORD;
169typedef unsigned long DWORD;
170typedef unsigned long ULONG;
171typedef unsigned char BYTE;
172typedef long LONG;
173typedef short SHORT;
174typedef unsigned short USHORT;
175typedef char CHAR;
176typedef unsigned char UCHAR;
177/* Some systems might have wchar_t, but we really need 16 bit characters */
178typedef unsigned short WCHAR;
179typedef unsigned short BOOL16;
180typedef int BOOL;
181typedef double DATE;
182typedef long LONG_PTR;
183typedef unsigned long ULONG_PTR;
184typedef double DOUBLE;
185typedef double LONGLONG;
186typedef double ULONGLONG;
187
188/* FIXME: Wine does not compile with strict on, therefore strict
189 * handles are presently only usable on machines where sizeof(UINT) ==
190 * sizeof(void*). HANDLEs are supposed to be void* but a large amount
191 * of WINE code operates on HANDLES as if they are UINTs. So to WINE
192 * they exist as UINTs but to the Winelib user who turns on strict,
193 * they exist as void*. If there is a size difference between UINT and
194 * void* then things get ugly. */
195#ifdef STRICT
196typedef UINT16 HANDLE16;
197typedef VOID* HANDLE;
198#else
199typedef UINT16 HANDLE16;
200typedef ULONG HANDLE;
201#endif
202
203typedef HANDLE16 *LPHANDLE16;
204typedef HANDLE *LPHANDLE;
205
206/* Integer types. These are the same for emulator and library. */
207typedef UINT16 WPARAM16;
208typedef UINT WPARAM;
209typedef LONG LPARAM;
210typedef LONG HRESULT;
211typedef LONG LRESULT;
212typedef WORD ATOM;
213typedef WORD CATCHBUF[9];
214typedef WORD *LPCATCHBUF;
215typedef DWORD ACCESS_MASK;
216typedef ACCESS_MASK REGSAM;
217typedef HANDLE HHOOK;
218typedef HANDLE HKEY;
219typedef HANDLE HMONITOR;
220typedef DWORD LCID;
221typedef WORD LANGID;
222typedef DWORD LCTYPE;
223typedef float FLOAT;
224#ifdef __WIN32OS2__
225typedef double __int64;
226#else
227typedef long long __int64;
228#endif
229
230/* Pointers types. These are the same for emulator and library. */
231/* winnt types */
232typedef VOID *PVOID;
233typedef const void *PCVOID;
234typedef CHAR *PCHAR;
235typedef UCHAR *PUCHAR;
236typedef BYTE *PBYTE;
237typedef ULONG *PULONG;
238typedef LONG *PLONG;
239typedef DWORD *PDWORD;
240/* common win32 types */
241typedef CHAR *LPSTR;
242typedef CHAR *LPTSTR;
243typedef CHAR *PSTR;
244typedef const CHAR *LPCSTR;
245typedef const CHAR *LPCTSTR;
246typedef const CHAR *PCSTR;
247typedef WCHAR *LPWSTR;
248typedef WCHAR *PWSTR;
249typedef const WCHAR *LPCWSTR;
250typedef const WCHAR *PCWSTR;
251typedef BYTE *LPBYTE;
252typedef WORD *LPWORD;
253typedef DWORD *LPDWORD;
254typedef LONG *LPLONG;
255typedef VOID *LPVOID;
256typedef const VOID *LPCVOID;
257typedef INT16 *LPINT16;
258typedef UINT16 *LPUINT16;
259typedef INT *PINT;
260typedef INT *LPINT;
261typedef UINT *PUINT;
262typedef UINT *LPUINT;
263typedef HKEY *LPHKEY;
264typedef HKEY *PHKEY;
265typedef FLOAT *PFLOAT;
266typedef FLOAT *LPFLOAT;
267typedef BOOL *PBOOL;
268typedef BOOL *LPBOOL;
269
270/* Special case: a segmented pointer is just a pointer in the user's code. */
271
272#ifdef __WINE__
273typedef DWORD SEGPTR;
274#else
275typedef void* SEGPTR;
276#endif /* __WINE__ */
277
278/* Handle types that exist both in Win16 and Win32. */
279
280#ifdef STRICT
281#define DECLARE_HANDLE(a) \
282 typedef HANDLE16 a##16; \
283 typedef a##16 *P##a##16; \
284 typedef a##16 *NP##a##16; \
285 typedef a##16 *LP##a##16; \
286 typedef struct a##__ { int unused; } *a; \
287 typedef a *P##a; \
288 typedef a *LP##a
289#else /*STRICT*/
290#define DECLARE_HANDLE(a) \
291 typedef HANDLE16 a##16; \
292 typedef a##16 *P##a##16; \
293 typedef a##16 *NP##a##16; \
294 typedef a##16 *LP##a##16; \
295 typedef HANDLE a; \
296 typedef a *P##a; \
297 typedef a *LP##a
298#endif /*STRICT*/
299
300DECLARE_HANDLE(HACMDRIVERID);
301DECLARE_HANDLE(HACMDRIVER);
302DECLARE_HANDLE(HACMOBJ);
303DECLARE_HANDLE(HACMSTREAM);
304DECLARE_HANDLE(HMETAFILEPICT);
305
306DECLARE_HANDLE(HACCEL);
307DECLARE_HANDLE(HBITMAP);
308DECLARE_HANDLE(HBRUSH);
309DECLARE_HANDLE(HCOLORSPACE);
310DECLARE_HANDLE(HCURSOR);
311DECLARE_HANDLE(HDC);
312DECLARE_HANDLE(HDROP);
313DECLARE_HANDLE(HDRVR);
314DECLARE_HANDLE(HDWP);
315DECLARE_HANDLE(HENHMETAFILE);
316DECLARE_HANDLE(HFILE);
317DECLARE_HANDLE(HFONT);
318DECLARE_HANDLE(HICON);
319DECLARE_HANDLE(HINSTANCE);
320DECLARE_HANDLE(HMENU);
321DECLARE_HANDLE(HMETAFILE);
322DECLARE_HANDLE(HMIDI);
323DECLARE_HANDLE(HMIDIIN);
324DECLARE_HANDLE(HMIDIOUT);
325DECLARE_HANDLE(HMIDISTRM);
326DECLARE_HANDLE(HMIXER);
327DECLARE_HANDLE(HMIXEROBJ);
328DECLARE_HANDLE(HMMIO);
329DECLARE_HANDLE(HPALETTE);
330DECLARE_HANDLE(HPEN);
331DECLARE_HANDLE(HQUEUE);
332DECLARE_HANDLE(HRGN);
333DECLARE_HANDLE(HRSRC);
334DECLARE_HANDLE(HTASK);
335DECLARE_HANDLE(HWAVE);
336DECLARE_HANDLE(HWAVEIN);
337DECLARE_HANDLE(HWAVEOUT);
338DECLARE_HANDLE(HWINSTA);
339DECLARE_HANDLE(HDESK);
340DECLARE_HANDLE(HWND);
341DECLARE_HANDLE(HKL);
342DECLARE_HANDLE(HIC);
343DECLARE_HANDLE(HRASCONN);
344DECLARE_HANDLE(HPRINTER);
345#undef DECLARE_HANDLE
346
347/* Handle types that must remain interchangeable even with strict on */
348
349typedef HINSTANCE16 HMODULE16;
350typedef HINSTANCE HMODULE;
351typedef HANDLE16 HGDIOBJ16;
352typedef HANDLE16 HGLOBAL16;
353typedef HANDLE16 HLOCAL16;
354typedef HANDLE HGDIOBJ;
355typedef HANDLE HGLOBAL;
356typedef HANDLE HLOCAL;
357
358/* Callback function pointers types */
359
360typedef BOOL (* CALLBACK DATEFMT_ENUMPROCA)(LPSTR);
361typedef BOOL (* CALLBACK DATEFMT_ENUMPROCW)(LPWSTR);
362DECL_WINELIB_TYPE_AW(DATEFMT_ENUMPROC)
363typedef BOOL16 (* CALLBACK DLGPROC16)(HWND16,UINT16,WPARAM16,LPARAM);
364typedef BOOL (* CALLBACK DLGPROC)(HWND,UINT,WPARAM,LPARAM);
365typedef LRESULT (* CALLBACK DRIVERPROC16)(DWORD,HDRVR16,UINT16,LPARAM,LPARAM);
366typedef LRESULT (* CALLBACK DRIVERPROC)(DWORD,HDRVR,UINT,LPARAM,LPARAM);
367typedef INT16 (* CALLBACK EDITWORDBREAKPROC16)(LPSTR,INT16,INT16,INT16);
368typedef INT (* CALLBACK EDITWORDBREAKPROCA)(LPSTR,INT,INT,INT);
369typedef INT (* CALLBACK EDITWORDBREAKPROCW)(LPWSTR,INT,INT,INT);
370DECL_WINELIB_TYPE_AW(EDITWORDBREAKPROC)
371typedef LRESULT (* CALLBACK FARPROC16)();
372typedef LRESULT (* CALLBACK FARPROC)();
373typedef INT16 (* CALLBACK PROC16)();
374typedef INT (* CALLBACK PROC)();
375typedef INT16 (* CALLBACK GOBJENUMPROC16)(SEGPTR,LPARAM);
376typedef INT (* CALLBACK GOBJENUMPROC)(LPVOID,LPARAM);
377typedef BOOL16 (* CALLBACK GRAYSTRINGPROC16)(HDC16,LPARAM,INT16);
378typedef BOOL (* CALLBACK GRAYSTRINGPROC)(HDC,LPARAM,INT);
379typedef LRESULT (* CALLBACK HOOKPROC16)(INT16,WPARAM16,LPARAM);
380typedef LRESULT (* CALLBACK HOOKPROC)(INT,WPARAM,LPARAM);
381typedef VOID (* CALLBACK LINEDDAPROC16)(INT16,INT16,LPARAM);
382typedef VOID (* CALLBACK LINEDDAPROC)(INT,INT,LPARAM);
383typedef BOOL16 (* CALLBACK PROPENUMPROC16)(HWND16,SEGPTR,HANDLE16);
384typedef BOOL (* CALLBACK PROPENUMPROCA)(HWND,LPCSTR,HANDLE);
385typedef BOOL (* CALLBACK PROPENUMPROCW)(HWND,LPCWSTR,HANDLE);
386DECL_WINELIB_TYPE_AW(PROPENUMPROC)
387typedef BOOL (* CALLBACK PROPENUMPROCEXA)(HWND,LPCSTR,HANDLE,LPARAM);
388typedef BOOL (* CALLBACK PROPENUMPROCEXW)(HWND,LPCWSTR,HANDLE,LPARAM);
389DECL_WINELIB_TYPE_AW(PROPENUMPROCEX)
390typedef BOOL (* CALLBACK TIMEFMT_ENUMPROCA)(LPSTR);
391typedef BOOL (* CALLBACK TIMEFMT_ENUMPROCW)(LPWSTR);
392DECL_WINELIB_TYPE_AW(TIMEFMT_ENUMPROC)
393typedef VOID (* CALLBACK TIMERPROC16)(HWND16,UINT16,UINT16,DWORD);
394typedef VOID (* CALLBACK TIMERPROC)(HWND,UINT,UINT,DWORD);
395typedef LRESULT (* CALLBACK WNDENUMPROC16)(HWND16,LPARAM);
396typedef LRESULT (* CALLBACK WNDENUMPROC)(HWND,LPARAM);
397typedef LRESULT (* CALLBACK WNDPROC16)(HWND16,UINT16,WPARAM16,LPARAM);
398typedef LRESULT (* CALLBACK WNDPROC)(HWND,UINT,WPARAM,LPARAM);
399
400/* TCHAR data types definitions for Winelib. */
401/* These types are _not_ defined for the emulator, because they */
402/* depend on the UNICODE macro that only exists in user's code. */
403
404#ifndef __WINE__
405# ifdef UNICODE
406typedef WCHAR TCHAR;
407typedef LPWSTR LPTSTR;
408typedef LPCWSTR LPCTSTR;
409#define __TEXT(string) L##string /*probably wrong */
410# else /* UNICODE */
411typedef CHAR TCHAR;
412typedef LPSTR LPTSTR;
413typedef LPCSTR LPCTSTR;
414#define __TEXT(string) string
415# endif /* UNICODE */
416#endif /* __WINE__ */
417#define TEXT(quote) __TEXT(quote)
418
419/* Data types specific to the library. These do _not_ exist in the emulator. */
420
421
422
423/* Define some empty macros for compatibility with Windows code. */
424
425#ifndef __WINE__
426#define NEAR
427#define FAR
428#define near
429#define far
430#define _near
431#define _far
432#define IN
433#define OUT
434#define OPTIONAL
435#endif /* __WINE__ */
436
437/* Macro for structure packing. */
438
439#ifdef __GNUC__
440#define WINE_PACKED __attribute__ ((packed))
441#define WINE_UNUSED __attribute__ ((unused))
442#else
443#define WINE_PACKED /* nothing */
444#define WINE_UNUSED /* nothing */
445#endif
446
447/* Macros to split words and longs. */
448
449#define LOBYTE(w) ((BYTE)(WORD)(w))
450#define HIBYTE(w) ((BYTE)((WORD)(w) >> 8))
451
452#define LOWORD(l) ((WORD)(DWORD)(l))
453#define HIWORD(l) ((WORD)((DWORD)(l) >> 16))
454
455#define SLOWORD(l) ((INT16)(LONG)(l))
456#define SHIWORD(l) ((INT16)((LONG)(l) >> 16))
457
458#define MAKEWORD(low,high) ((WORD)(((BYTE)(low)) | ((WORD)((BYTE)(high))) << 8))
459#define MAKELONG(low,high) ((LONG)(((WORD)(low)) | (((DWORD)((WORD)(high))) << 16)))
460#define MAKELPARAM(low,high) ((LPARAM)MAKELONG(low,high))
461#define MAKEWPARAM(low,high) ((WPARAM)MAKELONG(low,high))
462#define MAKELRESULT(low,high) ((LRESULT)MAKELONG(low,high))
463#define MAKEINTATOM(atom) ((LPCSTR)MAKELONG((atom),0))
464
465#define SELECTOROF(ptr) (HIWORD(ptr))
466#define OFFSETOF(ptr) (LOWORD(ptr))
467
468/* Macros to access unaligned or wrong-endian WORDs and DWORDs. */
469/* Note: These macros are semantically broken, at least for wrc. wrc
470 spits out data in the platform's current binary format, *not* in
471 little-endian format. These macros are used throughout the resource
472 code to load and store data to the resources. Since it is unlikely
473 that we'll ever be dealing with little-endian resource data, the
474 byte-swapping nature of these macros has been disabled. Rather than
475 remove the use of these macros from the resource loading code, the
476 macros have simply been disabled. In the future, someone may want
477 to reactivate these macros for other purposes. In that case, the
478 resource code will have to be modified to use different macros. */
479
480#if 1
481#define PUT_WORD(ptr,w) (*(WORD *)(ptr) = (w))
482#define GET_WORD(ptr) (*(WORD *)(ptr))
483#define PUT_DWORD(ptr,dw) (*(DWORD *)(ptr) = (dw))
484#define GET_DWORD(ptr) (*(DWORD *)(ptr))
485#else
486#define PUT_WORD(ptr,w) (*(BYTE *)(ptr) = LOBYTE(w), \
487 *((BYTE *)(ptr) + 1) = HIBYTE(w))
488#define GET_WORD(ptr) ((WORD)(*(BYTE *)(ptr) | \
489 (WORD)(*((BYTE *)(ptr)+1) << 8)))
490#define PUT_DWORD(ptr,dw) (PUT_WORD((ptr),LOWORD(dw)), \
491 PUT_WORD((WORD *)(ptr)+1,HIWORD(dw)))
492#define GET_DWORD(ptr) ((DWORD)(GET_WORD(ptr) | \
493 ((DWORD)GET_WORD((WORD *)(ptr)+1) << 16)))
494#endif /* 1 */
495
496/* MIN and MAX macros */
497
498#ifdef MAX
499#undef MAX
500#endif
501#define MAX(a,b) (((a) > (b)) ? (a) : (b))
502
503#ifdef MIN
504#undef MIN
505#endif
506#define MIN(a,b) (((a) < (b)) ? (a) : (b))
507
508#define __max(a,b) MAX(a,b)
509#define __min(a,b) MIN(a,b)
510#ifndef max
511#define max(a,b) MAX(a,b)
512#endif
513
514#ifndef min
515#define min(a,b) MIN(a,b)
516#endif
517
518#define _MAX_PATH 260
519#define MAX_PATH 260
520#define _MAX_DRIVE 3
521#define _MAX_DIR 256
522#ifndef __WIN32OS2__
523#define _MAX_FNAME 255
524#endif
525#define _MAX_EXT 256
526
527#define HFILE_ERROR16 ((HFILE16)-1)
528#define HFILE_ERROR ((HFILE)-1)
529
530/* Winelib run-time flag */
531
532#ifdef __WINE__
533extern int __winelib;
534#endif /* __WINE__ */
535
536/* The SIZE structure */
537
538typedef struct
539{
540 INT16 cx;
541 INT16 cy;
542} SIZE16, *PSIZE16, *LPSIZE16;
543
544typedef struct tagSIZE
545{
546 INT cx;
547 INT cy;
548} SIZE, *PSIZE, *LPSIZE;
549
550
551typedef SIZE SIZEL, *PSIZEL, *LPSIZEL;
552
553#define CONV_SIZE16TO32(s16,s32) \
554 ((s32)->cx = (INT)(s16)->cx, (s32)->cy = (INT)(s16)->cy)
555#define CONV_SIZE32TO16(s32,s16) \
556 ((s16)->cx = (INT16)(s32)->cx, (s16)->cy = (INT16)(s32)->cy)
557
558/* The POINT structure */
559
560typedef struct
561{
562 INT16 x;
563 INT16 y;
564} POINT16, *PPOINT16, *LPPOINT16;
565
566typedef struct tagPOINT
567{
568 LONG x;
569 LONG y;
570} POINT, *PPOINT, *LPPOINT;
571
572typedef struct _POINTL
573{
574 LONG x;
575 LONG y;
576} POINTL;
577
578#define CONV_POINT16TO32(p16,p32) \
579 ((p32)->x = (INT)(p16)->x, (p32)->y = (INT)(p16)->y)
580#define CONV_POINT32TO16(p32,p16) \
581 ((p16)->x = (INT16)(p32)->x, (p16)->y = (INT16)(p32)->y)
582
583#define MAKEPOINT16(l) (*((POINT16 *)&(l)))
584
585/* The POINTS structure */
586
587typedef struct tagPOINTS
588{
589 SHORT x;
590 SHORT y;
591} POINTS, *PPOINTS, *LPPOINTS;
592
593
594#define MAKEPOINTS(l) (*((POINTS *)&(l)))
595
596
597/* The RECT structure */
598
599typedef struct
600{
601 INT16 left;
602 INT16 top;
603 INT16 right;
604 INT16 bottom;
605} RECT16, *LPRECT16;
606
607typedef struct tagRECT
608{
609 INT left;
610 INT top;
611 INT right;
612 INT bottom;
613} RECT, *PRECT, *LPRECT;
614typedef const RECT *LPCRECT;
615
616
617typedef struct tagRECTL
618{
619 LONG left;
620 LONG top;
621 LONG right;
622 LONG bottom;
623} RECTL, *PRECTL, *LPRECTL;
624
625typedef const RECTL *LPCRECTL;
626
627#define CONV_RECT16TO32(r16,r32) \
628 ((r32)->left = (INT)(r16)->left, (r32)->top = (INT)(r16)->top, \
629 (r32)->right = (INT)(r16)->right, (r32)->bottom = (INT)(r16)->bottom)
630#define CONV_RECT32TO16(r32,r16) \
631 ((r16)->left = (INT16)(r32)->left, (r16)->top = (INT16)(r32)->top, \
632 (r16)->right = (INT16)(r32)->right, (r16)->bottom = (INT16)(r32)->bottom)
633
634#ifdef __cplusplus
635}
636#endif
637
638#endif /* __WINE_WINDEF_H */
Note: See TracBrowser for help on using the repository browser.