Re: [Mingw-w64-public] [PATCH] include/intrin-impl: Don't define `__cpuidex` for GCC 11

2021-05-23 Thread Liu Hao

在 5/23/21 11:16 PM, Jacek Caban 写道:


The whole thing is really a hack, but I don't see a better solution, so it 
looks fine to me.




I am not sure whether people expect the Microsoft `__cpuid` or the GCC one. Perhaps we can have this 
commit in master for some time and see how it goes.




--
Best regards,
Liu Hao



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


Re: [Mingw-w64-public] [PATCH] include/intrin-impl: Don't define `__cpuidex` for GCC 11

2021-05-23 Thread Jacek Caban

On 20/05/2021 17:46, Liu Hao wrote:


在 2021-05-20 22:40, Jacek Caban 写道:



We could #undef __cpuid just after including cpuid.h.




Updated patch is attached.



The whole thing is really a hack, but I don't see a better solution, so 
it looks fine to me.



Thanks,

Jacek



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


Re: [Mingw-w64-public] [PATCH] include/intrin-impl: Don't define `__cpuidex` for GCC 11

2021-05-23 Thread Liu Hao

在 2021-05-20 23:46, Liu Hao 写道:

在 2021-05-20 22:40, Jacek Caban 写道:



We could #undef __cpuid just after including cpuid.h.




Updated patch is attached.





ping?


--
Best regards,
Liu Hao



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


Re: [Mingw-w64-public] [PATCH] include/intrin-impl: Don't define `__cpuidex` for GCC 11

2021-05-20 Thread Liu Hao

在 2021-05-20 22:40, Jacek Caban 写道:



We could #undef __cpuid just after including cpuid.h.




Updated patch is attached.


--
Best regards,
Liu Hao
From fb076cef964bfeb65c345535cceadadaff3e3ceb Mon Sep 17 00:00:00 2001
From: Liu Hao 
Date: Tue, 11 May 2021 00:39:58 +0800
Subject: [PATCH] include/intrin: Don't define `__cpuid` and `__cpuidex` for
 GCC 11

GCC has `__cpuid` as a macro. GCC 11 has `__cpuidex` as a static inline
function taking the same arguments, but without any indicative macros.

Reference: 
https://github.com/gcc-mirror/gcc/blob/23855a176609fe8dda6abaf2b21846b4517966eb/gcc/config/i386/cpuid.h#L333
Signed-off-by: Liu Hao 
---
 mingw-w64-headers/crt/intrin.h   | 4 
 mingw-w64-headers/include/psdk_inc/intrin-impl.h | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/mingw-w64-headers/crt/intrin.h b/mingw-w64-headers/crt/intrin.h
index bdabaea3..fbfee5fd 100644
--- a/mingw-w64-headers/crt/intrin.h
+++ b/mingw-w64-headers/crt/intrin.h
@@ -67,6 +67,10 @@ extern "C" {
 #endif
 
 #include 
+#include 
+
+/* Undefine the GCC one taking 5 parameters to prefer the mingw-w64 one. */
+#undef __cpuid
 
 /* Before 4.9.2, x86intrin.h had broken versions of these. */
 #undef _lrotl
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


Re: [Mingw-w64-public] [PATCH] include/intrin-impl: Don't define `__cpuidex` for GCC 11

2021-05-20 Thread Jacek Caban

On 5/20/21 4:37 PM, Liu Hao wrote:

在 2021-05-20 22:29, Jacek Caban 写道:

On 5/20/21 4:21 PM, Liu Hao wrote:

+#if (!defined(__GNUC__) || __GNUC__ < 11)
  __MACHINEI(void __cpuid(int a[4],int b))
+#endif


__cpuid is a macro in both older GCCs and clang, so it will probably 
not work there. It's also present in intrin-impl.h.





So what should we do? Can we just comment it out?



We could #undef __cpuid just after including cpuid.h.


Jacek




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


Re: [Mingw-w64-public] [PATCH] include/intrin-impl: Don't define `__cpuidex` for GCC 11

2021-05-20 Thread Liu Hao

在 2021-05-20 22:29, Jacek Caban 写道:

On 5/20/21 4:21 PM, Liu Hao wrote:

+#if (!defined(__GNUC__) || __GNUC__ < 11)
  __MACHINEI(void __cpuid(int a[4],int b))
+#endif


__cpuid is a macro in both older GCCs and clang, so it will probably not work there. It's also 
present in intrin-impl.h.





So what should we do? Can we just comment it out?


--
Best regards,
Liu Hao



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


Re: [Mingw-w64-public] [PATCH] include/intrin-impl: Don't define `__cpuidex` for GCC 11

2021-05-20 Thread Jacek Caban

On 5/20/21 4:21 PM, Liu Hao wrote:

+#if (!defined(__GNUC__) || __GNUC__ < 11)
  __MACHINEI(void __cpuid(int a[4],int b))
+#endif


__cpuid is a macro in both older GCCs and clang, so it will probably not 
work there. It's also present in intrin-impl.h.



Jacek



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


Re: [Mingw-w64-public] [PATCH] include/intrin-impl: Don't define `__cpuidex` for GCC 11

2021-05-20 Thread Liu Hao

在 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  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 
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 
---
 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 
+#include 
 
 /* Before 4.9.2, x86intrin.h had broken versions of these. */
 #undef _lrotl
@@ -1110,7 +,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


Re: [Mingw-w64-public] [PATCH] include/intrin-impl: Don't define `__cpuidex` for GCC 11

2021-05-20 Thread Jacek Caban

Hi Liu,

On 5/10/21 6:45 PM, Liu Hao wrote:

Subject: [PATCH] include/intrin-impl: Don't define `__cpuidex` for GCC 11

GCC 11 has this as a static inline function without any indicative
macros.

Reference:https://github.com/gcc-mirror/gcc/blob/23855a176609fe8dda6abaf2b21846b4517966eb/gcc/config/i386/cpuid.h#L333



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...



Thanks,

Jacek





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


Re: [Mingw-w64-public] [PATCH] include/intrin-impl: Don't define `__cpuidex` for GCC 11

2021-05-20 Thread Liu Hao

ping.


--
Best regards,
Liu Hao



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


[Mingw-w64-public] [PATCH] include/intrin-impl: Don't define `__cpuidex` for GCC 11

2021-05-10 Thread Liu Hao


--
Best regards,
Liu Hao
From f8ee13e246884c5ddb732097310efbe67f642d91 Mon Sep 17 00:00:00 2001
From: Liu Hao 
Date: Tue, 11 May 2021 00:39:58 +0800
Subject: [PATCH] include/intrin-impl: Don't define `__cpuidex` for GCC 11

GCC 11 has this 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 
---
 mingw-w64-headers/include/psdk_inc/intrin-impl.h | 2 ++
 1 file changed, 2 insertions(+)

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