2 * Basic types definitions
4 * Copyright 1996 Alexandre Julliard
7 #ifndef __WINE_WINTYPES_H
8 #define __WINE_WINTYPES_H
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
38 /* Macros to map Winelib names to the correct implementation name */
39 /* depending on WINELIB16, WINELIB32 and UNICODE macros. */
42 # define WINELIB_NAME(func) this is a syntax error
43 # define WINELIB_NAME_AW(func) this is a syntax error
46 # define WINELIB_NAME(func) func##32
48 # define WINELIB_NAME_AW(func) func##32W
50 # define WINELIB_NAME_AW(func) func##32A
52 # else /* WINELIB32 */
53 # define WINELIB_NAME(func) func##16
54 # define WINELIB_NAME_AW(func) func##16
55 # endif /* WINELIB32 */
59 # define DECL_WINELIB_TYPE(type) /* nothing */
60 # define DECL_WINELIB_TYPE_AW(type) /* nothing */
62 # define DECL_WINELIB_TYPE(type) typedef WINELIB_NAME(type) type
63 # define DECL_WINELIB_TYPE_AW(type) typedef WINELIB_NAME_AW(type) type
67 /* Calling conventions definitions */
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")
75 # error You need gcc >= 2.7 to build Wine on a 386
76 # endif /* __GNUC__ */
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. */
97 typedef unsigned short UINT16
;
99 typedef unsigned int UINT32
;
100 typedef unsigned short WORD
;
101 typedef unsigned long DWORD
;
102 typedef unsigned char BYTE
;
105 /* Some systems might have wchar_t, but we really need 16 bit characters */
106 typedef unsigned short WCHAR
;
107 typedef unsigned short BOOL16
;
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
;
117 typedef LONG LRESULT
;
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
;
128 typedef DWORD LCTYPE
;
130 /* Pointers types. These are the same for emulator and library. */
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. */
152 typedef DWORD SEGPTR
;
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
);
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
);
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. */
244 # if defined(WINELIB32) && defined(UNICODE)
246 typedef LPWSTR LPTSTR
;
247 typedef LPCWSTR LPCTSTR
;
248 # else /* WINELIB32 && UNICODE */
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. */
315 /* Define some empty macros for compatibility with Windows code. */
322 #endif /* __WINE__ */
324 /* Macro for structure packing. */
327 #define WINE_PACKED __attribute__ ((packed))
329 #define WINE_PACKED /* nothing */
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. */
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))
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 */
375 #define MAX(a,b) (((a) > (b)) ? (a) : (b))
380 #define MIN(a,b) (((a) < (b)) ? (a) : (b))
382 /* Winelib run-time flag */
385 extern int __winelib
;
386 #endif /* __WINE__ */
388 #endif /* __WINE_WINTYPES_H */