This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

amended fix for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68491


Hello,

I've been asked to send the patch against trunk here.

Best,

christos

Index: cpuid.h
===================================================================
--- cpuid.h	(revision 247395)
+++ cpuid.h	(working copy)
@@ -235,6 +235,16 @@
   return __eax;
 }
 
+/* Return non-zero  if we support cpuid at this leaf */
+static __inline int
+__have_cpuid_leaf (unsigned int __leaf)
+{
+  unsigned int __ext = __leaf & 0x80000000;
+  unsigned int __maxlevel = __get_cpuid_max (__ext, 0);
+
+  return __maxlevel != 0 && __maxlevel >= __ext;
+}
+
 /* Return cpuid data for requested cpuid leaf, as found in returned
    eax, ebx, ecx and edx registers.  The function checks if cpuid is
    supported and returns 1 for valid cpuid information or 0 for
@@ -245,9 +255,7 @@
 	     unsigned int *__eax, unsigned int *__ebx,
 	     unsigned int *__ecx, unsigned int *__edx)
 {
-  unsigned int __ext = __leaf & 0x80000000;
-
-  if (__get_cpuid_max (__ext, 0) < __leaf)
+  if (!__have_cpuid_leaf (__leaf))
     return 0;
 
   __cpuid (__leaf, *__eax, *__ebx, *__ecx, *__edx);
@@ -261,9 +269,7 @@
 		   unsigned int *__eax, unsigned int *__ebx,
 		   unsigned int *__ecx, unsigned int *__edx)
 {
-  unsigned int __ext = __leaf & 0x80000000;
-
-  if (__get_cpuid_max (__ext, 0) < __leaf)
+  if (!__have_cpuid_leaf (__leaf))
     return 0;
 
   __cpuid_count (__leaf, __subleaf, *__eax, *__ebx, *__ecx, *__edx);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]