This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug target/77756] __get_cpuid() returns wrong values for level 7 (extended features)
- From: "ubizjak at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 29 Sep 2016 16:57:25 +0000
- Subject: [Bug target/77756] __get_cpuid() returns wrong values for level 7 (extended features)
- Auto-submitted: auto-generated
- References: <bug-77756-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77756
--- Comment #9 from Uroš Bizjak <ubizjak at gmail dot com> ---
At the end of the day, it looks that we want simply an additional version of
__get_cpuid where sub-leaf can be specified - a variant of HJ's proposal:
--cut here--
/* 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
unsupported cpuid leaf. All pointers are required to be non-null. */
static __inline int
__get_cpuid (unsigned int __leaf,
unsigned int *__eax, unsigned int *__ebx,
unsigned int *__ecx, unsigned int *__edx)
{
unsigned int __ext = __leaf & 0x80000000;
if (__get_cpuid_max (__ext, 0) < __leaf)
return 0;
__cpuid (__leaf, *__eax, *__ebx, *__ecx, *__edx);
return 1;
}
/* Same as above, but sub-leaf can be specified. */
static __inline int
__get_cpuid_count (unsigned int __leaf, unsigned int __subleaf,
unsigned int *__eax, unsigned int *__ebx,
unsigned int *__ecx, unsigned int *__edx)
{
unsigned int __ext = __leaf & 0x80000000;
if (__get_cpuid_max (__ext, 0) < __leaf)
return 0;
__cpuid_count (__leaf, __subleaf, *__eax, *__ebx, *__ecx, *__edx);
return 1;
}
--cut here--