_mingw_mac.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  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. #ifndef _INC_CRTDEFS_MACRO
  7. #define _INC_CRTDEFS_MACRO
  8. #define __STRINGIFY(x) #x
  9. #define __MINGW64_STRINGIFY(x) \
  10. __STRINGIFY(x)
  11. #define __MINGW64_VERSION_MAJOR 11
  12. #define __MINGW64_VERSION_MINOR 0
  13. #define __MINGW64_VERSION_BUGFIX 0
  14. /* This macro holds an monotonic increasing value, which indicates
  15. a specific fix/patch is present on trunk. This value isn't related to
  16. minor/major version-macros. It is increased on demand, if a big
  17. fix was applied to trunk. This macro gets just increased on trunk. For
  18. other branches its value won't be modified. */
  19. #define __MINGW64_VERSION_RC 0
  20. #define __MINGW64_VERSION_STR \
  21. __MINGW64_STRINGIFY(__MINGW64_VERSION_MAJOR) \
  22. "." \
  23. __MINGW64_STRINGIFY(__MINGW64_VERSION_MINOR) \
  24. "." \
  25. __MINGW64_STRINGIFY(__MINGW64_VERSION_BUGFIX)
  26. #define __MINGW64_VERSION_STATE "alpha"
  27. /* mingw.org's version macros: these make gcc to define
  28. MINGW32_SUPPORTS_MT_EH and to use the _CRT_MT global
  29. and the __mingwthr_key_dtor() function from the MinGW
  30. CRT in its private gthr-win32.h header. */
  31. #define __MINGW32_MAJOR_VERSION 3
  32. #define __MINGW32_MINOR_VERSION 11
  33. /* Set VC specific compiler target macros. */
  34. #if defined(__x86_64) && defined(_X86_)
  35. # undef _X86_ /* _X86_ is not for __x86_64 */
  36. #endif
  37. #if defined(_X86_) && !defined(_M_IX86) && !defined(_M_IA64) \
  38. && !defined(_M_AMD64) && !defined(__x86_64)
  39. # if defined(__i486__)
  40. # define _M_IX86 400
  41. # elif defined(__i586__)
  42. # define _M_IX86 500
  43. # elif defined(__i686__)
  44. # define _M_IX86 600
  45. # else
  46. # define _M_IX86 300
  47. # endif
  48. #endif /* if defined(_X86_) && !defined(_M_IX86) && !defined(_M_IA64) ... */
  49. #if defined(__x86_64) && !defined(_M_IX86) && !defined(_M_IA64) \
  50. && !defined(_M_AMD64)
  51. # define _M_AMD64 100
  52. # define _M_X64 100
  53. #endif
  54. #if defined(__ia64__) && !defined(_M_IX86) && !defined(_M_IA64) \
  55. && !defined(_M_AMD64) && !defined(_X86_) && !defined(__x86_64)
  56. # define _M_IA64 100
  57. #endif
  58. #if defined(__arm__) && !defined(_M_ARM) && !defined(_M_ARMT) \
  59. && !defined(_M_THUMB)
  60. # define _M_ARM 100
  61. # define _M_ARMT 100
  62. # define _M_THUMB 100
  63. # ifndef _ARM_
  64. # define _ARM_ 1
  65. # endif
  66. # ifndef _M_ARM_NT
  67. # define _M_ARM_NT 1
  68. # endif
  69. #endif
  70. #if defined(__aarch64__) && !defined(_M_ARM64)
  71. # define _M_ARM64 1
  72. # ifndef _ARM64_
  73. # define _ARM64_ 1
  74. # endif
  75. #endif
  76. #ifndef _X86_
  77. /* MS does not prefix symbols by underscores for 64-bit. */
  78. # ifndef __MINGW_USE_UNDERSCORE_PREFIX
  79. /* As we have to support older gcc version, which are using underscores
  80. as symbol prefix for x64, we have to check here for the user label
  81. prefix defined by gcc. */
  82. # ifdef __USER_LABEL_PREFIX__
  83. # pragma push_macro ("_")
  84. # undef _
  85. # define _ 1
  86. # if (__USER_LABEL_PREFIX__ + 0) != 0
  87. # define __MINGW_USE_UNDERSCORE_PREFIX 1
  88. # else
  89. # define __MINGW_USE_UNDERSCORE_PREFIX 0
  90. # endif
  91. # undef _
  92. # pragma pop_macro ("_")
  93. # else /* ! __USER_LABEL_PREFIX__ */
  94. # define __MINGW_USE_UNDERSCORE_PREFIX 0
  95. # endif /* __USER_LABEL_PREFIX__ */
  96. # endif
  97. #else /* ! ifndef _X86_ */
  98. /* For x86 we have always to prefix by underscore. */
  99. # undef __MINGW_USE_UNDERSCORE_PREFIX
  100. # define __MINGW_USE_UNDERSCORE_PREFIX 1
  101. #endif /* ifndef _X86_ */
  102. #if __MINGW_USE_UNDERSCORE_PREFIX == 0
  103. # define __MINGW_IMP_SYMBOL(sym) __imp_##sym
  104. # define __MINGW_IMP_LSYMBOL(sym) __imp_##sym
  105. # define __MINGW_USYMBOL(sym) sym
  106. # define __MINGW_LSYMBOL(sym) _##sym
  107. #else /* ! if __MINGW_USE_UNDERSCORE_PREFIX == 0 */
  108. # define __MINGW_IMP_SYMBOL(sym) _imp__##sym
  109. # define __MINGW_IMP_LSYMBOL(sym) __imp__##sym
  110. # define __MINGW_USYMBOL(sym) _##sym
  111. # define __MINGW_LSYMBOL(sym) sym
  112. #endif /* if __MINGW_USE_UNDERSCORE_PREFIX == 0 */
  113. #define __MINGW_ASM_CALL(func) __asm__(__MINGW64_STRINGIFY(__MINGW_USYMBOL(func)))
  114. #define __MINGW_ASM_CRT_CALL(func) __asm__(__STRINGIFY(func))
  115. #ifndef __PTRDIFF_TYPE__
  116. # ifdef _WIN64
  117. # define __PTRDIFF_TYPE__ long long int
  118. # else
  119. # define __PTRDIFF_TYPE__ long int
  120. # endif
  121. #endif
  122. #ifndef __SIZE_TYPE__
  123. # ifdef _WIN64
  124. # define __SIZE_TYPE__ long long unsigned int
  125. # else
  126. # define __SIZE_TYPE__ long unsigned int
  127. # endif
  128. #endif
  129. #ifndef __WCHAR_TYPE__
  130. # define __WCHAR_TYPE__ unsigned short
  131. #endif
  132. #ifndef __WINT_TYPE__
  133. # define __WINT_TYPE__ unsigned short
  134. #endif
  135. #undef __MINGW_EXTENSION
  136. #ifdef __WIDL__
  137. # define __MINGW_EXTENSION
  138. #else
  139. # if defined(__GNUC__) || defined(__GNUG__)
  140. # define __MINGW_EXTENSION __extension__
  141. # else
  142. # define __MINGW_EXTENSION
  143. # endif
  144. #endif /* __WIDL__ */
  145. /* Special case nameless struct/union. */
  146. #ifndef __C89_NAMELESS
  147. # define __C89_NAMELESS __MINGW_EXTENSION
  148. # define __C89_NAMELESSSTRUCTNAME
  149. # define __C89_NAMELESSSTRUCTNAME1
  150. # define __C89_NAMELESSSTRUCTNAME2
  151. # define __C89_NAMELESSSTRUCTNAME3
  152. # define __C89_NAMELESSSTRUCTNAME4
  153. # define __C89_NAMELESSSTRUCTNAME5
  154. # define __C89_NAMELESSUNIONNAME
  155. # define __C89_NAMELESSUNIONNAME1
  156. # define __C89_NAMELESSUNIONNAME2
  157. # define __C89_NAMELESSUNIONNAME3
  158. # define __C89_NAMELESSUNIONNAME4
  159. # define __C89_NAMELESSUNIONNAME5
  160. # define __C89_NAMELESSUNIONNAME6
  161. # define __C89_NAMELESSUNIONNAME7
  162. # define __C89_NAMELESSUNIONNAME8
  163. #endif
  164. #ifndef __GNU_EXTENSION
  165. # define __GNU_EXTENSION __MINGW_EXTENSION
  166. #endif
  167. /* MinGW-w64 has some additional C99 printf/scanf feature support.
  168. So we add some helper macros to ease recognition of them. */
  169. #define __MINGW_HAVE_ANSI_C99_PRINTF 1
  170. #define __MINGW_HAVE_WIDE_C99_PRINTF 1
  171. #define __MINGW_HAVE_ANSI_C99_SCANF 1
  172. #define __MINGW_HAVE_WIDE_C99_SCANF 1
  173. #ifdef __MINGW_USE_BROKEN_INTERFACE
  174. # define __MINGW_POISON_NAME(__IFACE) __IFACE
  175. #else
  176. # define __MINGW_POISON_NAME(__IFACE) \
  177. __IFACE##_layout_has_not_been_verified_and_its_declaration_is_most_likely_incorrect
  178. #endif
  179. #ifndef __MSABI_LONG
  180. # ifndef __LP64__
  181. # define __MSABI_LONG(x) x ## l
  182. # else
  183. # define __MSABI_LONG(x) x
  184. # endif
  185. #endif
  186. #if __GNUC__
  187. # define __MINGW_GCC_VERSION (__GNUC__ * 10000 + \
  188. __GNUC_MINOR__ * 100 + \
  189. __GNUC_PATCHLEVEL__)
  190. #else
  191. # define __MINGW_GCC_VERSION 0
  192. #endif
  193. #if defined (__GNUC__) && defined (__GNUC_MINOR__)
  194. # define __MINGW_GNUC_PREREQ(major, minor) \
  195. (__GNUC__ > (major) \
  196. || (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor)))
  197. #else
  198. # define __MINGW_GNUC_PREREQ(major, minor) 0
  199. #endif
  200. #if defined (_MSC_VER)
  201. # define __MINGW_MSC_PREREQ(major, minor) \
  202. (_MSC_VER >= (major * 100 + minor * 10))
  203. #else
  204. # define __MINGW_MSC_PREREQ(major, minor) 0
  205. #endif
  206. #ifdef __MINGW_MSVC_COMPAT_WARNINGS
  207. # if __MINGW_GNUC_PREREQ (4, 5)
  208. # define __MINGW_ATTRIB_DEPRECATED_STR(X) \
  209. __attribute__ ((__deprecated__ (X)))
  210. # else
  211. # define __MINGW_ATTRIB_DEPRECATED_STR(X) \
  212. __MINGW_ATTRIB_DEPRECATED
  213. # endif
  214. #else
  215. # define __MINGW_ATTRIB_DEPRECATED_STR(X)
  216. #endif /* ifdef __MINGW_MSVC_COMPAT_WARNINGS */
  217. #define __MINGW_SEC_WARN_STR \
  218. "This function or variable may be unsafe, use _CRT_SECURE_NO_WARNINGS to disable deprecation"
  219. #define __MINGW_MSVC2005_DEPREC_STR \
  220. "This POSIX function is deprecated beginning in Visual C++ 2005, use _CRT_NONSTDC_NO_DEPRECATE to disable deprecation"
  221. #if !defined (_CRT_NONSTDC_NO_DEPRECATE)
  222. # define __MINGW_ATTRIB_DEPRECATED_MSVC2005 \
  223. __MINGW_ATTRIB_DEPRECATED_STR(__MINGW_MSVC2005_DEPREC_STR)
  224. #else
  225. # define __MINGW_ATTRIB_DEPRECATED_MSVC2005
  226. #endif
  227. #if !defined (_CRT_SECURE_NO_WARNINGS) || (_CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES == 0)
  228. # define __MINGW_ATTRIB_DEPRECATED_SEC_WARN \
  229. __MINGW_ATTRIB_DEPRECATED_STR(__MINGW_SEC_WARN_STR)
  230. #else
  231. # define __MINGW_ATTRIB_DEPRECATED_SEC_WARN
  232. #endif
  233. #define __MINGW_MS_PRINTF(__format,__args) \
  234. __attribute__((__format__(ms_printf, __format,__args)))
  235. #define __MINGW_MS_SCANF(__format,__args) \
  236. __attribute__((__format__(ms_scanf, __format,__args)))
  237. #define __MINGW_GNU_PRINTF(__format,__args) \
  238. __attribute__((__format__(gnu_printf,__format,__args)))
  239. #define __MINGW_GNU_SCANF(__format,__args) \
  240. __attribute__((__format__(gnu_scanf, __format,__args)))
  241. #undef __mingw_ovr
  242. #undef __mingw_static_ovr
  243. #ifdef __cplusplus
  244. # define __mingw_ovr inline __cdecl
  245. # define __mingw_static_ovr static __mingw_ovr
  246. #elif defined (__GNUC__)
  247. # define __mingw_ovr static \
  248. __attribute__ ((__unused__)) __inline__ __cdecl
  249. # define __mingw_static_ovr __mingw_ovr
  250. #else
  251. # define __mingw_ovr static __cdecl
  252. # define __mingw_static_ovr __mingw_ovr
  253. #endif /* __cplusplus */
  254. #if __MINGW_GNUC_PREREQ(4, 3) && !defined(__clang__)
  255. # define __mingw_attribute_artificial \
  256. __attribute__((__artificial__))
  257. #else
  258. # define __mingw_attribute_artificial
  259. #endif
  260. #define __MINGW_SELECTANY __attribute__((__selectany__))
  261. #if _FORTIFY_SOURCE > 0 && __OPTIMIZE__ > 0 && __MINGW_GNUC_PREREQ(4, 1)
  262. # if _FORTIFY_SOURCE > 1
  263. # define __MINGW_FORTIFY_LEVEL 2
  264. # else
  265. # define __MINGW_FORTIFY_LEVEL 1
  266. # endif
  267. #else
  268. # define __MINGW_FORTIFY_LEVEL 0
  269. #endif
  270. #if __MINGW_FORTIFY_LEVEL > 0
  271. /* Calling an function with __attribute__((__warning__("...")))
  272. from a system include __inline__ function does not print
  273. a warning unless caller has __attribute__((__artificial__)). */
  274. # define __mingw_bos_declare \
  275. void __cdecl __chk_fail(void) __attribute__((__noreturn__)); \
  276. void __cdecl __mingw_chk_fail_warn(void) __MINGW_ASM_CALL(__chk_fail) \
  277. __attribute__((__noreturn__)) \
  278. __attribute__((__warning__("Buffer overflow detected")))
  279. # define __mingw_bos(p, maxtype) \
  280. __builtin_object_size((p), ((maxtype) > 0) && (__MINGW_FORTIFY_LEVEL > 1))
  281. # define __mingw_bos_known(p) \
  282. (__mingw_bos(p, 0) != (size_t)-1)
  283. # define __mingw_bos_cond_chk(c) \
  284. (__builtin_expect((c), 1) ? (void)0 : __chk_fail())
  285. # define __mingw_bos_ptr_chk(p, n, maxtype) \
  286. __mingw_bos_cond_chk(!__mingw_bos_known(p) || __mingw_bos(p, maxtype) >= (size_t)(n))
  287. # define __mingw_bos_ptr_chk_warn(p, n, maxtype) \
  288. (__mingw_bos_known(p) && __builtin_constant_p((n)) && __mingw_bos(p, maxtype) < (size_t)(n) \
  289. ? __mingw_chk_fail_warn() : __mingw_bos_ptr_chk(p, n, maxtype))
  290. # define __mingw_bos_ovr __mingw_ovr \
  291. __attribute__((__always_inline__)) \
  292. __mingw_attribute_artificial
  293. # define __mingw_bos_extern_ovr extern __inline__ __cdecl \
  294. __attribute__((__always_inline__, __gnu_inline__)) \
  295. __mingw_attribute_artificial
  296. #else
  297. # define __mingw_bos_ovr __mingw_ovr
  298. #endif /* __MINGW_FORTIFY_LEVEL > 0 */
  299. /* If _FORTIFY_SOURCE is enabled, some inline functions may use
  300. __builtin_va_arg_pack(). GCC may report an error if the address
  301. of such a function is used. Set _FORTIFY_VA_ARG=0 in this case. */
  302. #if __MINGW_FORTIFY_LEVEL > 0 && __MINGW_GNUC_PREREQ(4, 3) && !defined(__clang__) \
  303. && (!defined(_FORTIFY_VA_ARG) || _FORTIFY_VA_ARG > 0)
  304. # define __MINGW_FORTIFY_VA_ARG 1
  305. #else
  306. # define __MINGW_FORTIFY_VA_ARG 0
  307. #endif
  308. /* Enable workaround for ABI incompatibility on affected platforms */
  309. #ifndef WIDL_EXPLICIT_AGGREGATE_RETURNS
  310. #if defined(__GNUC__) && defined(__cplusplus)
  311. #define WIDL_EXPLICIT_AGGREGATE_RETURNS
  312. #endif
  313. #endif
  314. #endif /* _INC_CRTDEFS_MACRO */