windef.h 11.5 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
# elif defined(__aarch64__) && defined (__GNUC__)
#  define __stdcall __attribute__((ms_abi))
76 77 78 79 80 81 82
# else  /* __i386__ */
#  define __stdcall
# endif  /* __i386__ */
#endif /* __stdcall */

#ifndef __cdecl
# if defined(__i386__) && defined(__GNUC__)
83
#   if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 2)) || defined(__APPLE__)
84 85 86 87
#   define __cdecl __attribute__((__cdecl__)) __attribute__((__force_align_arg_pointer__))
#  else
#   define __cdecl __attribute__((__cdecl__))
#  endif
88
# elif defined(__x86_64__) && defined (__GNUC__)
89 90 91 92 93
#  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
94
# elif defined(__arm__) && defined (__GNUC__) && !defined(__SOFTFP__)
95
#   define __cdecl __attribute__((pcs("aapcs-vfp")))
96 97
# elif defined(__aarch64__) && defined (__GNUC__)
#  define __cdecl __attribute__((ms_abi))
98 99
# elif !defined(_MSC_VER)
#  define __cdecl
100
# endif
101
#endif /* __cdecl */
102

103
#ifndef __ms_va_list
104
# if (defined(__x86_64__) || defined(__aarch64__)) && defined (__GNUC__)
105 106 107
#  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)
108
#  define __ms_va_copy(dest,src) __builtin_ms_va_copy(dest,src)
109 110 111 112
# 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)
113 114 115 116 117
#  ifdef va_copy
#   define __ms_va_copy(dest,src) va_copy(dest,src)
#  else
#   define __ms_va_copy(dest,src) ((dest) = (src))
#  endif
118 119 120
# endif
#endif

121
#if defined(__arm__) && defined (__GNUC__) && !defined(__SOFTFP__)
122 123 124 125 126
# define WINAPIV __attribute__((pcs("aapcs")))
#else
# define WINAPIV __cdecl
#endif

127 128 129 130 131
#ifdef __WINESRC__
#define __ONLY_IN_WINELIB(x)	do_not_use_this_in_wine
#else
#define __ONLY_IN_WINELIB(x)	x
#endif
132 133

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

#ifndef near
159
#define near        __ONLY_IN_WINELIB(/* nothing */)
160 161
#endif
#ifndef far
162
#define far         __ONLY_IN_WINELIB(/* nothing */)
163 164
#endif
#ifndef _near
165
#define _near       __ONLY_IN_WINELIB(/* nothing */)
166 167
#endif
#ifndef _far
168
#define _far        __ONLY_IN_WINELIB(/* nothing */)
169 170
#endif
#ifndef NEAR
171
#define NEAR        __ONLY_IN_WINELIB(/* nothing */)
172 173
#endif
#ifndef FAR
174
#define FAR         __ONLY_IN_WINELIB(/* nothing */)
175 176
#endif

177 178
#ifndef _MSC_VER
# ifndef _declspec
179
#  define _declspec(x)    __ONLY_IN_WINELIB(/* nothing */)
180 181
# endif
# ifndef __declspec
182
#  define __declspec(x)   __ONLY_IN_WINELIB(/* nothing */)
183
# endif
184 185
#endif

186 187 188 189
#ifdef _MSC_VER
# define inline __inline
#endif

190 191 192 193 194 195 196
#define CALLBACK    __stdcall
#define WINAPI      __stdcall
#define APIPRIVATE  __stdcall
#define PASCAL      __stdcall
#define CDECL       __cdecl
#define _CDECL      __cdecl
#define APIENTRY    WINAPI
197
#define CONST       __ONLY_IN_WINELIB(const)
198

199
/* Misc. constants. */
200

201
#undef NULL
202
#ifdef __cplusplus
203 204 205 206 207 208 209
#define NULL  0
#else
#define NULL  ((void*)0)
#endif

#ifdef FALSE
#undef FALSE
210
#endif
211
#define FALSE 0
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 237 238 239 240
#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;
241 242
typedef float           FLOAT,      *PFLOAT;
typedef char                        *PSZ;
243
#ifdef _MSC_VER
244 245 246
typedef long                                   *LPLONG;
typedef unsigned long   DWORD,      *PDWORD,   *LPDWORD;
typedef unsigned long   ULONG,      *PULONG;
247 248 249 250
#else
typedef int                                    *LPLONG;
typedef unsigned int    DWORD,      *PDWORD,   *LPDWORD;
typedef unsigned int    ULONG,      *PULONG;
251
#endif
252

253 254 255
/* Macros to map Winelib names to the correct implementation name */
/* Note that Winelib is purely Win32.                             */

256
#ifdef __WINESRC__
257 258
#define WINE_NO_UNICODE_MACROS 1
#define WINE_STRICT_PROTOTYPES 1
259 260 261
#endif

#ifdef WINE_NO_UNICODE_MACROS
262 263 264
# 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
265
#else  /* WINE_NO_UNICODE_MACROS */
266 267 268 269
# ifdef UNICODE
#  define WINELIB_NAME_AW(func) func##W
# else
#  define WINELIB_NAME_AW(func) func##A
270 271
# endif
#endif  /* WINE_NO_UNICODE_MACROS */
272

