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