This is the mail archive of the gcc-bugs@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]

[Bug target/77756] __get_cpuid() returns wrong values for level 7 (extended features)


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77756

--- Comment #10 from H.J. Lu <hjl.tools at gmail dot com> ---
(In reply to Uroš Bizjak from comment #9)
> 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--

It looks good to me.

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