在 2021-05-20 21:58, Jacek Caban 写道:
As far as I can see, cpuid.h is not included by any other header shipped with GCC. It means that with your changes, users will would need to start including it themselves in addition to intrin.h.For similar cases with other *intrin.h headers provided by GCC, we simply include them from intrin.h to avoid collisions. cpuid.h is risky in this regard, because it seems to provide way more than we want. But maybe that's fine...
Inclusion of <cpuid.h> has revealed another issue: GCC 11 has `__cpuid` as a macro which causes errors like
mingw-w64-headers/crt/intrin.h:1114:44: error: macro "__cpuid" requires 5 arguments, but only 2 given
1114 | __MACHINEI(void __cpuid(int a[4],int b)) | ^ In file included from mingw-w64-headers/crt/intrin.h:70:C:/MSYS2/mingw64/lib/gcc/x86_64-w64-mingw32/11.1.1/include/cpuid.h:227: note: macro "__cpuid" defined here
227 | #define __cpuid(level, a, b, c, d) \ | mingw-w64-headers/crt/intrin.h:1114:21: error: '__cpuid' redeclared as different kind of symbol 1114 | __MACHINEI(void __cpuid(int a[4],int b)) | ^~~~~~~ mingw-w64-headers/crt/intrin.h:186:22: note: in definition of macro '__MACHINE' 186 | #define __MACHINE(X) X; | ^ mingw-w64-headers/crt/intrin.h:1114:5: note: in expansion of macro '__MACHINEI' 1114 | __MACHINEI(void __cpuid(int a[4],int b)) | ^~~~~~~~~~ In file included from mingw-w64-headers/crt/intrin.h:41:mingw-w64-headers/include/psdk_inc/intrin-impl.h:1899:6: note: previous definition of '__cpuid' with type 'void(int *, int)'
1899 | void __cpuid(int CPUInfo[4], int InfoType) { | ^~~~~~~ The attached patch adds the include and another guard for it. -- Best regards, Liu Hao
From c321a21153678a2f1e54797d923ae56536382b86 Mon Sep 17 00:00:00 2001 From: Liu Hao <lh_mo...@126.com> Date: Tue, 11 May 2021 00:39:58 +0800 Subject: [PATCH] include/intrin: Don't define `__cpuid` and `__cpuidex` for GCC 11 GCC 11 has `__cpuid` as a macro, and has `__cpuidex` as a static inline function without any indicative macros. Reference: https://github.com/gcc-mirror/gcc/blob/23855a176609fe8dda6abaf2b21846b4517966eb/gcc/config/i386/cpuid.h#L333 Signed-off-by: Liu Hao <lh_mo...@126.com> --- mingw-w64-headers/crt/intrin.h | 3 +++ mingw-w64-headers/include/psdk_inc/intrin-impl.h | 2 ++ 2 files changed, 5 insertions(+) diff --git a/mingw-w64-headers/crt/intrin.h b/mingw-w64-headers/crt/intrin.h index bdabaea3..7b73b947 100644 --- a/mingw-w64-headers/crt/intrin.h +++ b/mingw-w64-headers/crt/intrin.h @@ -67,6 +67,7 @@ extern "C" { #endif #include <x86intrin.h> +#include <cpuid.h> /* Before 4.9.2, x86intrin.h had broken versions of these. */ #undef _lrotl @@ -1110,7 +1111,9 @@ extern "C" { /* __MACHINEX64(__MINGW_EXTENSION unsigned char _interlockedbittestandset64(__int64 *a,__int64 b)) moved to psdk_inc/intrin-impl.h */ /* __MACHINEX64(__MINGW_EXTENSION unsigned char _interlockedbittestandreset64(__int64 *a,__int64 b)) moved to psdk_inc/intrin-impl.h */ /* __MACHINEX64(__MINGW_EXTENSION unsigned char _interlockedbittestandcomplement64(__int64 *a,__int64 b)) moved to psdk_inc/intrin-impl.h */ +#if (!defined(__GNUC__) || __GNUC__ < 11) __MACHINEI(void __cpuid(int a[4],int b)) +#endif __MACHINEI(__MINGW_EXTENSION unsigned __int64 __readpmc(unsigned __LONG32 a)) __MACHINEI(unsigned __LONG32 __segmentlimit(unsigned __LONG32 a)) diff --git a/mingw-w64-headers/include/psdk_inc/intrin-impl.h b/mingw-w64-headers/include/psdk_inc/intrin-impl.h index 27cc26ac..d59682c1 100644 --- a/mingw-w64-headers/include/psdk_inc/intrin-impl.h +++ b/mingw-w64-headers/include/psdk_inc/intrin-impl.h @@ -1906,6 +1906,7 @@ void __cpuid(int CPUInfo[4], int InfoType) { #define __INTRINSIC_DEFINED___cpuid #endif /* __INTRINSIC_PROLOG */ +#if (!defined(__GNUC__) || __GNUC__ < 11) #if __INTRINSIC_PROLOG(__cpuidex) void __cpuidex(int CPUInfo[4], int, int); #if !__has_builtin(__cpuidex) @@ -1919,6 +1920,7 @@ void __cpuidex(int CPUInfo[4], int function_id, int subfunction_id) { #endif #define __INTRINSIC_DEFINED___cpuidex #endif /* __INTRINSIC_PROLOG */ +#endif /* __GNUC__ < 11 */ #if __INTRINSIC_PROLOG(__readmsr) __MINGW_EXTENSION unsigned __int64 __readmsr(unsigned __LONG32); -- 2.31.1
OpenPGP_signature
Description: OpenPGP digital signature
_______________________________________________ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public