Skip to content

Commit

Permalink
update mingw-w64 headers to latest git commit
Browse files Browse the repository at this point in the history
Upstream commit dddccbc3ef50ac52bf00723fd2f68d98140aab80

Martin Storsjö suggested synchronizing with git snapshots rather than
waiting for tagged releases. Let's try this for a few releases of Zig
and see how we like it.

These headers were configured with `--with-default-msvcrt=ucrt`.

See related issue #18477.
  • Loading branch information
andrewrk committed Jan 8, 2024
1 parent f597818 commit 3c001fb
Show file tree
Hide file tree
Showing 440 changed files with 306,464 additions and 75,832 deletions.
56 changes: 47 additions & 9 deletions lib/libc/include/any-windows-any/_mingw.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,6 @@
#endif

/* C/C++ specific language defines. */
#ifdef _WIN64
#ifdef __stdcall
#undef __stdcall
#endif
#define __stdcall
#endif

#ifndef __GNUC__
# ifndef __MINGW_IMPORT
# define __MINGW_IMPORT __declspec(dllimport)
Expand Down Expand Up @@ -226,7 +219,7 @@ limitations in handling dllimport attribute. */
# elif defined(_UCRT)
# define __MSVCRT_VERSION__ 0xE00
# else
# define __MSVCRT_VERSION__ 0x700
# define __MSVCRT_VERSION__ 0xE00
# endif
#endif

Expand All @@ -236,7 +229,7 @@ limitations in handling dllimport attribute. */
#endif

#ifndef _WIN32_WINNT
#define _WIN32_WINNT 0x0603
#define _WIN32_WINNT 0xa00
#endif

#ifndef _INT128_DEFINED
Expand Down Expand Up @@ -577,6 +570,7 @@ extern "C" {


#ifdef __MINGW_INTRIN_INLINE

#ifdef __has_builtin
#define __MINGW_DEBUGBREAK_IMPL !__has_builtin(__debugbreak)
#else
Expand All @@ -596,8 +590,52 @@ __MINGW_INTRIN_INLINE void __cdecl __debugbreak(void)
__asm__ __volatile__("unimplemented");
#endif
}
#endif /* __MINGW_DEBUGBREAK_IMPL == 1 */

#ifdef __has_builtin
#define __MINGW_FASTFAIL_IMPL !__has_builtin(__fastfail)
#else
#define __MINGW_FASTFAIL_IMPL 1
#endif
#if __MINGW_FASTFAIL_IMPL == 1
void __cdecl __MINGW_ATTRIB_NORETURN __fastfail(unsigned int code);
__MINGW_INTRIN_INLINE void __cdecl __MINGW_ATTRIB_NORETURN __fastfail(unsigned int code)
{
#if defined(__i386__) || defined(__x86_64__)
__asm__ __volatile__("int {$}0x29"::"c"(code));
#elif defined(__arm__)
register unsigned int r0 __asm__("r0") = code;
__asm__ __volatile__("udf #0xfb"::"r"(r0));
#elif defined(__aarch64__)
register unsigned int w0 __asm__("w0") = code;
__asm__ __volatile__("brk #0xf003"::"r"(w0));
#else
__asm__ __volatile__("unimplemented");
#endif
__builtin_unreachable();
}
#endif /* __MINGW_FASTFAIL_IMPL == 1 */

#ifdef __has_builtin
#define __MINGW_PREFETCH_IMPL !__has_builtin(__prefetch)
#else
#define __MINGW_PREFETCH_IMPL 1
#endif
#if __MINGW_PREFETCH_IMPL == 1
#if defined(__arm__) || defined(__aarch64__)
void __cdecl __prefetch(const void *addr);
__MINGW_INTRIN_INLINE void __cdecl __prefetch(const void *addr)
{
#if defined(__arm__)
__asm__ __volatile__("pld [%0]"::"r"(addr));
#elif defined(__aarch64__)
__asm__ __volatile__("prfm pldl1keep, [%0]"::"r"(addr));
#endif
}
#endif /* defined(__arm__) || defined(__aarch64__) */
#endif /* __MINGW_PREFETCH_IMPL == 1 */

#endif /* defined(__MINGW_INTRIN_INLINE) */

/* mingw-w64 specific functions: */
const char *__mingw_get_crt_info (void);
Expand Down
50 changes: 40 additions & 10 deletions lib/libc/include/any-windows-any/_mingw_mac.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#define __MINGW64_STRINGIFY(x) \
__STRINGIFY(x)

