Skip to content

Commit 62c9a40

Browse files
committed
handle -Wpedantic
1 parent 838f928 commit 62c9a40

1 file changed

Lines changed: 19 additions & 7 deletions

File tree

Python/cpuinfo.c

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ get_cpuid_info(uint32_t level /* input eax */,
128128
uint32_t info[4] = {0};
129129
__cpuidex(info, level, count);
130130
*eax = info[0], *ebx = info[1], *ecx = info[2], *edx = info[3];
131+
#else
132+
(void)level, (void)count;
131133
#endif
132134
}
133135

@@ -151,16 +153,18 @@ get_xgetbv(uint32_t index)
151153
static uint32_t
152154
detect_cpuid_maxleaf(void)
153155
{
154-
uint32_t maxleaf = 0, ebx = 0, ecx = 0, edx = 0;
155-
get_cpuid_info(0, 0, &maxleaf, &ebx, &ecx, &edx);
156+
uint32_t maxleaf = 0, _ebx = 0, _ecx = 0, _edx = 0;
157+
get_cpuid_info(0, 0, &maxleaf, &_ebx, &_ecx, &_edx);
156158
return maxleaf;
157159
}
158160

159161
/* Processor Info and Feature Bits (LEAF=1, SUBLEAF=0). */
160162
static void
161163
detect_cpuid_features(_Py_cpuid_features *flags, uint32_t ecx, uint32_t edx)
162164
{
165+
assert(flags->ready == 0);
163166
assert(flags->maxleaf >= 1);
167+
(void)flags, (void)ecx, (void)edx; // silence -Wunused-parameter
164168
// Keep the ordering and newlines as they are declared in the structure.
165169
#ifdef SIMD_SSE_INSTRUCTIONS_DETECTION_GUARD
166170
#ifdef _Py_CAN_COMPILE_SIMD_SSE_INSTRUCTIONS
@@ -205,8 +209,9 @@ static void
205209
detect_cpuid_extended_features_L7S0(_Py_cpuid_features *flags,
206210
uint32_t ebx, uint32_t ecx, uint32_t edx)
207211
{
212+
assert(flags->ready == 0);
208213
assert(flags->maxleaf >= 7);
209-
(void)ebx, (void)ecx, (void)edx; // to suppress unused warnings
214+
(void)flags, (void)ebx, (void)ecx, (void)edx;
210215
// Keep the ordering and newlines as they are declared in the structure.
211216
#ifdef SIMD_AVX2_INSTRUCTIONS_DETECTION_GUARD
212217
#ifdef _Py_CAN_COMPILE_SIMD_AVX2_INSTRUCTIONS
@@ -282,8 +287,9 @@ detect_cpuid_extended_features_L7S1(_Py_cpuid_features *flags,
282287
uint32_t ecx,
283288
uint32_t edx)
284289
{
290+
assert(flags->ready == 0);
285291
assert(flags->maxleaf >= 7);
286-
(void)eax, (void)ebx, (void)ecx, (void)edx; // to suppress unused warnings
292+
(void)flags, (void)eax, (void)ebx, (void)ecx, (void)edx;
287293
// Keep the ordering and newlines as they are declared in the structure.
288294
#ifdef SIMD_AVX_INSTRUCTIONS_DETECTION_GUARD
289295
#ifdef _Py_CAN_COMPILE_SIMD_AVX_NE_CONVERT_INSTRUCTIONS
@@ -309,8 +315,10 @@ detect_cpuid_extended_features_L7S1(_Py_cpuid_features *flags,
309315
static void
310316
detect_cpuid_xsave_state(_Py_cpuid_features *flags)
311317
{
312-
// Keep the ordering and newlines as they are declared in the structure.
318+
assert(flags->ready == 0);
313319
assert(flags->maxleaf >= 1);
320+
(void)flags;
321+
// Keep the ordering and newlines as they are declared in the structure.
314322
#ifdef HAS_XGETBV_SUPPORT
315323
uint64_t xcr0 = flags->osxsave ? get_xgetbv(0) : 0;
316324
flags->xcr0_sse = XSAVE_CHECK_REG(xcr0, XCR0_SSE);
@@ -480,6 +488,7 @@ _Py_cpuid_match_features(const _Py_cpuid_features *actual,
480488
static void
481489
cpuid_detect_l1_features(_Py_cpuid_features *flags)
482490
{
491+
assert(flags->ready == 0);
483492
if (flags->maxleaf >= 1) {
484493
uint32_t eax = 0, ebx = 0, ecx = 0, edx = 0;
485494
get_cpuid_info(1, 0, &eax, &ebx, &ecx, &edx);
@@ -497,9 +506,10 @@ cpuid_detect_l1_features(_Py_cpuid_features *flags)
497506
static void
498507
cpuid_detect_l7s0_features(_Py_cpuid_features *flags)
499508
{
509+
assert(flags->ready == 0);
500510
assert(flags->maxleaf >= 7);
501-
uint32_t eax = 0, ebx = 0, ecx = 0, edx = 0;
502-
get_cpuid_info(7, 0, &eax, &ebx, &ecx, &edx);
511+
uint32_t _eax = 0, ebx = 0, ecx = 0, edx = 0;
512+
get_cpuid_info(7, 0, &_eax, &ebx, &ecx, &edx);
503513
detect_cpuid_extended_features_L7S0(flags, ebx, ecx, edx);
504514
}
505515
#else
@@ -510,6 +520,7 @@ cpuid_detect_l7s0_features(_Py_cpuid_features *flags)
510520
static void
511521
cpuid_detect_l7s1_features(_Py_cpuid_features *flags)
512522
{
523+
assert(flags->ready == 0);
513524
assert(flags->maxleaf >= 7);
514525
uint32_t eax = 0, ebx = 0, ecx = 0, edx = 0;
515526
get_cpuid_info(7, 1, &eax, &ebx, &ecx, &edx);
@@ -523,6 +534,7 @@ cpuid_detect_l7s1_features(_Py_cpuid_features *flags)
523534
static void
524535
cpuid_detect_l7_features(_Py_cpuid_features *flags)
525536
{
537+
assert(flags->ready == 0);
526538
if (flags->maxleaf >= 7) {
527539
cpuid_detect_l7s0_features(flags);
528540
cpuid_detect_l7s1_features(flags);

0 commit comments

Comments
 (0)