Release 970914
[wine.git] / include / wintypes.h
blobf420b394dae04afbd4629817de6bccd3a14a853f
1 /*
2 * Basic types definitions
4 * Copyright 1996 Alexandre Julliard
5 */
7 #ifndef __WINE_WINTYPES_H
8 #define __WINE_WINTYPES_H
10 #ifdef __WINE__
11 #include "config.h"
12 #endif
14 #if !defined(__WINE__) && !defined(WINELIB)
15 /* If we are not compiling Wine, then we should be using Winelib */
16 #error You must use 'configure --with-library' to build Winelib programs
17 #define WINELIB
18 #endif
20 #ifdef WINELIB
21 # ifdef WINELIB16
22 # undef WINELIB32
23 # else
24 # ifndef WINELIB32
25 # define WINELIB32
26 # endif
27 # endif
28 #else
29 # ifdef WINELIB32
30 # undef WINELIB16
31 # define WINELIB
32 # endif
33 # ifdef WINELIB16
34 # define WINELIB
35 # endif
36 #endif
38 /* Macros to map Winelib names to the correct implementation name */
39 /* depending on WINELIB16, WINELIB32 and UNICODE macros. */
41 #ifdef __WINE__
42 # define WINELIB_NAME(func) this is a syntax error
43 # define WINELIB_NAME_AW(func) this is a syntax error
44 #else /* __WINE__ */
45 # ifdef WINELIB32
46 # define WINELIB_NAME(func) func##32
47 # ifdef UNICODE
48 # define WINELIB_NAME_AW(func) func##32W
49 # else
50 # define WINELIB_NAME_AW(func) func##32A
51 # endif /* UNICODE */
52 # else /* WINELIB32 */
53 # define WINELIB_NAME(func) func##16
54 # define WINELIB_NAME_AW(func) func##16
55 # endif /* WINELIB32 */
56 #endif /* __WINE__ */
58 #ifdef __WINE__
59 # define DECL_WINELIB_TYPE(type) /* nothing */
60 # define DECL_WINELIB_TYPE_AW(type) /* nothing */
61 #else /* __WINE__ */
62 # define DECL_WINELIB_TYPE(type) typedef WINELIB_NAME(type) type
63 # define DECL_WINELIB_TYPE_AW(type) typedef WINELIB_NAME_AW(type) type
64 #endif /* __WINE__ */
67 /* Calling conventions definitions */
69 #ifdef __i386__
70 # if defined(__GNUC__) && (__GNUC__ == 2) && (__GNUC_MINOR__ >= 7)
71 # define __stdcall __attribute__((__stdcall__))
72 # define __cdecl __attribute__((__cdecl__))
73 # define __RESTORE_ES __asm__ __volatile__("pushw %ds\n\tpopw %es")
74 # else
75 # error You need gcc >= 2.7 to build Wine on a 386
76 # endif /* __GNUC__ */
77 #else /* __i386__ */
78 # define __stdcall
79 # define __cdecl
80 # define __RESTORE_ES
81 #endif /* __i386__ */
83 #define CALLBACK __stdcall
84 #define WINAPI __stdcall
85 #define APIPRIVATE __stdcall
86 #define PASCAL __stdcall
87 #define _pascal __stdcall
88 #define __export __stdcall
89 #define WINAPIV __cdecl
90 #define APIENTRY WINAPI
93 /* Standard data types. These are the same for emulator and library. */
95 typedef void VOID;
96 typedef short INT16;
97 typedef unsigned short UINT16;
98 typedef int INT32;
99 typedef unsigned int UINT32;
100 typedef unsigned short WORD;
101 typedef unsigned long DWORD;
102 typedef unsigned char BYTE;
103 typedef long LONG;
104 typedef char CHAR;
105 /* Some systems might have wchar_t, but we really need 16 bit characters */
106 typedef unsigned short WCHAR;
107 typedef unsigned short BOOL16;
108 typedef int BOOL32;
110 /* Integer types. These are the same for emulator and library. */
112 typedef UINT16 HANDLE16;
113 typedef UINT32 HANDLE32;
114 typedef UINT16 WPARAM16;
115 typedef UINT32 WPARAM32;
116 typedef LONG LPARAM;
117 typedef LONG LRESULT;
118 typedef WORD ATOM;
119 typedef WORD CATCHBUF[9];
120 typedef WORD *LPCATCHBUF;
121 typedef DWORD ACCESS_MASK;
122 typedef ACCESS_MASK REGSAM;
123 typedef HANDLE32 HHOOK;
124 typedef HANDLE32 HKEY;
125 typedef HANDLE32 HMIXEROBJ;
126 typedef DWORD LCID;
127 typedef WORD LANGID;
128 typedef DWORD LCTYPE;
130 /* Pointers types. These are the same for emulator and library. */
132 typedef CHAR *LPSTR;
133 typedef const CHAR *LPCSTR;
134 typedef WCHAR *LPWSTR;
135 typedef const WCHAR *LPCWSTR;
136 typedef BYTE *LPBYTE;
137 typedef WORD *LPWORD;
138 typedef DWORD *LPDWORD;
139 typedef LONG *LPLONG;
140 typedef VOID *LPVOID;
141 typedef const VOID *LPCVOID;
142 typedef INT16 *LPINT16;
143 typedef UINT16 *LPUINT16;
144 typedef INT32 *LPINT32;
145 typedef UINT32 *LPUINT32;
146 typedef HKEY *LPHKEY;
147 typedef HMIXEROBJ *LPHMIXEROBJ;
149 /* Special case: a segmented pointer is just a pointer in the user's code. */
151 #ifdef __WINE__
152 typedef DWORD SEGPTR;
153 #else
154 typedef void* SEGPTR;
155 #endif /* __WINE__ */
157 /* Handle types that exist both in Win16 and Win32. */
159 #define DECLARE_HANDLE(a) typedef HANDLE16 a##16; typedef HANDLE32 a##32;
160 DECLARE_HANDLE(HACCEL);
161 DECLARE_HANDLE(HBITMAP);
162 DECLARE_HANDLE(HBRUSH);
163 DECLARE_HANDLE(HCURSOR);
164 DECLARE_HANDLE(HDC);
165 DECLARE_HANDLE(HDROP);
166 DECLARE_HANDLE(HDRVR);
167 DECLARE_HANDLE(HDWP);
168 DECLARE_HANDLE(HFILE);
169 DECLARE_HANDLE(HFONT);
170 DECLARE_HANDLE(HGDIOBJ);
171 DECLARE_HANDLE(HGLOBAL);
172 DECLARE_HANDLE(HICON);
173 DECLARE_HANDLE(HINSTANCE);
174 DECLARE_HANDLE(HLOCAL);
175 DECLARE_HANDLE(HMENU);
176 DECLARE_HANDLE(HMETAFILE);
177 DECLARE_HANDLE(HMIDI);
178 DECLARE_HANDLE(HMIDIIN);
179 DECLARE_HANDLE(HMIDIOUT);
180 DECLARE_HANDLE(HMMIO);
181 DECLARE_HANDLE(HMODULE);
182 DECLARE_HANDLE(HPALETTE);
183 DECLARE_HANDLE(HPEN);
184 DECLARE_HANDLE(HQUEUE);
185 DECLARE_HANDLE(HRGN);
186 DECLARE_HANDLE(HRSRC);
187 DECLARE_HANDLE(HTASK);
188 DECLARE_HANDLE(HWAVE);
189 DECLARE_HANDLE(HWAVEIN);
190 DECLARE_HANDLE(HWAVEOUT);
191 DECLARE_HANDLE(HWND);
192 DECLARE_HANDLE(HKL);
193 #undef DECLARE_HANDLE
195 /* Callback function pointers types */
197 typedef LRESULT (CALLBACK *DLGPROC16)(HWND16,UINT16,WPARAM16,LPARAM);
198 typedef LRESULT (CALLBACK *DLGPROC32)(HWND32,UINT32,WPARAM32,LPARAM);
199 DECL_WINELIB_TYPE(DLGPROC);
200 typedef LRESULT (CALLBACK *DRIVERPROC16)(DWORD,HDRVR16,UINT16,LPARAM,LPARAM);
201 typedef LRESULT (CALLBACK *DRIVERPROC32)(DWORD,HDRVR32,UINT32,LPARAM,LPARAM);
202 DECL_WINELIB_TYPE(DRIVERPROC);
203 typedef INT16 (CALLBACK *EDITWORDBREAKPROC16)(LPSTR,INT16,INT16,INT16);
204 typedef INT32 (CALLBACK *EDITWORDBREAKPROC32A)(LPSTR,INT32,INT32,INT32);
205 typedef INT32 (CALLBACK *EDITWORDBREAKPROC32W)(LPWSTR,INT32,INT32,INT32);
206 DECL_WINELIB_TYPE_AW(EDITWORDBREAKPROC);
207 typedef LRESULT (CALLBACK *FARPROC16)();
208 typedef LRESULT (CALLBACK *FARPROC32)();
209 DECL_WINELIB_TYPE(FARPROC);
210 typedef INT16 (CALLBACK *GOBJENUMPROC16)(SEGPTR,LPARAM);
211 typedef INT32 (CALLBACK *GOBJENUMPROC32)(LPVOID,LPARAM);
212 DECL_WINELIB_TYPE(GOBJENUMPROC);
213 typedef BOOL16 (CALLBACK *GRAYSTRINGPROC16)(HDC16,LPARAM,INT16);
214 typedef BOOL32 (CALLBACK *GRAYSTRINGPROC32)(HDC32,LPARAM,INT32);
215 DECL_WINELIB_TYPE(GRAYSTRINGPROC);
216 typedef LRESULT (CALLBACK *HOOKPROC16)(INT16,WPARAM16,LPARAM);
217 typedef LRESULT (CALLBACK *HOOKPROC32)(INT32,WPARAM32,LPARAM);
218 DECL_WINELIB_TYPE(HOOKPROC);
219 typedef VOID (CALLBACK *LINEDDAPROC16)(INT16,INT16,LPARAM);
220 typedef VOID (CALLBACK *LINEDDAPROC32)(INT32,INT32,LPARAM);
221 DECL_WINELIB_TYPE(LINEDDAPROC);
222 typedef BOOL16 (CALLBACK *PROPENUMPROC16)(HWND16,SEGPTR,HANDLE16);
223 typedef BOOL32 (CALLBACK *PROPENUMPROC32A)(HWND32,LPCSTR,HANDLE32);
224 typedef BOOL32 (CALLBACK *PROPENUMPROC32W)(HWND32,LPCWSTR,HANDLE32);
225 DECL_WINELIB_TYPE_AW(PROPENUMPROC);
226 typedef BOOL32 (CALLBACK *PROPENUMPROCEX32A)(HWND32,LPCSTR,HANDLE32,LPARAM);
227 typedef BOOL32 (CALLBACK *PROPENUMPROCEX32W)(HWND32,LPCWSTR,HANDLE32,LPARAM);
228 DECL_WINELIB_TYPE_AW(PROPENUMPROCEX);
229 typedef VOID (CALLBACK *TIMERPROC16)(HWND16,UINT16,UINT16,DWORD);
230 typedef VOID (CALLBACK *TIMERPROC32)(HWND32,UINT32,UINT32,DWORD);
231 DECL_WINELIB_TYPE(TIMERPROC);
232 typedef LRESULT (CALLBACK *WNDENUMPROC16)(HWND16,LPARAM);
233 typedef LRESULT (CALLBACK *WNDENUMPROC32)(HWND32,LPARAM);
234 DECL_WINELIB_TYPE(WNDENUMPROC);
235 typedef LRESULT (CALLBACK *WNDPROC16)(HWND16,UINT16,WPARAM16,LPARAM);
236 typedef LRESULT (CALLBACK *WNDPROC32)(HWND32,UINT32,WPARAM32,LPARAM);
237 DECL_WINELIB_TYPE(WNDPROC);
239 /* TCHAR data types definitions for Winelib. */
240 /* These types are _not_ defined for the emulator, because they */
241 /* depend on the UNICODE macro that only exists in user's code. */
243 #ifndef __WINE__
244 # if defined(WINELIB32) && defined(UNICODE)
245 typedef WCHAR TCHAR;
246 typedef LPWSTR LPTSTR;
247 typedef LPCWSTR LPCTSTR;
248 # else /* WINELIB32 && UNICODE */
249 typedef CHAR TCHAR;
250 typedef LPSTR LPTSTR;
251 typedef LPCSTR LPCTSTR;
252 # endif /* WINELIB32 && UNICODE */
253 #endif /* __WINE__ */
255 /* Data types specific to the library. These do _not_ exist in the emulator. */
257 DECL_WINELIB_TYPE(INT);
258 DECL_WINELIB_TYPE(LPINT);
259 DECL_WINELIB_TYPE(LPUINT);
260 DECL_WINELIB_TYPE(UINT);
261 DECL_WINELIB_TYPE(BOOL);
262 DECL_WINELIB_TYPE(WPARAM);
264 DECL_WINELIB_TYPE(HACCEL);
265 DECL_WINELIB_TYPE(HANDLE);
266 DECL_WINELIB_TYPE(HBITMAP);
267 DECL_WINELIB_TYPE(HBRUSH);
268 DECL_WINELIB_TYPE(HCURSOR);
269 DECL_WINELIB_TYPE(HDC);
270 DECL_WINELIB_TYPE(HDROP);
271 DECL_WINELIB_TYPE(HDRVR);
272 DECL_WINELIB_TYPE(HDWP);
273 DECL_WINELIB_TYPE(HFILE);
274 DECL_WINELIB_TYPE(HFONT);
275 DECL_WINELIB_TYPE(HGDIOBJ);
276 DECL_WINELIB_TYPE(HGLOBAL);
277 DECL_WINELIB_TYPE(HICON);
278 DECL_WINELIB_TYPE(HINSTANCE);
279 DECL_WINELIB_TYPE(HLOCAL);
280 DECL_WINELIB_TYPE(HMENU);
281 DECL_WINELIB_TYPE(HMETAFILE);
282 DECL_WINELIB_TYPE(HMIDI);
283 DECL_WINELIB_TYPE(HMIDIIN);
284 DECL_WINELIB_TYPE(HMIDIOUT);
285 DECL_WINELIB_TYPE(HMMIO);
286 DECL_WINELIB_TYPE(HMODULE);
287 DECL_WINELIB_TYPE(HPALETTE);
288 DECL_WINELIB_TYPE(HPEN);
289 DECL_WINELIB_TYPE(HQUEUE);
290 DECL_WINELIB_TYPE(HRGN);
291 DECL_WINELIB_TYPE(HRSRC);
292 DECL_WINELIB_TYPE(HTASK);
293 DECL_WINELIB_TYPE(HWAVE);
294 DECL_WINELIB_TYPE(HWAVEIN);
295 DECL_WINELIB_TYPE(HWAVEOUT);
296 DECL_WINELIB_TYPE(HWND);
298 /* Misc. constants. */
300 #ifdef FALSE
301 #undef FALSE
302 #endif
303 #define FALSE 0
305 #ifdef TRUE
306 #undef TRUE
307 #endif
308 #define TRUE 1
310 #ifdef NULL
311 #undef NULL
312 #endif
313 #define NULL 0
315 /* Define some empty macros for compatibility with Windows code. */
317 #ifndef __WINE__
318 #define NEAR
319 #define FAR
320 #define _far
321 #define _near
322 #endif /* __WINE__ */
324 /* Macro for structure packing. */
326 #ifdef __GNUC__
327 #define WINE_PACKED __attribute__ ((packed))
328 #else
329 #define WINE_PACKED /* nothing */
330 #endif
332 /* Macros to split words and longs. */
334 #define LOBYTE(w) ((BYTE)(WORD)(w))
335 #define HIBYTE(w) ((BYTE)((WORD)(w) >> 8))
337 #define LOWORD(l) ((WORD)(DWORD)(l))
338 #define HIWORD(l) ((WORD)((DWORD)(l) >> 16))
340 #define SLOWORD(l) ((INT16)(LONG)(l))
341 #define SHIWORD(l) ((INT16)((LONG)(l) >> 16))
343 #define MAKELONG(low,high) ((LONG)(((WORD)(low)) | \
344 (((DWORD)((WORD)(high))) << 16)))
345 #define MAKELPARAM(low,high) ((LPARAM)MAKELONG(low,high))
346 #define MAKEWPARAM(low,high) ((WPARAM32)MAKELONG(low,high))
347 #define MAKEINTATOM(atom) ((LPCSTR)MAKELONG((atom),0))
349 #define SELECTOROF(ptr) (HIWORD(ptr))
350 #define OFFSETOF(ptr) (LOWORD(ptr))
352 /* Macros to access unaligned or wrong-endian WORDs and DWORDs. */
354 #ifdef __i386__
355 #define PUT_WORD(ptr,w) (*(WORD *)(ptr) = (w))
356 #define GET_WORD(ptr) (*(WORD *)(ptr))
357 #define PUT_DWORD(ptr,dw) (*(DWORD *)(ptr) = (dw))
358 #define GET_DWORD(ptr) (*(DWORD *)(ptr))
359 #else
360 #define PUT_WORD(ptr,w) (*(BYTE *)(ptr) = LOBYTE(w), \
361 *((BYTE *)(ptr) + 1) = HIBYTE(w))
362 #define GET_WORD(ptr) ((WORD)(*(BYTE *)(ptr) | \
363 (WORD)(*((BYTE *)(ptr)+1) << 8)))
364 #define PUT_DWORD(ptr,dw) (PUT_WORD((ptr),LOWORD(dw)), \
365 PUT_WORD((WORD *)(ptr)+1,HIWORD(dw)))
366 #define GET_DWORD(ptr) ((DWORD)(GET_WORD(ptr) | \
367 ((DWORD)GET_WORD((WORD *)(ptr)+1) << 16)))
368 #endif /* __i386__ */
370 /* MIN and MAX macros */
372 #ifdef MAX
373 #undef MAX
374 #endif
375 #define MAX(a,b) (((a) > (b)) ? (a) : (b))
377 #ifdef MIN
378 #undef MIN
379 #endif
380 #define MIN(a,b) (((a) < (b)) ? (a) : (b))
382 /* Winelib run-time flag */
384 #ifdef __WINE__
385 extern int __winelib;
386 #endif /* __WINE__ */
388 #endif /* __WINE_WINTYPES_H */