#define __MINGW64_VERSION_MAJOR 10
#define __MINGW64_VERSION_MAJOR 12
#define __MINGW64_VERSION_MINOR 0
#define __MINGW64_VERSION_BUGFIX 0

Expand Down Expand Up @@ -294,7 +294,7 @@
# define __mingw_static_ovr __mingw_ovr
#endif /* __cplusplus */

#if __MINGW_GNUC_PREREQ(4, 3) && !defined(__clang__)
#if __MINGW_GNUC_PREREQ(4, 3) || defined(__clang__)
# define __mingw_attribute_artificial \
__attribute__((__artificial__))
#else
Expand All @@ -303,8 +303,23 @@

#define __MINGW_SELECTANY __attribute__((__selectany__))

#pragma push_macro("__has_builtin")
#ifndef __has_builtin
# define __has_builtin(x) 0
#endif

#if _FORTIFY_SOURCE > 0 && __OPTIMIZE__ > 0 && __MINGW_GNUC_PREREQ(4, 1)
# if _FORTIFY_SOURCE > 1
# if _FORTIFY_SOURCE > 3
# warning Using _FORTIFY_SOURCE=3 (levels > 3 are not supported)
# endif
# if _FORTIFY_SOURCE > 2
# if __has_builtin(__builtin_dynamic_object_size)
# define __MINGW_FORTIFY_LEVEL 3
# else
# warning Using _FORTIFY_SOURCE=2 (level 3 requires __builtin_dynamic_object_size support)
# define __MINGW_FORTIFY_LEVEL 2
# endif
# elif _FORTIFY_SOURCE > 1
# define __MINGW_FORTIFY_LEVEL 2
# else
# define __MINGW_FORTIFY_LEVEL 1
Expand All @@ -322,16 +337,26 @@
void __cdecl __mingw_chk_fail_warn(void) __MINGW_ASM_CALL(__chk_fail) \
__attribute__((__noreturn__)) \
__attribute__((__warning__("Buffer overflow detected")))
# define __mingw_bos(p, maxtype) \
__builtin_object_size((p), ((maxtype) > 0) && (__MINGW_FORTIFY_LEVEL > 1))
# define __mingw_bos_known(p) \
(__mingw_bos(p, 0) != (size_t)-1)
# if __MINGW_FORTIFY_LEVEL > 2
# define __mingw_bos(p, maxtype) \
__builtin_dynamic_object_size((p), (maxtype) > 0)
# define __mingw_bos_known(p) \
(__builtin_object_size(p, 0) != (size_t)-1 \
|| !__builtin_constant_p(__mingw_bos(p, 0)))
# else
# define __mingw_bos(p, maxtype) \
__builtin_object_size((p), ((maxtype) > 0) && (__MINGW_FORTIFY_LEVEL > 1))
# define __mingw_bos_known(p) \
(__mingw_bos(p, 0) != (size_t)-1)
# endif
# define __mingw_bos_cond_chk(c) \
(__builtin_expect((c), 1) ? (void)0 : __chk_fail())
# define __mingw_bos_ptr_chk(p, n, maxtype) \
__mingw_bos_cond_chk(!__mingw_bos_known(p) || __mingw_bos(p, maxtype) >= (size_t)(n))
# define __mingw_bos_ptr_chk_warn(p, n, maxtype) \
(__mingw_bos_known(p) && __builtin_constant_p((n)) && __mingw_bos(p, maxtype) < (size_t)(n) \
((__mingw_bos_known(p) \
&& __builtin_constant_p(__mingw_bos(p, maxtype) < (size_t)(n)) \
&& __mingw_bos(p, maxtype) < (size_t)(n)) \
? __mingw_chk_fail_warn() : __mingw_bos_ptr_chk(p, n, maxtype))
# define __mingw_bos_ovr __mingw_ovr \
__attribute__((__always_inline__)) \
Expand All @@ -345,14 +370,19 @@

/* If _FORTIFY_SOURCE is enabled, some inline functions may use
__builtin_va_arg_pack(). GCC may report an error if the address
of such a function is used. Set _FORTIFY_VA_ARG=0 in this case. */
#if __MINGW_FORTIFY_LEVEL > 0 && __MINGW_GNUC_PREREQ(4, 3) && !defined(__clang__) \
of such a function is used. Set _FORTIFY_VA_ARG=0 in this case.
Clang doesn't, as of version 15, yet implement __builtin_va_arg_pack(). */
#if __MINGW_FORTIFY_LEVEL > 0 \
&& ((__MINGW_GNUC_PREREQ(4, 3) && !defined(__clang__)) \
|| __has_builtin(__builtin_va_arg_pack)) \
&& (!defined(_FORTIFY_VA_ARG) || _FORTIFY_VA_ARG > 0)
# define __MINGW_FORTIFY_VA_ARG 1
#else
# define __MINGW_FORTIFY_VA_ARG 0
#endif

#pragma pop_macro("__has_builtin")

/* Enable workaround for ABI incompatibility on affected platforms */
#ifndef WIDL_EXPLICIT_AGGREGATE_RETURNS
#if defined(__GNUC__) && defined(__cplusplus)
Expand Down
24 changes: 16 additions & 8 deletions lib/libc/include/any-windows-any/activation.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*** Autogenerated by WIDL 7.0 from include/activation.idl - Do not edit ***/
/*** Autogenerated by WIDL 8.21 from include/activation.idl - Do not edit ***/

#ifdef _WIN32
#ifndef __REQUIRED_RPCNDR_H_VERSION__
Expand All @@ -16,6 +16,14 @@
#ifndef __activation_h__
#define __activation_h__

#ifndef __WIDL_INLINE
#if defined(__cplusplus) || defined(_MSC_VER)
#define __WIDL_INLINE inline
#elif defined(__GNUC__)
#define __WIDL_INLINE __inline__
#endif
#endif

/* Forward declarations */

#ifndef __IActivationFactory_FWD_DEFINED__
Expand Down Expand Up @@ -108,27 +116,27 @@ interface IActivationFactory {
#define IActivationFactory_ActivateInstance(This,instance) (This)->lpVtbl->ActivateInstance(This,instance)
#else
/*** IUnknown methods ***/
static FORCEINLINE HRESULT IActivationFactory_QueryInterface(IActivationFactory* This,REFIID riid,void **ppvObject) {
static __WIDL_INLINE HRESULT IActivationFactory_QueryInterface(IActivationFactory* This,REFIID riid,void **ppvObject) {
return This->lpVtbl->QueryInterface(This,riid,ppvObject);
}
static FORCEINLINE ULONG IActivationFactory_AddRef(IActivationFactory* This) {
static __WIDL_INLINE ULONG IActivationFactory_AddRef(IActivationFactory* This) {
return This->lpVtbl->AddRef(This);
}
static FORCEINLINE ULONG IActivationFactory_Release(IActivationFactory* This) {
static __WIDL_INLINE ULONG IActivationFactory_Release(IActivationFactory* This) {
return This->lpVtbl->Release(This);
}
/*** IInspectable methods ***/
static FORCEINLINE HRESULT IActivationFactory_GetIids(IActivationFactory* This,ULONG *iidCount,IID **iids) {
static __WIDL_INLINE HRESULT IActivationFactory_GetIids(IActivationFactory* This,ULONG *iidCount,IID **iids) {
return This->lpVtbl->GetIids(This,iidCount,iids);
}
static FORCEINLINE HRESULT IActivationFactory_GetRuntimeClassName(IActivationFactory* This,HSTRING *className) {
static __WIDL_INLINE HRESULT IActivationFactory_GetRuntimeClassName(IActivationFactory* This,HSTRING *className) {
return This->lpVtbl->GetRuntimeClassName(This,className);
}
static FORCEINLINE HRESULT IActivationFactory_GetTrustLevel(IActivationFactory* This,TrustLevel *trustLevel) {
static __WIDL_INLINE HRESULT IActivationFactory_GetTrustLevel(IActivationFactory* This,TrustLevel *trustLevel) {
return This->lpVtbl->GetTrustLevel(This,trustLevel);
}
/*** IActivationFactory methods ***/
static FORCEINLINE HRESULT IActivationFactory_ActivateInstance(IActivationFactory* This,IInspectable **instance) {
static __WIDL_INLINE HRESULT IActivationFactory_ActivateInstance(IActivationFactory* This,IInspectable **instance) {
return This->lpVtbl->ActivateInstance(This,instance);
}
#endif
Expand Down
Loading

0 comments on commit 3c001fb

Please sign in to comment.