1/** 2 * This file has no copyright assigned and is placed in the Public Domain. 3 * This file is part of the mingw-w64 runtime package. 4 * No warranty is given; refer to the file DISCLAIMER.PD within this package. 5 */ 6 7#ifndef _INC__MINGW_H 8#define _INC__MINGW_H 9 10#include "_mingw_mac.h" 11#include "_mingw_secapi.h" 12 13/* Include _cygwin.h if we're building a Cygwin application. */ 14#ifdef __CYGWIN__ 15#include "_cygwin.h" 16#endif 17 18/* Target specific macro replacement for type "long". In the Windows API, 19 the type long is always 32 bit, even if the target is 64 bit (LLP64). 20 On 64 bit Cygwin, the type long is 64 bit (LP64). So, to get the right 21 sized definitions and declarations, all usage of type long in the Windows 22 headers have to be replaced by the below defined macro __LONG32. */ 23#ifndef __LP64__ /* 32 bit target, 64 bit Mingw target */ 24#define __LONG32 long 25#else /* 64 bit Cygwin target */ 26#define __LONG32 int 27#endif 28 29/* C/C++ specific language defines. */ 30#ifdef _WIN64 31#ifdef __stdcall 32#undef __stdcall 33#endif 34#define __stdcall 35#endif 36 37#ifndef __GNUC__ 38# ifndef __MINGW_IMPORT 39# define __MINGW_IMPORT __declspec(dllimport) 40# endif 41# ifndef _CRTIMP 42# define _CRTIMP __declspec(dllimport) 43# endif 44# define __DECLSPEC_SUPPORTED 45# define __attribute__(x) /* nothing */ 46#else /* __GNUC__ */ 47# ifdef __declspec 48# ifndef __MINGW_IMPORT 49/* Note the extern. This is needed to work around GCC's 50limitations in handling dllimport attribute. */ 51# define __MINGW_IMPORT extern __attribute__ ((__dllimport__)) 52# endif 53# ifndef _CRTIMP 54# undef __USE_CRTIMP 55# if !defined (_CRTBLD) && !defined (_SYSCRT) 56# define __USE_CRTIMP 1 57# endif 58# ifdef __USE_CRTIMP 59# define _CRTIMP __attribute__ ((__dllimport__)) 60# else 61# define _CRTIMP 62# endif 63# endif 64# define __DECLSPEC_SUPPORTED 65# else /* __declspec */ 66# undef __DECLSPEC_SUPPORTED 67# undef __MINGW_IMPORT 68# ifndef _CRTIMP 69# define _CRTIMP 70# endif 71# endif /* __declspec */ 72#endif /* __GNUC__ */ 73 74#ifdef _MSC_VER 75#define USE___UUIDOF 1 76#else 77#define USE___UUIDOF 0 78#endif 79 80#if !defined(_MSC_VER) && !defined(_inline) 81#define _inline __inline 82#endif 83 84#ifdef __cplusplus 85# define __CRT_INLINE inline 86#elif defined(_MSC_VER) 87# define __CRT_INLINE __inline 88#else 89# if ( __MINGW_GNUC_PREREQ(4, 3) && __STDC_VERSION__ >= 199901L) \ 90 || (defined (__clang__)) 91# define __CRT_INLINE extern inline __attribute__((__gnu_inline__)) 92# else 93# define __CRT_INLINE extern __inline__ 94# endif 95#endif 96 97#if !defined(__MINGW_INTRIN_INLINE) && defined(__GNUC__) 98#define __MINGW_INTRIN_INLINE extern __inline__ __attribute__((__always_inline__,__gnu_inline__)) 99#endif 100 101#ifndef __CYGWIN__ 102#ifdef __NO_INLINE__ 103#undef __CRT__NO_INLINE 104#define __CRT__NO_INLINE 1 105#endif 106#endif 107 108#ifdef __cplusplus 109# define __UNUSED_PARAM(x) 110#else 111# ifdef __GNUC__ 112# define __UNUSED_PARAM(x) x __attribute__ ((__unused__)) 113# else 114# define __UNUSED_PARAM(x) x 115# endif 116#endif 117 118#ifndef __GNUC__ 119# ifdef _MSC_VER 120# define __restrict__ __restrict 121# else 122# define __restrict__ /* nothing */ 123# endif 124#endif /* !__GNUC__ */ 125 126#if __MINGW_GNUC_PREREQ (3,1) && !defined __GNUG__ 127# define __restrict_arr __restrict 128#elif defined(_MSC_VER) 129# define __restrict_arr __restrict 130#else 131# ifdef __GNUC__ 132# define __restrict_arr /* Not supported in old GCC. */ 133# else 134# if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L 135# define __restrict_arr restrict 136# else 137# define __restrict_arr /* Not supported. */ 138# endif 139# endif 140#endif 141 142#ifdef __GNUC__ 143#define __MINGW_ATTRIB_NORETURN __attribute__ ((__noreturn__)) 144#define __MINGW_ATTRIB_CONST __attribute__ ((__const__)) 145#elif __MINGW_MSC_PREREQ(12, 0) 146#define __MINGW_ATTRIB_NORETURN __declspec(noreturn) 147#define __MINGW_ATTRIB_CONST 148#else 149#define __MINGW_ATTRIB_NORETURN 150#define __MINGW_ATTRIB_CONST 151#endif 152 153#if __MINGW_GNUC_PREREQ (3, 0) 154#define __MINGW_ATTRIB_MALLOC __attribute__ ((__malloc__)) 155#define __MINGW_ATTRIB_PURE __attribute__ ((__pure__)) 156#elif __MINGW_MSC_PREREQ(14, 0) 157#define __MINGW_ATTRIB_MALLOC __declspec(noalias) __declspec(restrict) 158#define __MINGW_ATTRIB_PURE 159#else 160#define __MINGW_ATTRIB_MALLOC 161#define __MINGW_ATTRIB_PURE 162#endif 163 164/* Attribute `nonnull' was valid as of gcc 3.3. We don't use GCC's 165 variadiac macro facility, because variadic macros cause syntax 166 errors with --traditional-cpp. */ 167#if __MINGW_GNUC_PREREQ (3, 3) 168#define __MINGW_ATTRIB_NONNULL(arg) __attribute__ ((__nonnull__ (arg))) 169#else 170#define __MINGW_ATTRIB_NONNULL(arg) 171#endif /* GNUC >= 3.3 */ 172 173#ifdef __GNUC__ 174#define __MINGW_ATTRIB_UNUSED __attribute__ ((__unused__)) 175#else 176#define __MINGW_ATTRIB_UNUSED 177#endif /* ATTRIBUTE_UNUSED */ 178 179#if __MINGW_GNUC_PREREQ (3, 1) 180#define __MINGW_ATTRIB_USED __attribute__ ((__used__)) 181#define __MINGW_ATTRIB_DEPRECATED __attribute__ ((__deprecated__)) 182#if __MINGW_GNUC_PREREQ (4, 5) || defined (__clang__) 183#define __MINGW_ATTRIB_DEPRECATED_MSG(x) __attribute__ ((__deprecated__(x))) 184#endif 185#elif __MINGW_MSC_PREREQ(12, 0) 186#define __MINGW_ATTRIB_USED 187#define __MINGW_ATTRIB_DEPRECATED __declspec(deprecated) 188#else 189#define __MINGW_ATTRIB_USED __MINGW_ATTRIB_UNUSED 190#define __MINGW_ATTRIB_DEPRECATED 191#endif /* GNUC >= 3.1 */ 192 193#ifndef __MINGW_ATTRIB_DEPRECATED_MSG 194#define __MINGW_ATTRIB_DEPRECATED_MSG(x) __MINGW_ATTRIB_DEPRECATED 195#endif 196 197#if __MINGW_GNUC_PREREQ (3, 3) 198#define __MINGW_NOTHROW __attribute__ ((__nothrow__)) 199#elif __MINGW_MSC_PREREQ(12, 0) && defined (__cplusplus) 200#define __MINGW_NOTHROW __declspec(nothrow) 201#else 202#define __MINGW_NOTHROW 203#endif 204 205#if __MINGW_GNUC_PREREQ (4, 4) 206#define __MINGW_ATTRIB_NO_OPTIMIZE __attribute__((__optimize__ ("0"))) 207#else 208#define __MINGW_ATTRIB_NO_OPTIMIZE 209#endif 210 211#if __MINGW_GNUC_PREREQ (4, 4) 212#define __MINGW_PRAGMA_PARAM(x) _Pragma (#x) 213#elif __MINGW_MSC_PREREQ (13, 1) 214#define __MINGW_PRAGMA_PARAM(x) __pragma (x) 215#else 216#define __MINGW_PRAGMA_PARAM(x) 217#endif 218 219#define __MINGW_BROKEN_INTERFACE(x) \ 220 __MINGW_PRAGMA_PARAM(message ("Interface " _CRT_STRINGIZE(x) \ 221 " has unverified layout.")) 222 223#ifndef __MSVCRT_VERSION__ 224/* High byte is the major version, low byte is the minor. */ 225# ifndef _UCRT 226# define __MSVCRT_VERSION__ @DEFAULT_MSVCRT_VERSION@ 227# else 228# define __MSVCRT_VERSION__ 0xE00 229# endif 230#endif 231 232 233#ifndef _WIN32_WINNT 234#define _WIN32_WINNT @DEFAULT_WIN32_WINNT@ 235#endif 236 237#ifndef _INT128_DEFINED 238#define _INT128_DEFINED 239#ifdef __GNUC__ 240#define __int8 char 241#define __int16 short 242#define __int32 int 243#define __int64 long long 244#ifdef _WIN64 245#if (__clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 1)) && \ 246 !defined(__SIZEOF_INT128__) /* clang >= 3.1 has __int128 but no size macro */ 247#define __SIZEOF_INT128__ 16 248#endif 249#ifndef __SIZEOF_INT128__ 250typedef int __int128 __attribute__ ((__mode__ (TI))); 251#endif 252#endif 253#endif /* __GNUC__ */ 254#endif /* _INT128_DEFINED */ 255 256#ifdef __GNUC__ 257#define __ptr32 258#define __ptr64 259#ifndef __unaligned 260#define __unaligned 261#endif 262#ifndef __w64 263#define __w64 264#endif 265#ifdef __cplusplus 266#define __forceinline inline __attribute__((__always_inline__)) 267#else 268#define __forceinline extern __inline__ __attribute__((__always_inline__,__gnu_inline__)) 269#endif /* __cplusplus */ 270#endif /* __GNUC__ */ 271 272#if !defined(_WIN32) && !defined(__CYGWIN__) 273#error Only Win32 target is supported! 274#endif 275 276#ifndef __nothrow 277#ifdef __cplusplus 278#define __nothrow __MINGW_NOTHROW 279#else 280#define __nothrow 281#endif 282#endif /* __nothrow */ 283 284#include <vadefs.h> /* other headers depend on this include */ 285 286#ifndef _CRT_STRINGIZE 287#define __CRT_STRINGIZE(_Value) #_Value 288#define _CRT_STRINGIZE(_Value) __CRT_STRINGIZE(_Value) 289#endif /* _CRT_STRINGIZE */ 290 291#ifndef _CRT_WIDE 292#define __CRT_WIDE(_String) L ## _String 293#define _CRT_WIDE(_String) __CRT_WIDE(_String) 294#endif /* _CRT_WIDE */ 295 296#ifndef _W64 297#define _W64 298#endif 299 300#ifndef _CRTIMP_NOIA64 301#ifdef __ia64__ 302#define _CRTIMP_NOIA64 303#else 304#define _CRTIMP_NOIA64 _CRTIMP 305#endif 306#endif /* _CRTIMP_NOIA64 */ 307 308#ifndef _CRTIMP2 309#define _CRTIMP2 _CRTIMP 310#endif 311 312#ifndef _CRTIMP_ALTERNATIVE 313#define _CRTIMP_ALTERNATIVE _CRTIMP 314#define _CRT_ALTERNATIVE_IMPORTED 315#endif /* _CRTIMP_ALTERNATIVE */ 316 317#ifndef _MRTIMP2 318#define _MRTIMP2 _CRTIMP 319#endif 320 321/* We have to define _DLL for gcc based mingw version. This define is set 322 by VC, when DLL-based runtime is used. So, gcc based runtime just have 323 DLL-base runtime, therefore this define has to be set. 324 As our headers are possibly used by windows compiler having a static 325 C-runtime, we make this definition gnu compiler specific here. */ 326#if !defined (_DLL) && defined (__GNUC__) 327#define _DLL 328#endif 329 330#ifndef _MT 331#define _MT 332#endif 333 334#ifndef _MCRTIMP 335#define _MCRTIMP _CRTIMP 336#endif 337 338#ifndef _CRTIMP_PURE 339#define _CRTIMP_PURE _CRTIMP 340#endif 341 342#ifndef _PGLOBAL 343#define _PGLOBAL 344#endif 345 346#ifndef _AGLOBAL 347#define _AGLOBAL 348#endif 349 350#define _SECURECRT_FILL_BUFFER_PATTERN 0xFD 351#define _CRT_DEPRECATE_TEXT(_Text) __declspec(deprecated) 352 353#ifndef _CRT_INSECURE_DEPRECATE_MEMORY 354#define _CRT_INSECURE_DEPRECATE_MEMORY(_Replacement) 355#endif 356 357#ifndef _CRT_INSECURE_DEPRECATE_GLOBALS 358#define _CRT_INSECURE_DEPRECATE_GLOBALS(_Replacement) 359#endif 360 361#ifndef _CRT_MANAGED_HEAP_DEPRECATE 362#define _CRT_MANAGED_HEAP_DEPRECATE 363#endif 364 365#ifndef _CRT_OBSOLETE 366#define _CRT_OBSOLETE(_NewItem) 367#endif 368 369#ifndef __WIDL__ 370 371#if defined (_WIN32) && !defined (_WIN64) && !defined (__MINGW_USE_VC2005_COMPAT) 372#ifndef _USE_32BIT_TIME_T 373#define _USE_32BIT_TIME_T 374#endif 375#endif 376 377#ifndef _CONST_RETURN 378#define _CONST_RETURN 379#endif 380 381#ifndef UNALIGNED 382#if defined(_M_IA64) || defined(_M_AMD64) 383#define UNALIGNED __unaligned 384#else 385#define UNALIGNED 386#endif 387#endif /* UNALIGNED */ 388 389#ifndef _CRT_ALIGN 390#ifdef _MSC_VER 391#define _CRT_ALIGN(x) __declspec(align(x)) 392#else /* __GNUC__ */ 393#define _CRT_ALIGN(x) __attribute__ ((__aligned__ (x))) 394#endif 395#endif /* _CRT_ALIGN */ 396 397#endif /* __WIDL__ */ 398 399#ifndef __CRTDECL 400#define __CRTDECL __cdecl 401#endif 402 403#define _ARGMAX 100 404 405#ifndef _TRUNCATE 406#define _TRUNCATE ((size_t)-1) 407#endif 408 409#ifndef _CRT_UNUSED 410#define _CRT_UNUSED(x) (void)x 411#endif 412 413/* MSVC defines _NATIVE_NULLPTR_SUPPORTED when nullptr is supported. We emulate it here for GCC. */ 414#if __MINGW_GNUC_PREREQ(4, 6) 415#if defined(__GNUC__) && (defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L) 416#define _NATIVE_NULLPTR_SUPPORTED 417#endif 418#endif 419 420/* We are activating __USE_MINGW_ANSI_STDIO for various define indicators. 421 Note that we enable it also for _GNU_SOURCE in C++, but not for C case. */ 422#if (defined (_POSIX) || defined (_POSIX_SOURCE) || defined (_POSIX_C_SOURCE) \ 423 || defined (_ISOC99_SOURCE) \ 424 || defined (_XOPEN_SOURCE) || defined (_XOPEN_SOURCE_EXTENDED) \ 425 || (defined (_GNU_SOURCE) && defined (__cplusplus)) \ 426 || defined (_SVID_SOURCE)) \ 427 && !defined(__USE_MINGW_ANSI_STDIO) 428/* Enable __USE_MINGW_ANSI_STDIO if _POSIX defined 429 * and If user did _not_ specify it explicitly... */ 430# define __USE_MINGW_ANSI_STDIO 1 431#endif 432 433/* We are defining __USE_MINGW_ANSI_STDIO as 0 or 1 */ 434#if !defined(__USE_MINGW_ANSI_STDIO) 435#define __USE_MINGW_ANSI_STDIO 0 /* was not defined so it should be 0 */ 436#elif (__USE_MINGW_ANSI_STDIO + 0) != 0 || (1 - __USE_MINGW_ANSI_STDIO - 1) == 2 437#define __USE_MINGW_ANSI_STDIO 1 /* was defined as nonzero or empty so it should be 1 */ 438#else 439#define __USE_MINGW_ANSI_STDIO 0 /* was defined as (int)zero and non-empty so it should be 0 */ 440#endif 441 442/* _dowildcard is an int that controls the globbing of the command line. 443 * The MinGW32 (mingw.org) runtime calls it _CRT_glob, so we are adding 444 * a compatibility definition here: you can use either of _CRT_glob or 445 * _dowildcard . 446 * If _dowildcard is non-zero, the command line will be globbed: *.* 447 * will be expanded to be all files in the startup directory. 448 * In the mingw-w64 library a _dowildcard variable is defined as being 449 * 0, therefore command line globbing is DISABLED by default. To turn it 450 * on and to leave wildcard command line processing MS's globbing code, 451 * include a line in one of your source modules defining _dowildcard and 452 * setting it to -1, like so: 453 * int _dowildcard = -1; 454 */ 455#undef _CRT_glob 456#define _CRT_glob _dowildcard 457 458 459#if defined(_MSC_VER) && !defined(_MSC_EXTENSIONS) 460#define NONAMELESSUNION 1 461#endif 462#if defined(NONAMELESSSTRUCT) && \ 463 !defined(NONAMELESSUNION) 464#define NONAMELESSUNION 1 465#endif 466#if defined(NONAMELESSUNION) && \ 467 !defined(NONAMELESSSTRUCT) 468#define NONAMELESSSTRUCT 1 469#endif 470 471#ifndef __ANONYMOUS_DEFINED 472#define __ANONYMOUS_DEFINED 473#define _ANONYMOUS_UNION __MINGW_EXTENSION 474#define _ANONYMOUS_STRUCT __MINGW_EXTENSION 475#ifndef NONAMELESSUNION 476#define _UNION_NAME(x) 477#define _STRUCT_NAME(x) 478#else /* NONAMELESSUNION */ 479#define _UNION_NAME(x) x 480#define _STRUCT_NAME(x) x 481#endif 482#endif /* __ANONYMOUS_DEFINED */ 483 484#ifndef DUMMYUNIONNAME 485# ifdef NONAMELESSUNION 486# define DUMMYUNIONNAME u 487# define DUMMYUNIONNAME1 u1 /* Wine uses this variant */ 488# define DUMMYUNIONNAME2 u2 489# define DUMMYUNIONNAME3 u3 490# define DUMMYUNIONNAME4 u4 491# define DUMMYUNIONNAME5 u5 492# define DUMMYUNIONNAME6 u6 493# define DUMMYUNIONNAME7 u7 494# define DUMMYUNIONNAME8 u8 495# define DUMMYUNIONNAME9 u9 496# else /* NONAMELESSUNION */ 497# define DUMMYUNIONNAME 498# define DUMMYUNIONNAME1 /* Wine uses this variant */ 499# define DUMMYUNIONNAME2 500# define DUMMYUNIONNAME3 501# define DUMMYUNIONNAME4 502# define DUMMYUNIONNAME5 503# define DUMMYUNIONNAME6 504# define DUMMYUNIONNAME7 505# define DUMMYUNIONNAME8 506# define DUMMYUNIONNAME9 507# endif 508#endif /* DUMMYUNIONNAME */ 509 510#ifndef DUMMYSTRUCTNAME 511# ifdef NONAMELESSUNION 512# define DUMMYSTRUCTNAME s 513# define DUMMYSTRUCTNAME1 s1 /* Wine uses this variant */ 514# define DUMMYSTRUCTNAME2 s2 515# define DUMMYSTRUCTNAME3 s3 516# define DUMMYSTRUCTNAME4 s4 517# define DUMMYSTRUCTNAME5 s5 518# else 519# define DUMMYSTRUCTNAME 520# define DUMMYSTRUCTNAME1 /* Wine uses this variant */ 521# define DUMMYSTRUCTNAME2 522# define DUMMYSTRUCTNAME3 523# define DUMMYSTRUCTNAME4 524# define DUMMYSTRUCTNAME5 525# endif 526#endif /* DUMMYSTRUCTNAME */ 527 528 529/* Macros for __uuidof template-based emulation */ 530#if defined(__cplusplus) && (USE___UUIDOF == 0) 531 532#if __cpp_constexpr >= 200704l && __cpp_inline_variables >= 201606L 533#define __CRT_UUID_DECL(type,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \ 534 extern "C++" { \ 535 template<> struct __mingw_uuidof_s<type> { \ 536 static constexpr IID __uuid_inst = { \ 537 l,w1,w2, {b1,b2,b3,b4,b5,b6,b7,b8} \ 538 }; \ 539 }; \ 540 template<> constexpr const GUID &__mingw_uuidof<type>() { \ 541 return __mingw_uuidof_s<type>::__uuid_inst; \ 542 } \ 543 template<> constexpr const GUID &__mingw_uuidof<type*>() { \ 544 return __mingw_uuidof_s<type>::__uuid_inst; \ 545 } \ 546 } 547#else 548#define __CRT_UUID_DECL(type,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) \ 549 extern "C++" { \ 550 template<> inline const GUID &__mingw_uuidof<type>() { \ 551 static const IID __uuid_inst = {l,w1,w2, {b1,b2,b3,b4,b5,b6,b7,b8}}; \ 552 return __uuid_inst; \ 553 } \ 554 template<> inline const GUID &__mingw_uuidof<type*>() { \ 555 return __mingw_uuidof<type>(); \ 556 } \ 557 } 558#endif 559 560#define __uuidof(type) __mingw_uuidof<__typeof(type)>() 561 562#else 563 564#define __CRT_UUID_DECL(type,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) 565 566#endif 567 568#ifdef __cplusplus 569extern "C" { 570#endif 571 572 573#ifdef __MINGW_INTRIN_INLINE 574#ifdef __has_builtin 575#define __MINGW_DEBUGBREAK_IMPL !__has_builtin(__debugbreak) 576#else 577#define __MINGW_DEBUGBREAK_IMPL 1 578#endif 579#if __MINGW_DEBUGBREAK_IMPL == 1 580void __cdecl __debugbreak(void); 581__MINGW_INTRIN_INLINE void __cdecl __debugbreak(void) 582{ 583 __asm__ __volatile__("int {$}3":); 584} 585#endif 586#endif 587 588/* mingw-w64 specific functions: */ 589const char *__mingw_get_crt_info (void); 590 591#ifdef __cplusplus 592} 593#endif 594 595#endif /* _INC__MINGW_H */ 596 597#ifndef MINGW_SDK_INIT 598#define MINGW_SDK_INIT 599 600/* for backward compatibility */ 601#ifndef MINGW_HAS_SECURE_API 602#define MINGW_HAS_SECURE_API 1 603#endif 604 605#define __STDC_SECURE_LIB__ 200411L 606#define __GOT_SECURE_LIB__ __STDC_SECURE_LIB__ 607 608#ifndef __WIDL__ 609#include "sdks/_mingw_directx.h" 610#include "sdks/_mingw_ddk.h" 611#endif 612 613#endif /* MINGW_SDK_INIT */ 614