From: Billy Laws <blaw...@gmail.com>

ARM64EC defines x86_64 identification macros, but its actual intrinsics are aarch64-based. Since this differs from what x86_64 code expects, MSVC additionally provides softintrin.h (and softintrin.lib),
which act as wrappers to offer x86_64 variants of the intrinsics.

Signed-off-by: Jacek Caban <ja...@codeweavers.com>
---
 mingw-w64-headers/crt/intrin.h                | 20 +++++++-------
 .../include/psdk_inc/intrin-impl.h            | 27 +++++++++----------
 mingw-w64-headers/include/winnt.h             | 12 ++++-----
 3 files changed, 29 insertions(+), 30 deletions(-)

diff --git a/mingw-w64-headers/crt/intrin.h b/mingw-w64-headers/crt/intrin.h
index ebd604d88..041c20e54 100644
--- a/mingw-w64-headers/crt/intrin.h
+++ b/mingw-w64-headers/crt/intrin.h
@@ -55,7 +55,7 @@
 #endif
 
 #if defined(__GNUC__) && \
-   (defined(__i386__) || defined(__x86_64__))
+   (defined(__i386__) || (defined(__x86_64__) && !defined(__arm64ec__)))
 #ifndef _MM_MALLOC_H_INCLUDED
 #include <stdlib.h>
 #include <errno.h>
@@ -103,7 +103,7 @@ typedef union __m128i { char v[16]; } __m128i;
 #endif
 #endif
 
-#if (defined(_X86_) || defined(__x86_64))
+#if (defined(_X86_) || (defined(__x86_64) && !defined(__arm64ec__)))
 
 #if defined(__MMX__) || defined(__MINGW_FORCE_SYS_INTRINS)
 #if defined(__cplusplus)
