11#include "pycore_cpuinfo.h"
22
3- /* CPUID input and output registers are 32-bit unsigned integers */
4- #define CPUID_REG uint32_t
53/* Check one or more CPUID register bits. */
64#define CHECK_REG (REG , MASK ) ((((REG) & (MASK)) == (MASK)) ? 0 : 1)
75#define CPUID_CHECK_REG (REG , FEAT ) CHECK_REG(REG, (_Py_CPUID_MASK_ ## FEAT))
121119static void
122120get_cpuid_info (uint32_t level /* input eax */ ,
123121 uint32_t count /* input ecx */ ,
124- CPUID_REG * eax , CPUID_REG * ebx , CPUID_REG * ecx , CPUID_REG * edx )
122+ uint32_t * eax , uint32_t * ebx , uint32_t * ecx , uint32_t * edx )
125123{
126124 * eax = * ebx = * ecx = * edx = 0 ; // ensure the output to be initialized
127125#if defined(HAS_CPUID_SUPPORT ) && defined(__x86_64__ ) && defined(__GNUC__ )
@@ -153,14 +151,14 @@ get_xgetbv(uint32_t index)
153151static uint32_t
154152detect_cpuid_maxleaf (void )
155153{
156- CPUID_REG maxleaf = 0 , ebx = 0 , ecx = 0 , edx = 0 ;
154+ uint32_t maxleaf = 0 , ebx = 0 , ecx = 0 , edx = 0 ;
157155 get_cpuid_info (0 , 0 , & maxleaf , & ebx , & ecx , & edx );
158156 return maxleaf ;
159157}
160158
161159/* Processor Info and Feature Bits (LEAF=1, SUBLEAF=0). */
162160static void
163- detect_cpuid_features (_Py_cpuid_features * flags , CPUID_REG ecx , CPUID_REG edx )
161+ detect_cpuid_features (_Py_cpuid_features * flags , uint32_t ecx , uint32_t edx )
164162{
165163 assert (flags -> maxleaf >= 1 );
166164 // Keep the ordering and newlines as they are declared in the structure.
@@ -205,7 +203,7 @@ detect_cpuid_features(_Py_cpuid_features *flags, CPUID_REG ecx, CPUID_REG edx)
205203/* Extended Feature Bits (LEAF=7, SUBLEAF=0). */
206204static void
207205detect_cpuid_extended_features_L7S0 (_Py_cpuid_features * flags ,
208- CPUID_REG ebx , CPUID_REG ecx , CPUID_REG edx )
206+ uint32_t ebx , uint32_t ecx , uint32_t edx )
209207{
210208 assert (flags -> maxleaf >= 7 );
211209 (void )ebx , (void )ecx , (void )edx ; // to suppress unused warnings
@@ -279,10 +277,10 @@ detect_cpuid_extended_features_L7S0(_Py_cpuid_features *flags,
279277/* Extended Feature Bits (LEAF=7, SUBLEAF=1). */
280278static void
281279detect_cpuid_extended_features_L7S1 (_Py_cpuid_features * flags ,
282- CPUID_REG eax ,
283- CPUID_REG ebx ,
284- CPUID_REG ecx ,
285- CPUID_REG edx )
280+ uint32_t eax ,
281+ uint32_t ebx ,
282+ uint32_t ecx ,
283+ uint32_t edx )
286284{
287285 assert (flags -> maxleaf >= 7 );
288286 (void )eax , (void )ebx , (void )ecx , (void )edx ; // to suppress unused warnings
@@ -489,7 +487,7 @@ static void
489487cpuid_detect_l1_features (_Py_cpuid_features * flags )
490488{
491489 if (flags -> maxleaf >= 1 ) {
492- CPUID_REG eax = 0 , ebx = 0 , ecx = 0 , edx = 0 ;
490+ uint32_t eax = 0 , ebx = 0 , ecx = 0 , edx = 0 ;
493491 get_cpuid_info (1 , 0 , & eax , & ebx , & ecx , & edx );
494492 detect_cpuid_features (flags , ecx , edx );
495493 if (flags -> osxsave ) {
@@ -506,7 +504,7 @@ static void
506504cpuid_detect_l7s0_features (_Py_cpuid_features * flags )
507505{
508506 assert (flags -> maxleaf >= 7 );
509- CPUID_REG eax = 0 , ebx = 0 , ecx = 0 , edx = 0 ;
507+ uint32_t eax = 0 , ebx = 0 , ecx = 0 , edx = 0 ;
510508 get_cpuid_info (7 , 0 , & eax , & ebx , & ecx , & edx );
511509 detect_cpuid_extended_features_L7S0 (flags , ebx , ecx , edx );
512510}
@@ -519,7 +517,7 @@ static void
519517cpuid_detect_l7s1_features (_Py_cpuid_features * flags )
520518{
521519 assert (flags -> maxleaf >= 7 );
522- CPUID_REG eax = 0 , ebx = 0 , ecx = 0 , edx = 0 ;
520+ uint32_t eax = 0 , ebx = 0 , ecx = 0 , edx = 0 ;
523521 get_cpuid_info (7 , 1 , & eax , & ebx , & ecx , & edx );
524522 detect_cpuid_extended_features_L7S1 (flags , eax , ebx , ecx , edx );
525523}
0 commit comments