From a55148fc5654f2d5401ec71ea850f5a71ef6794f Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Wed, 20 Dec 2023 08:45:07 +0530 Subject: [PATCH] Use two-argument cpuid when using recent MinGW (#172) --- Extensions/DirectXMathAVX.h | 4 ++-- Extensions/DirectXMathAVX2.h | 4 ++-- Extensions/DirectXMathBE.h | 4 ++-- Extensions/DirectXMathF16C.h | 4 ++-- Extensions/DirectXMathFMA3.h | 4 ++-- Extensions/DirectXMathFMA4.h | 8 ++++---- Extensions/DirectXMathSSE3.h | 4 ++-- Extensions/DirectXMathSSE4.h | 4 ++-- Inc/DirectXMathMisc.inl | 4 ++-- 9 files changed, 20 insertions(+), 20 deletions(-) diff --git a/Extensions/DirectXMathAVX.h b/Extensions/DirectXMathAVX.h index 901a1c9..ea91539 100644 --- a/Extensions/DirectXMathAVX.h +++ b/Extensions/DirectXMathAVX.h @@ -28,7 +28,7 @@ inline bool XMVerifyAVXSupport() // See http://msdn.microsoft.com/en-us/library/hskdteyh.aspx int CPUInfo[4] = {-1}; -#if defined(__clang__) || defined(__GNUC__) +#if (defined(__clang__) || defined(__GNUC__)) && defined(__cpuid) __cpuid(0, CPUInfo[0], CPUInfo[1], CPUInfo[2], CPUInfo[3]); #else __cpuid( CPUInfo, 0 ); @@ -37,7 +37,7 @@ inline bool XMVerifyAVXSupport() if ( CPUInfo[0] < 1 ) return false; -#if defined(__clang__) || defined(__GNUC__) +#if (defined(__clang__) || defined(__GNUC__)) && defined(__cpuid) __cpuid(1, CPUInfo[0], CPUInfo[1], CPUInfo[2], CPUInfo[3]); #else __cpuid(CPUInfo, 1 ); diff --git a/Extensions/DirectXMathAVX2.h b/Extensions/DirectXMathAVX2.h index 9624dc9..e7b4d2a 100644 --- a/Extensions/DirectXMathAVX2.h +++ b/Extensions/DirectXMathAVX2.h @@ -29,7 +29,7 @@ inline bool XMVerifyAVX2Support() // See http://msdn.microsoft.com/en-us/library/hskdteyh.aspx int CPUInfo[4] = {-1}; -#if defined(__clang__) || defined(__GNUC__) +#if (defined(__clang__) || defined(__GNUC__)) && defined(__cpuid) __cpuid(0, CPUInfo[0], CPUInfo[1], CPUInfo[2], CPUInfo[3]); #else __cpuid(CPUInfo, 0); @@ -38,7 +38,7 @@ inline bool XMVerifyAVX2Support() if ( CPUInfo[0] < 7 ) return false; -#if defined(__clang__) || defined(__GNUC__) +#if (defined(__clang__) || defined(__GNUC__)) && defined(__cpuid) __cpuid(1, CPUInfo[0], CPUInfo[1], CPUInfo[2], CPUInfo[3]); #else __cpuid(CPUInfo, 1); diff --git a/Extensions/DirectXMathBE.h b/Extensions/DirectXMathBE.h index e5a0f85..b41d9fe 100644 --- a/Extensions/DirectXMathBE.h +++ b/Extensions/DirectXMathBE.h @@ -59,7 +59,7 @@ inline bool XMVerifySSSE3Support() // See http://msdn.microsoft.com/en-us/library/hskdteyh.aspx int CPUInfo[4] = { -1 }; -#if defined(__clang__) || defined(__GNUC__) +#if (defined(__clang__) || defined(__GNUC__)) && defined(__cpuid) __cpuid(0, CPUInfo[0], CPUInfo[1], CPUInfo[2], CPUInfo[3]); #else __cpuid(CPUInfo, 0); @@ -68,7 +68,7 @@ inline bool XMVerifySSSE3Support() if ( CPUInfo[0] < 1 ) return false; -#if defined(__clang__) || defined(__GNUC__) +#if (defined(__clang__) || defined(__GNUC__)) && defined(__cpuid) __cpuid(1, CPUInfo[0], CPUInfo[1], CPUInfo[2], CPUInfo[3]); #else __cpuid(CPUInfo, 1); diff --git a/Extensions/DirectXMathF16C.h b/Extensions/DirectXMathF16C.h index 5802be6..726a894 100644 --- a/Extensions/DirectXMathF16C.h +++ b/Extensions/DirectXMathF16C.h @@ -29,7 +29,7 @@ inline bool XMVerifyF16CSupport() // See http://msdn.microsoft.com/en-us/library/hskdteyh.aspx int CPUInfo[4] = { -1 }; -#if defined(__clang__) || defined(__GNUC__) +#if (defined(__clang__) || defined(__GNUC__)) && defined(__cpuid) __cpuid(0, CPUInfo[0], CPUInfo[1], CPUInfo[2], CPUInfo[3]); #else __cpuid(CPUInfo, 0); @@ -38,7 +38,7 @@ inline bool XMVerifyF16CSupport() if ( CPUInfo[0] < 1 ) return false; -#if defined(__clang__) || defined(__GNUC__) +#if (defined(__clang__) || defined(__GNUC__)) && defined(__cpuid) __cpuid(1, CPUInfo[0], CPUInfo[1], CPUInfo[2], CPUInfo[3]); #else __cpuid(CPUInfo, 1); diff --git a/Extensions/DirectXMathFMA3.h b/Extensions/DirectXMathFMA3.h index 8fae18e..03ce1a2 100644 --- a/Extensions/DirectXMathFMA3.h +++ b/Extensions/DirectXMathFMA3.h @@ -28,7 +28,7 @@ inline bool XMVerifyFMA3Support() // See http://msdn.microsoft.com/en-us/library/hskdteyh.aspx int CPUInfo[4] = {-1}; -#if defined(__clang__) || defined(__GNUC__) +#if (defined(__clang__) || defined(__GNUC__)) && defined(__cpuid) __cpuid(0, CPUInfo[0], CPUInfo[1], CPUInfo[2], CPUInfo[3]); #else __cpuid(CPUInfo, 0); @@ -37,7 +37,7 @@ inline bool XMVerifyFMA3Support() if ( CPUInfo[0] < 1 ) return false; -#if defined(__clang__) || defined(__GNUC__) +#if (defined(__clang__) || defined(__GNUC__)) && defined(__cpuid) __cpuid(1, CPUInfo[0], CPUInfo[1], CPUInfo[2], CPUInfo[3]); #else __cpuid(CPUInfo, 1); diff --git a/Extensions/DirectXMathFMA4.h b/Extensions/DirectXMathFMA4.h index 2cec13e..ad29ad4 100644 --- a/Extensions/DirectXMathFMA4.h +++ b/Extensions/DirectXMathFMA4.h @@ -33,7 +33,7 @@ inline bool XMVerifyFMA4Support() // See http://msdn.microsoft.com/en-us/library/hskdteyh.aspx int CPUInfo[4] = {-1}; -#if defined(__clang__) || defined(__GNUC__) +#if (defined(__clang__) || defined(__GNUC__)) && defined(__cpuid) __cpuid(0, CPUInfo[0], CPUInfo[1], CPUInfo[2], CPUInfo[3]); #else __cpuid(CPUInfo, 0); @@ -42,7 +42,7 @@ inline bool XMVerifyFMA4Support() if ( CPUInfo[0] < 1 ) return false; -#if defined(__clang__) || defined(__GNUC__) +#if (defined(__clang__) || defined(__GNUC__)) && defined(__cpuid) __cpuid(1, CPUInfo[0], CPUInfo[1], CPUInfo[2], CPUInfo[3]); #else __cpuid(CPUInfo, 1); @@ -52,7 +52,7 @@ inline bool XMVerifyFMA4Support() if ( (CPUInfo[2] & 0x18000000) != 0x18000000 ) return false; -#if defined(__clang__) || defined(__GNUC__) +#if (defined(__clang__) || defined(__GNUC__)) && defined(__cpuid) __cpuid(0x80000000, CPUInfo[0], CPUInfo[1], CPUInfo[2], CPUInfo[3]); #else __cpuid(CPUInfo, 0x80000000); @@ -62,7 +62,7 @@ inline bool XMVerifyFMA4Support() return false; // We check for FMA4 -#if defined(__clang__) || defined(__GNUC__) +#if (defined(__clang__) || defined(__GNUC__)) && defined(__cpuid) __cpuid(0x80000001, CPUInfo[0], CPUInfo[1], CPUInfo[2], CPUInfo[3]); #else __cpuid(CPUInfo, 0x80000001); diff --git a/Extensions/DirectXMathSSE3.h b/Extensions/DirectXMathSSE3.h index 926de4a..963ba38 100644 --- a/Extensions/DirectXMathSSE3.h +++ b/Extensions/DirectXMathSSE3.h @@ -29,7 +29,7 @@ inline bool XMVerifySSE3Support() // See http://msdn.microsoft.com/en-us/library/hskdteyh.aspx int CPUInfo[4] = { -1 }; -#if defined(__clang__) || defined(__GNUC__) +#if (defined(__clang__) || defined(__GNUC__)) && defined(__cpuid) __cpuid(0, CPUInfo[0], CPUInfo[1], CPUInfo[2], CPUInfo[3]); #else __cpuid(CPUInfo, 0); @@ -37,7 +37,7 @@ inline bool XMVerifySSE3Support() if ( CPUInfo[0] < 1 ) return false; -#if defined(__clang__) || defined(__GNUC__) +#if (defined(__clang__) || defined(__GNUC__)) && defined(__cpuid) __cpuid(1, CPUInfo[0], CPUInfo[1], CPUInfo[2], CPUInfo[3]); #else __cpuid(CPUInfo, 1); diff --git a/Extensions/DirectXMathSSE4.h b/Extensions/DirectXMathSSE4.h index 4e432a9..58b7a4d 100644 --- a/Extensions/DirectXMathSSE4.h +++ b/Extensions/DirectXMathSSE4.h @@ -29,7 +29,7 @@ inline bool XMVerifySSE4Support() // See http://msdn.microsoft.com/en-us/library/hskdteyh.aspx int CPUInfo[4] = { -1 }; -#if defined(__clang__) || defined(__GNUC__) +#if (defined(__clang__) || defined(__GNUC__)) && defined(__cpuid) __cpuid(0, CPUInfo[0], CPUInfo[1], CPUInfo[2], CPUInfo[3]); #else __cpuid(CPUInfo, 0); @@ -37,7 +37,7 @@ inline bool XMVerifySSE4Support() if ( CPUInfo[0] < 1 ) return false; -#if defined(__clang__) || defined(__GNUC__) +#if (defined(__clang__) || defined(__GNUC__)) && defined(__cpuid) __cpuid(1, CPUInfo[0], CPUInfo[1], CPUInfo[2], CPUInfo[3]); #else __cpuid(CPUInfo, 1); diff --git a/Inc/DirectXMathMisc.inl b/Inc/DirectXMathMisc.inl index 5f88da6..eba728a 100644 --- a/Inc/DirectXMathMisc.inl +++ b/Inc/DirectXMathMisc.inl @@ -1973,7 +1973,7 @@ inline bool XMVerifyCPUSupport() noexcept { #if defined(_XM_SSE_INTRINSICS_) && !defined(_XM_NO_INTRINSICS_) int CPUInfo[4] = { -1 }; -#if defined(__clang__) || defined(__GNUC__) +#if (defined(__clang__) || defined(__GNUC__)) && defined(__cpuid) __cpuid(0, CPUInfo[0], CPUInfo[1], CPUInfo[2], CPUInfo[3]); #else __cpuid(CPUInfo, 0); @@ -1987,7 +1987,7 @@ inline bool XMVerifyCPUSupport() noexcept return false; #endif -#if defined(__clang__) || defined(__GNUC__) +#if (defined(__clang__) || defined(__GNUC__)) && defined(__cpuid) __cpuid(1, CPUInfo[0], CPUInfo[1], CPUInfo[2], CPUInfo[3]); #else __cpuid(CPUInfo, 1);