@@ -177,7 +177,7 @@ extern "C" {
 #define __MACHINEIA32 __MACHINEZ
 #endif
 
-#if !(defined(_X86_) || defined(__x86_64) || defined(__ia64__))
+#if !(defined(_X86_) || defined(__x86_64) || defined(__ia64__)) || defined(__arm64ec__)
 #undef __MACHINEIW64
 #define __MACHINEIW64 __MACHINEZ
 #endif
@@ -187,17 +187,17 @@ extern "C" {
 #define __MACHINEIA64 __MACHINEZ
 #endif
 
-#if !(defined(__ia64__) || defined(__x86_64))
+#if !(defined(__ia64__) || defined(__x86_64)) || defined(__arm64ec__)
 #undef __MACHINEW64
 #define __MACHINEW64 __MACHINEZ
 #endif
 
-#if !(defined(_X86_) || defined(__x86_64))
+#if !(defined(_X86_) || defined(__x86_64)) || defined(__arm64ec__)
 #undef __MACHINEI
 #define __MACHINEI __MACHINEZ
 #endif
 
-#if !(defined(_X86_) || defined(__x86_64))
+#if !(defined(_X86_) || defined(__x86_64)) || defined(__arm64ec__)
 #undef __MACHINEX86X
 #define __MACHINEX86X __MACHINEZ
 #endif
@@ -207,7 +207,7 @@ extern "C" {
 #define __MACHINEX86X_NOX64 __MACHINEZ
 #endif
 
-#if !(defined(_X86_) || defined(__x86_64)) || defined(__ia64__)
+#if !(defined(_X86_) || defined(__x86_64)) || defined(__ia64__) || defined(__arm64ec__)
 #undef __MACHINEX86X_NOIA64
 #define __MACHINEX86X_NOIA64 __MACHINEZ
 #endif
@@ -228,17 +228,17 @@ extern "C" {
 #define __MACHINECC __MACHINEZ
 #endif
 
-#if !(defined(__aarch64__))
+#if !(defined(__aarch64__) || defined(__arm64ec__))
 #undef __MACHINEARM64
 #define __MACHINEARM64 __MACHINEZ
 #endif
 
-#if !(defined(__arm__) || defined(__aarch64__))
+#if !(defined(__arm__) || defined(__aarch64__) || defined(__arm64ec__))
 #undef __MACHINEARM_ARM64
 #define __MACHINEARM_ARM64 __MACHINEZ
 #endif
 
-#if !(defined(__x86_64))
+#if !(defined(__x86_64)) || defined(__arm64ec__)
 #undef __MACHINEX64
 #define __MACHINEX64 __MACHINEZ
 #endif
diff --git a/mingw-w64-headers/include/psdk_inc/intrin-impl.h b/mingw-w64-headers/include/psdk_inc/intrin-impl.h
index 872246a44..e109c15d0 100644
--- a/mingw-w64-headers/include/psdk_inc/intrin-impl.h
+++ b/mingw-w64-headers/include/psdk_inc/intrin-impl.h
@@ -134,7 +134,7 @@ __INTRINSICS_USEINLINE
    FunctionName: Any valid function name
    DataType: __LONG32 or __int64
    OffsetConstraint: either "I" for 32bit data types or "J" for 64. */
-#if defined(__x86_64__) || defined(_AMD64_) || defined(__i386__) || defined(_X86_)
+#if (defined(__x86_64__) && !defined(__arm64ec__)) || (defined(_AMD64_) && !defined(_ARM64EC_)) || defined(__i386__) || defined(_X86_)
 #define __buildbittesti(x, y, z, a) unsigned char x(y volatile *Base, y Offset) \
 { \
    unsigned char old; \
@@ -162,7 +162,7 @@ __INTRINSICS_USEINLINE
       : "memory", "cc"); \
    return (old >> Offset) & 1; \
 }
-#elif defined(__aarch64__) || defined(_ARM64_)
+#elif defined(__aarch64__) || defined(_ARM64_) || defined(__arm64ec__) || defined(_ARM64EC_)
 #define __buildbittesti(x, y, z, a) unsigned char x(y volatile *Base, y Offset) \
 { \
    unsigned int old, tmp1, tmp2; \
@@ -198,7 +198,7 @@ __INTRINSICS_USEINLINE
       : "memory", "cc"); \
    return (old >> Offset) & 1; \
 }
-#endif /* defined(__x86_64__) || defined(_AMD64_) || defined(__i386__) || defined(_X86_) */
+#endif /* (defined(__x86_64__) && !defined(__arm64ec__)) || (defined(_AMD64_) && !defined(_ARM64EC_)) || defined(__i386__) || defined(_X86_) */
 
 /* This macro is used by YieldProcessor when compiling x86 w/o SSE2.
 It generates the same opcodes as _mm_pause.  */
@@ -668,8 +668,7 @@ unsigned short _rotr16(unsigned short __X, unsigned char __C)
 #define __INTRINSIC_DEFINED__rotr16
 #endif /* __INTRINSIC_PROLOG */
 
-#if defined(__x86_64__) || defined(_AMD64_)
-
+#if (defined(__x86_64__) && !defined(__arm64ec__)) || (defined(_AMD64_) && !defined(_ARM64EC_))
 #if __INTRINSIC_PROLOG(__faststorefence)
 void __faststorefence(void);
 #if !__has_builtin(__faststorefence)
@@ -1103,7 +1102,7 @@ unsigned __int64 __shiftright128 (unsigned __int64  LowPart, unsigned __int64 Hi
 #define __INTRINSIC_DEFINED___shiftright128
 #endif /* __INTRINSIC_PROLOG */
 
-#endif /* defined(__x86_64__) || defined(_AMD64_) */
+#endif /* #(defined(__x86_64__) && !defined(__arm64ec__)) || (defined(_AMD64_) && !defined(_ARM64EC_)) */
 
 /* ***************************************************** */
 
@@ -1195,7 +1194,7 @@ unsigned char _BitScanReverse(unsigned __LONG32 *Index, unsigned __LONG32 Mask)
 
 #endif /* defined(__arm__) || defined(_ARM_) */
 
-#if defined(__aarch64__) || defined(_ARM64_)
+#if defined(__aarch64__) || defined(_ARM64_) || defined(__arm64ec__) || defined(_ARM64EC_)
 
 #if __INTRINSIC_PROLOG(_interlockedbittestandset)
 unsigned char _interlockedbittestandset(__LONG32 volatile *a, __LONG32 b);
@@ -1436,9 +1435,9 @@ unsigned char _BitScanReverse64(unsigned __LONG32 *Index, unsigned __int64 Mask)
 #define __INTRINSIC_DEFINED__BitScanReverse64
 #endif /* __INTRINSIC_PROLOG */
 
-#endif /* defined(__aarch64__) || define(_ARM64_) */
+#endif /* defined(__aarch64__) || define(_ARM64_) || defined(__arm64ec__) || defined(_ARM64EC_) */
 
-#if defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_)
+#if defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_) || defined(__arm64ec__) || defined(_ARM64EC_)
 
 #if __INTRINSIC_PROLOG(_bittest)
 unsigned char _bittest(const __LONG32 *__a, __LONG32 __b);
@@ -1494,9 +1493,9 @@ unsigned char _bittestandcomplement(__LONG32 *__a, __LONG32 __b)
 #define __INTRINSIC_DEFINED__bittestandcomplement
 #endif /* __INTRINSIC_PROLOG */
 
-#endif /* defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_) */
+#endif /* defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_) || defined(__arm64ec__) || defined(_ARM64EC_) */
 
-#if defined(__aarch64__) || defined(_ARM64_)
+#if defined(__aarch64__) || defined(_ARM64_) || defined(__arm64ec__) || defined(_ARM64EC_)
 
 #if __INTRINSIC_PROLOG(_bittest64)
 unsigned char _bittest64(const __int64 *__a, __int64 __b);
@@ -1552,7 +1551,7 @@ unsigned char _bittestandcomplement64(__int64 *__a, __int64 __b)
 #define __INTRINSIC_DEFINED__bittestandcomplement64
 #endif /* __INTRINSIC_PROLOG */
 
-#endif /* defined(__aarch64__) || define(_ARM64_) */
+#endif /* defined(__aarch64__) || define(_ARM64_) || defined(__arm64ec__) || defined(_ARM64EC_) */
 
 /* ***************************************************** */
 
@@ -1777,7 +1776,7 @@ void *_InterlockedExchangePointer(void *volatile *Target,void *Value) {
 
 #endif /* defined(__x86_64__) || defined(_AMD64_) || defined(__i386__) || defined(_X86_) || defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_) */
 
-#if defined(__x86_64__) || defined(_AMD64_) || defined(__i386__) || defined(_X86_)
+#if (defined(__x86_64__) && !defined(__arm64ec__)) || (defined(_AMD64_) && !defined(_ARM64EC_)) || defined(__i386__) || defined(_X86_)
 
 #if __INTRINSIC_PROLOG(__int2c)
 void __int2c(void);
@@ -2157,7 +2156,7 @@ unsigned __int64 _xgetbv(unsigned int index)
 #endif /* __INTRINSIC_PROLOG */
 #endif /* __GNUC__ < 8 */
 
-#endif /* defined(__x86_64__) || defined(_AMD64_) || defined(__i386__) || defined(_X86_) */
+#endif /* (defined(__x86_64__) && !defined(__arm64ec__)) || (defined(_AMD64_) && !defined(_ARM64EC_)) || defined(__i386__) || defined(_X86_) */
 
 /* ***************************************************** */
 
diff --git a/mingw-w64-headers/include/winnt.h b/mingw-w64-headers/include/winnt.h
index c53136b1f..b6d1f58ed 100644
--- a/mingw-w64-headers/include/winnt.h
+++ b/mingw-w64-headers/include/winnt.h
@@ -1589,7 +1589,7 @@ __MINGW_CXX14_CONSTEXPR inline ENUMTYPE& operator ^= (ENUMTYPE& a, ENUMTYPE b) {
 
 #ifdef _AMD64_
 
-#if defined(__x86_64) && !defined(RC_INVOKED)
+#if defined(__x86_64) && !defined(__arm64ec__) && !defined(RC_INVOKED)
 
 #ifdef __cplusplus
   extern "C" {
@@ -1789,7 +1789,7 @@ extern "C" {
 #ifdef __cplusplus
   }
 #endif
-#endif /* defined(__x86_64) && !defined(RC_INVOKED) */
+#endif /* defined(__x86_64) && !defined(__arm64ec__) && !defined(RC_INVOKED) */
 
 #define EXCEPTION_READ_FAULT 0
 #define EXCEPTION_WRITE_FAULT 1
@@ -2154,9 +2154,9 @@ extern "C" {
 #endif /* _ARM_ */
 
 
-#ifdef _ARM64_
+#if defined(_ARM64_) || defined(_ARM64EC_)
 
-#if defined(__aarch64__) && !defined(RC_INVOKED)
+#if (defined(__aarch64__) || defined(__arm64ec__)) && !defined(RC_INVOKED)
 
 #ifdef __cplusplus
   extern "C" {
@@ -2226,7 +2226,7 @@ extern "C" {
 #ifdef __cplusplus
   }
 #endif
-#endif /* defined(__aarch64__) && !defined(RC_INVOKED) */
+#endif /* (defined(__aarch64__) || defined(__arm64ec__)) && !defined(RC_INVOKED) */
 
 #define EXCEPTION_READ_FAULT    0
 #define EXCEPTION_WRITE_FAULT   1
@@ -9120,7 +9120,7 @@ typedef DWORD (WINAPI *PRTL_RUN_ONCE_INIT_FN)(PRTL_RUN_ONCE, PVOID, PVOID *);
 #if !defined (__CRT__NO_INLINE) && !defined (__WIDL__)
     __CRT_INLINE PVOID WINAPI RtlSecureZeroMemory(PVOID ptr,SIZE_T cnt) {
       volatile char *vptr =(volatile char *)ptr;
-#ifdef __x86_64
+#if defined(__x86_64__) && !defined(__arm64ec__)
       __stosb((PBYTE)((DWORD64)vptr),0,cnt);
 #else
       while(cnt) {

_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to