windef.h 10.6 KB
Newer Older
1 2 3 4
/*
 * Basic types definitions
 *
 * Copyright 1996 Alexandre Julliard
5 6 7 8 9 10 11 12 13 14 15 16 17
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19
 */
20

21 22
#ifndef _WINDEF_
#define _WINDEF_
23

24
#ifndef WINVER
25
#define WINVER 0x0500
26
#endif
27

28 29 30 31 32 33
#ifndef NO_STRICT
# ifndef STRICT
#  define STRICT
# endif /* STRICT */
#endif /* NO_STRICT */

34 35 36 37 38 39
#ifdef __cplusplus
extern "C" {
#endif

/* Calling conventions definitions */

40
#if (defined(__x86_64__) || defined(__powerpc64__) || defined(__aarch64__)) && !defined(_WIN64)
41 42 43
#define _WIN64
#endif

44 45 46 47 48 49 50 51 52
#ifndef _WIN64
# if defined(__i386__) && !defined(_X86_)
#  define _X86_
# endif
# if defined(_X86_) && !defined(__i386__)
#  define __i386__
# endif
#endif

53 54 55
#ifndef __stdcall
# ifdef __i386__
#  ifdef __GNUC__
56
#   if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 2)) || defined(__APPLE__)
57 58 59 60
#    define __stdcall __attribute__((__stdcall__)) __attribute__((__force_align_arg_pointer__))
#   else
#    define __stdcall __attribute__((__stdcall__))
#   endif
61 62 63 64 65
#  elif defined(_MSC_VER)
    /* Nothing needs to be done. __stdcall already exists */
#  else
#   error You need to define __stdcall for your compiler
#  endif
66
# elif defined(__x86_64__) && defined (__GNUC__)
67 68 69 70 71
#  if (__GNUC__ > 5) || ((__GNUC__ == 5) && (__GNUC_MINOR__ >= 3))
#   define __stdcall __attribute__((ms_abi)) __attribute__((__force_align_arg_pointer__))
#  else
#   define __stdcall __attribute__((ms_abi))
#  endif
72
# elif defined(__arm__) && defined (__GNUC__) && !defined(__SOFTFP__)
73
#   define __stdcall __attribute__((pcs("aapcs-vfp")))
74 75 76 77 78 79 80
# else  /* __i386__ */
#  define __stdcall
# endif  /* __i386__ */
#endif /* __stdcall */

#ifndef __cdecl
# if defined(__i386__) && defined(__GNUC__)
81
#   if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 2)) || defined(__APPLE__)
82 83 84 85
#   define __cdecl __attribute__((__cdecl__)) __attribute__((__force_align_arg_pointer__))
#  else
#   define __cdecl __attribute__((__cdecl__))
#  endif
86
# elif defined(__x86_64__) && defined (__GNUC__)
87 88 89 90 91
#  if (__GNUC__ > 5) || ((__GNUC__ == 5) && (__GNUC_MINOR__ >= 3))
#   define __cdecl __attribute__((ms_abi)) __attribute__((__force_align_arg_pointer__))
#  else
#   define __cdecl __attribute__((ms_abi))
#  endif
92
# elif defined(__arm__) && defined (__GNUC__) && !defined(__SOFTFP__)
93
#   define __cdecl __attribute__((pcs("aapcs-vfp")))
94 95
# elif !defined(_MSC_VER)
#  define __cdecl
96
# endif
97
#endif /* __cdecl */
98

99 100 101 102 103
#ifndef __ms_va_list
# if defined(__x86_64__) && defined (__GNUC__)
#  define __ms_va_list __builtin_ms_va_list
#  define __ms_va_start(list,arg) __builtin_ms_va_start(list,arg)
#  define __ms_va_end(list) __builtin_ms_va_end(list)
104
#  define __ms_va_copy(dest,src) __builtin_ms_va_copy(dest,src)
105 106 107 108
# else
#  define __ms_va_list va_list
#  define __ms_va_start(list,arg) va_start(list,arg)
#  define __ms_va_end(list) va_end(list)
109 110 111 112 113
#  ifdef va_copy
#   define __ms_va_copy(dest,src) va_copy(dest,src)
#  else
#   define __ms_va_copy(dest,src) ((dest) = (src))
#  endif
114 115 116
# endif
#endif

117
#if defined(__arm__) && defined (__GNUC__) && !defined(__SOFTFP__)
118 119 120 121 122
# define WINAPIV __attribute__((pcs("aapcs")))
#else
# define WINAPIV __cdecl
#endif

123 124 125 126 127
#ifdef __WINESRC__
#define __ONLY_IN_WINELIB(x)	do_not_use_this_in_wine
#else
#define __ONLY_IN_WINELIB(x)	x
#endif
128 129

#ifndef pascal
130
#define pascal      __ONLY_IN_WINELIB(__stdcall)
131 132
#endif
#ifndef _pascal
133
#define _pascal	    __ONLY_IN_WINELIB(__stdcall)
134 135
#endif
#ifndef _stdcall
136
#define _stdcall    __ONLY_IN_WINELIB(__stdcall)
137 138
#endif
#ifndef _fastcall
139
#define _fastcall   __ONLY_IN_WINELIB(__stdcall)
140 141
#endif
#ifndef __fastcall
142
#define __fastcall  __ONLY_IN_WINELIB(__stdcall)
143 144
#endif
#ifndef __export
145
#define __export    __ONLY_IN_WINELIB(__stdcall)
146 147
#endif
#ifndef cdecl
148
#define cdecl       __ONLY_IN_WINELIB(__cdecl)
149 150
#endif
#ifndef _cdecl
151
#define _cdecl      __ONLY_IN_WINELIB(__cdecl)
152 153 154
#endif

#ifndef near
155
#define near        __ONLY_IN_WINELIB(/* nothing */)
156 157
#endif
#ifndef far
158
#define far         __ONLY_IN_WINELIB(/* nothing */)
159 160
#endif
#ifndef _near
161
#define _near       __ONLY_IN_WINELIB(/* nothing */)
162 163
#endif
#ifndef _far
164
#define _far        __ONLY_IN_WINELIB(/* nothing */)
165 166
#endif
#ifndef NEAR
167
#define NEAR        __ONLY_IN_WINELIB(/* nothing */)
168 169
#endif
#ifndef FAR
170
#define FAR         __ONLY_IN_WINELIB(/* nothing */)
171 172
#endif

173 174
#ifndef _MSC_VER
# ifndef _declspec
175
#  define _declspec(x)    __ONLY_IN_WINELIB(/* nothing */)
176 177
# endif
# ifndef __declspec
178
#  define __declspec(x)   __ONLY_IN_WINELIB(/* nothing */)
179
# endif
180 181
#endif

182 183 184 185
#ifdef _MSC_VER
# define inline __inline
#endif

186 187 188 189 190 191 192
#define CALLBACK    __stdcall
#define WINAPI      __stdcall
#define APIPRIVATE  __stdcall
#define PASCAL      __stdcall
#define CDECL       __cdecl
#define _CDECL      __cdecl
#define APIENTRY    WINAPI
193
#define CONST       __ONLY_IN_WINELIB(const)
194

195
/* Misc. constants. */
196

197
#undef NULL
198
#ifdef __cplusplus
199 200 201 202 203 204 205
#define NULL  0
#else
#define NULL  ((void*)0)
#endif

#ifdef FALSE
#undef FALSE
206
#endif
207
#define FALSE 0
208

209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236
#ifdef TRUE
#undef TRUE
#endif
#define TRUE  1

#ifndef IN
#define IN
#endif

#ifndef OUT
#define OUT
#endif

#ifndef OPTIONAL
#define OPTIONAL
#endif

/* Standard data types */

typedef void                                   *LPVOID;
typedef const void                             *LPCVOID;
typedef int             BOOL,       *PBOOL,    *LPBOOL;
typedef unsigned char   BYTE,       *PBYTE,    *LPBYTE;
typedef unsigned char   UCHAR,      *PUCHAR;
typedef unsigned short  WORD,       *PWORD,    *LPWORD;
typedef unsigned short  USHORT,     *PUSHORT;
typedef int             INT,        *PINT,     *LPINT;
typedef unsigned int    UINT,       *PUINT;
237 238
typedef float           FLOAT,      *PFLOAT;
typedef char                        *PSZ;
239
#ifdef _MSC_VER
240 241 242
typedef long                                   *LPLONG;
typedef unsigned long   DWORD,      *PDWORD,   *LPDWORD;
typedef unsigned long   ULONG,      *PULONG;
243 244 245 246
#else
typedef int                                    *LPLONG;
typedef unsigned int    DWORD,      *PDWORD,   *LPDWORD;
typedef unsigned int    ULONG,      *PULONG;
247
#endif
248

249 250 251
/* Macros to map Winelib names to the correct implementation name */
/* Note that Winelib is purely Win32.                             */

252
#ifdef __WINESRC__
253 254
#define WINE_NO_UNICODE_MACROS 1
#define WINE_STRICT_PROTOTYPES 1
255 256 257
#endif

#ifdef WINE_NO_UNICODE_MACROS
258 259 260
# define WINELIB_NAME_AW(func) \
    func##_must_be_suffixed_with_W_or_A_in_this_context \
    func##_must_be_suffixed_with_W_or_A_in_this_context
261
#else  /* WINE_NO_UNICODE_MACROS */
262 263 264 265
# ifdef UNICODE
#  define WINELIB_NAME_AW(func) func##W
# else
#  define WINELIB_NAME_AW(func) func##A
266 267
# endif
#endif  /* WINE_NO_UNICODE_MACROS */
268

269
#ifdef WINE_NO_UNICODE_MACROS
270
# define DECL_WINELIB_TYPE_AW(type)  /* nothing */
271
#else
272
# define DECL_WINELIB_TYPE_AW(type)  typedef WINELIB_NAME_AW(type) type;
273
#endif
274

275
#include <winnt.h>
276

277 278 279 280 281 282
/* Polymorphic types */

typedef UINT_PTR        WPARAM;
typedef LONG_PTR        LPARAM;
typedef LONG_PTR        LRESULT;

283
/* Integer types */
284

285
typedef WORD            ATOM;
286 287
typedef DWORD           COLORREF, *LPCOLORREF;

288

289
/* Handle types */
290

291
typedef int HFILE;
292
DECLARE_HANDLE(HACCEL);
293 294
DECLARE_HANDLE(HBITMAP);
DECLARE_HANDLE(HBRUSH);
295
DECLARE_HANDLE(HCOLORSPACE);
296
DECLARE_HANDLE(HDC);
297
DECLARE_HANDLE(HDESK);
298
DECLARE_HANDLE(HENHMETAFILE);
299
DECLARE_HANDLE(HFONT);
300
DECLARE_HANDLE(HGLRC);
301
DECLARE_HANDLE(HHOOK);
302
DECLARE_HANDLE(HICON);
303
DECLARE_HANDLE(HINSTANCE);
304
DECLARE_HANDLE(HKEY);
305
typedef HKEY *PHKEY;
306
DECLARE_HANDLE(HKL);
307
DECLARE_HANDLE(HMENU);
308
DECLARE_HANDLE(HMETAFILE);
309
DECLARE_HANDLE(HMONITOR);
310
DECLARE_HANDLE(HPALETTE);
311 312
DECLARE_HANDLE(HPEN);
DECLARE_HANDLE(HRGN);
313
DECLARE_HANDLE(HRSRC);
314
DECLARE_HANDLE(HTASK);
315
DECLARE_HANDLE(HWINEVENTHOOK);
316
DECLARE_HANDLE(HWINSTA);
317
DECLARE_HANDLE(HWND);
318

319 320 321 322 323 324
/* Handle types that must remain interchangeable even with strict on */

typedef HINSTANCE HMODULE;
typedef HANDLE HGDIOBJ;
typedef HANDLE HGLOBAL;
typedef HANDLE HLOCAL;
325 326
typedef HANDLE GLOBALHANDLE;
typedef HANDLE LOCALHANDLE;
327
typedef HICON HCURSOR;
328

329 330
/* Callback function pointers types */

331 332 333 334 335
#ifdef WINE_STRICT_PROTOTYPES
typedef INT_PTR (CALLBACK *FARPROC)(void);
typedef INT_PTR (CALLBACK *NEARPROC)(void);
typedef INT_PTR (CALLBACK *PROC)(void);
#else
336 337 338
typedef INT_PTR (CALLBACK *FARPROC)();
typedef INT_PTR (CALLBACK *NEARPROC)();
typedef INT_PTR (CALLBACK *PROC)();
339
#endif
340

341 342
/* Macros to split words and longs. */

343 344
#define LOBYTE(w)              ((BYTE)((DWORD_PTR)(w) & 0xFF))
#define HIBYTE(w)              ((BYTE)((DWORD_PTR)(w) >> 8))
345

346 347
#define LOWORD(l)              ((WORD)((DWORD_PTR)(l) & 0xFFFF))
#define HIWORD(l)              ((WORD)((DWORD_PTR)(l) >> 16))
348

349 350
#define MAKEWORD(low,high)     ((WORD)(((BYTE)((DWORD_PTR)(low) & 0xFF)) | ((WORD)((BYTE)((DWORD_PTR)(high) & 0xFF))) << 8))
#define MAKELONG(low,high)     ((LONG)(((WORD)((DWORD_PTR)(low) & 0xFFFF)) | ((DWORD)((WORD)((DWORD_PTR)(high) & 0xFFFF))) << 16))
351

352
/* min and max macros */
353
#ifndef NOMINMAX
354
#ifndef max
355
#define max(a,b)   (((a) > (b)) ? (a) : (b))
356 357
#endif
#ifndef min
358
#define min(a,b)   (((a) < (b)) ? (a) : (b))
359
#endif
360
#endif  /* NOMINMAX */
361

362 363 364 365
#ifdef MAX_PATH /* Work-around for Mingw */ 
#undef MAX_PATH
#endif /* MAX_PATH */

366
#define MAX_PATH        260
367
#define HFILE_ERROR     ((HFILE)-1)
368

369 370 371
/* The SIZE structure */
typedef struct tagSIZE
{
372 373
    LONG cx;
    LONG cy;
374 375 376 377 378 379 380 381 382 383
} SIZE, *PSIZE, *LPSIZE;

typedef SIZE SIZEL, *PSIZEL, *LPSIZEL;

/* The POINT structure */
typedef struct tagPOINT
{
    LONG  x;
    LONG  y;
} POINT, *PPOINT, *LPPOINT;
384 385 386

typedef struct _POINTL
{
387 388
    LONG x;
    LONG y;
389
} POINTL, *PPOINTL;
390

391 392 393 394
/* The POINTS structure */

typedef struct tagPOINTS
{
395 396 397 398
#ifdef WORDS_BIGENDIAN
    SHORT y;
    SHORT x;
#else
399 400
    SHORT x;
    SHORT y;
401
#endif
402 403
} POINTS, *PPOINTS, *LPPOINTS;

404 405 406 407 408 409 410 411 412 413 414
typedef struct _FILETIME {
#ifdef WORDS_BIGENDIAN
    DWORD  dwHighDateTime;
    DWORD  dwLowDateTime;
#else
    DWORD  dwLowDateTime;
    DWORD  dwHighDateTime;
#endif
} FILETIME, *PFILETIME, *LPFILETIME;
#define _FILETIME_

415 416 417
/* The RECT structure */
typedef struct tagRECT
{
418 419 420 421
    LONG left;
    LONG top;
    LONG right;
    LONG bottom;
422 423 424
} RECT, *PRECT, *LPRECT;
typedef const RECT *LPCRECT;

425
typedef struct _RECTL
426 427
{
    LONG left;
428
    LONG top;
429 430 431 432 433 434 435 436 437
    LONG right;
    LONG bottom;
} RECTL, *PRECTL, *LPRECTL;

typedef const RECTL *LPCRECTL;

#ifdef __cplusplus
}
#endif
438

439
#endif /* _WINDEF_ */