From 095bbfb784f0b367558741e9b02f6278126e1c93 Mon Sep 17 00:00:00 2001 From: Dr-Noob Date: Fri, 6 Jan 2023 12:19:06 +0100 Subject: [PATCH] [v1.03] Fix build in macOS --- src/common/cpu.c | 2 -- src/common/global.h | 1 + src/x86/apic.c | 3 +-- src/x86/cpuid.c | 7 +++++++ 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/common/cpu.c b/src/common/cpu.c index 5cbbf9d..2faa4bb 100644 --- a/src/common/cpu.c +++ b/src/common/cpu.c @@ -16,8 +16,6 @@ #include "../arm/uarch.h" #endif -#define UNUSED(x) (void)(x) - #define STRING_YES "Yes" #define STRING_NO "No" #define STRING_NONE "None" diff --git a/src/common/global.h b/src/common/global.h index 5e5a0b3..4b61c4e 100644 --- a/src/common/global.h +++ b/src/common/global.h @@ -5,6 +5,7 @@ #include #define STRING_UNKNOWN "Unknown" +#define UNUSED(x) (void)(x) void set_log_level(bool verbose); void printWarn(const char *fmt, ...); diff --git a/src/x86/apic.c b/src/x86/apic.c index 1edcfc4..1757110 100644 --- a/src/x86/apic.c +++ b/src/x86/apic.c @@ -7,8 +7,6 @@ #elif defined __FreeBSD__ #include #include -#elif defined __APPLE__ - #define UNUSED(x) (void)(x) #endif #include @@ -355,6 +353,7 @@ void add_apic_to_array(uint32_t apic, uint32_t* apic_ids, int n) { bool fill_apic_ids(uint32_t* apic_ids, int first_core, int n, bool x2apic_id) { #ifdef __APPLE__ // macOS extremely dirty approach... + UNUSED(first_core); printf("cpufetch is computing APIC IDs, please wait...\n"); bool end = false; uint32_t apic; diff --git a/src/x86/cpuid.c b/src/x86/cpuid.c index b433fa9..fdc8869 100644 --- a/src/x86/cpuid.c +++ b/src/x86/cpuid.c @@ -356,6 +356,11 @@ struct features* get_features_info(struct cpuInfo* cpu) { bool set_cpu_module(int m, int total_modules, int32_t* first_core) { if(total_modules > 1) { + #ifdef __APPLE__ + UNUSED(m); + printBug("Hybrid architectures are not supported under macOS"); + return false; + #else // We have a hybrid architecture. // 1. Find the first core from module m int32_t core_id = -1; @@ -397,6 +402,7 @@ bool set_cpu_module(int m, int total_modules, int32_t* first_core) { if(!bind_to_cpu(core_id)) { return false; } + #endif } else { // This is a normal architecture @@ -659,6 +665,7 @@ struct topology* get_topology_info(struct cpuInfo* cpu, struct cache* cach, int #ifdef __linux__ topo->total_cores_module = get_total_cores_module(topo->total_cores, module); #else + UNUSED(module); topo->total_cores_module = topo->total_cores; #endif }