273
#ifdef WINE_NO_UNICODE_MACROS
274
# define DECL_WINELIB_TYPE_AW(type)  /* nothing */
275
#else
276
# define DECL_WINELIB_TYPE_AW(type)  typedef WINELIB_NAME_AW(type) type;
277
#endif
278

279
#include <winnt.h>
280

281 282 283 284 285 286
/* Polymorphic types */

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

287
/* Integer types */
288

289
typedef WORD            ATOM;
290 291
typedef DWORD           COLORREF, *LPCOLORREF;

292

293
/* Handle types */
294

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

324 325 326 327 328 329
/* Handle types that must remain interchangeable even with strict on */

typedef HINSTANCE HMODULE;
typedef HANDLE HGDIOBJ;
typedef HANDLE HGLOBAL;
typedef HANDLE HLOCAL;
330 331
typedef HANDLE GLOBALHANDLE;
typedef HANDLE LOCALHANDLE;
332
typedef HICON HCURSOR;
333

334 335
/* Callback function pointers types */

336 337 338 339 340
#ifdef WINE_STRICT_PROTOTYPES
typedef INT_PTR (CALLBACK *FARPROC)(void);
typedef INT_PTR (CALLBACK *NEARPROC)(void);
typedef INT_PTR (CALLBACK *PROC)(void);
#else
341 342 343
typedef INT_PTR (CALLBACK *FARPROC)();
typedef INT_PTR (CALLBACK *NEARPROC)();
typedef INT_PTR (CALLBACK *PROC)();
344
#endif
345

346 347
/* Macros to split words and longs. */

348 349
#define LOBYTE(w)              ((BYTE)((DWORD_PTR)(w) & 0xFF))
#define HIBYTE(w)              ((BYTE)((DWORD_PTR)(w) >> 8))
350

351 352
#define LOWORD(l)              ((WORD)((DWORD_PTR)(l) & 0xFFFF))
#define HIWORD(l)              ((WORD)((DWORD_PTR)(l) >> 16))
353

354 355
#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))
356

357
/* min and max macros */
358
#ifndef NOMINMAX
359
#ifndef max
360
#define max(a,b)   (((a) > (b)) ? (a) : (b))
361 362
#endif
#ifndef min
363
#define min(a,b)   (((a) < (b)) ? (a) : (b))
364
#endif
365
#endif  /* NOMINMAX */
366

367 368 369 370
#ifdef MAX_PATH /* Work-around for Mingw */ 
#undef MAX_PATH
#endif /* MAX_PATH */

371
#define MAX_PATH        260
372
#define HFILE_ERROR     ((HFILE)-1)
373

374 375 376
/* The SIZE structure */
typedef struct tagSIZE
{
377 378
    LONG cx;
    LONG cy;
379 380 381 382 383 384 385 386 387 388
} SIZE, *PSIZE, *LPSIZE;

typedef SIZE SIZEL, *PSIZEL, *LPSIZEL;

/* The POINT structure */
typedef struct tagPOINT
{
    LONG  x;
    LONG  y;
} POINT, *PPOINT, *LPPOINT;
389 390 391

typedef struct _POINTL
{
392 393
    LONG x;
    LONG y;
394
} POINTL, *PPOINTL;
395

396 397 398 399
/* The POINTS structure */

typedef struct tagPOINTS
{
400 401 402 403
#ifdef WORDS_BIGENDIAN
    SHORT y;
    SHORT x;
#else
404 405
    SHORT x;
    SHORT y;
406
#endif
407 408
} POINTS, *PPOINTS, *LPPOINTS;

409 410 411 412 413 414 415 416 417 418 419
typedef struct _FILETIME {
#ifdef WORDS_BIGENDIAN
    DWORD  dwHighDateTime;
    DWORD  dwLowDateTime;
#else
    DWORD  dwLowDateTime;
    DWORD  dwHighDateTime;
#endif
} FILETIME, *PFILETIME, *LPFILETIME;
#define _FILETIME_

420 421 422
/* The RECT structure */
typedef struct tagRECT
{
423 424 425 426
    LONG left;
    LONG top;
    LONG right;
    LONG bottom;
427 428 429
} RECT, *PRECT, *LPRECT;
typedef const RECT *LPCRECT;

430
typedef struct _RECTL
431 432
{
    LONG left;
433
    LONG top;
434 435 436 437 438 439
    LONG right;
    LONG bottom;
} RECTL, *PRECTL, *LPRECTL;

typedef const RECTL *LPCRECTL;

440 441 442 443 444 445 446 447 448 449 450 451 452
/* DPI awareness */
typedef enum DPI_AWARENESS
{
    DPI_AWARENESS_INVALID = -1,
    DPI_AWARENESS_UNAWARE = 0,
    DPI_AWARENESS_SYSTEM_AWARE,
    DPI_AWARENESS_PER_MONITOR_AWARE
} DPI_AWARENESS;

#define DPI_AWARENESS_CONTEXT_UNAWARE              ((DPI_AWARENESS_CONTEXT)-1)
#define DPI_AWARENESS_CONTEXT_SYSTEM_AWARE         ((DPI_AWARENESS_CONTEXT)-2)
#define DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE    ((DPI_AWARENESS_CONTEXT)-3)
#define DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 ((DPI_AWARENESS_CONTEXT)-4)
453
#define DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED    ((DPI_AWARENESS_CONTEXT)-5)
454

455 456 457
#ifdef __cplusplus
}
#endif
458

459
#endif /* _WINDEF_ */