From 497a1e3a4fc254e882745e37f2eb7d9131d0b56a Mon Sep 17 00:00:00 2001 From: Sergey Fedorov Date: Thu, 18 Jan 2024 12:39:56 +0800 Subject: [PATCH] darwin/PlatformHelpers: fix CPU detection for PowerPC Closes: https://github.com/htop-dev/htop/issues/1382 Notice, that hw.cpusubtype outputs a numerical code of a CPU. For PowerPC, 100 = G5, 11 = ppc7450, 10 = ppc7400. --- darwin/PlatformHelpers.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git darwin/PlatformHelpers.c darwin/PlatformHelpers.c index a4ea82be..b52346eb 100644 --- darwin/PlatformHelpers.c +++ darwin/PlatformHelpers.c @@ -60,6 +60,10 @@ bool Platform_KernelVersionIsBetween(KernelVersion lowerBound, KernelVersion upp void Platform_getCPUBrandString(char* cpuBrandString, size_t cpuBrandStringSize) { if (sysctlbyname("machdep.cpu.brand_string", cpuBrandString, &cpuBrandStringSize, NULL, 0) == -1) { + #ifdef __POWERPC__ + if (sysctlbyname("hw.cpusubtype", cpuBrandString, &cpuBrandStringSize, NULL, 0) != -1) + return; + #endif fprintf(stderr, "WARN: Unable to determine the CPU brand string.\n" "errno: %i, %s\n", errno, strerror(errno));