Skip to content

Commit 69a7e64

Browse files
committed
CPU (Linux): support up to 128-socket boards
1 parent ee564de commit 69a7e64

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/detection/cpu/cpu_linux.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -467,19 +467,22 @@ FF_MAYBE_UNUSED static void detectArmSoc(FFCPUResult* cpu)
467467
FF_MAYBE_UNUSED static uint16_t getPackageCount(FFstrbuf* cpuinfo)
468468
{
469469
const char* p = cpuinfo->chars;
470-
uint64_t bits = 0;
470+
uint64_t low = 0, high = 0;
471471

472472
while ((p = memmem(p, cpuinfo->length - (uint32_t) (p - cpuinfo->chars), "\nphysical id\t:", strlen("\nphysical id\t:"))))
473473
{
474474
if (!p) break;
475475
p += strlen("\nphysical id\t:");
476476
char* pend;
477-
uint32_t id = (uint32_t) strtoul(p, &pend, 10);
477+
unsigned long id = strtoul(p, &pend, 10);
478+
if (__builtin_expect(id > 64, false)) // Do 129-socket boards exist?
479+
high |= 1 << (id - 64);
480+
else
481+
low |= 1 << id;
478482
p = pend;
479-
bits |= 1 << id;
480483
}
481484

482-
return (uint16_t) __builtin_popcountll(bits);
485+
return (uint16_t) (__builtin_popcountll(low) + __builtin_popcountll(high));
483486
}
484487

485488
const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu)

0 commit comments

Comments
 (0)