[v1.03] Fix build in macOS

This commit is contained in:
Dr-Noob
2023-01-06 12:19:06 +01:00
parent 874f89051a
commit 095bbfb784
4 changed files with 9 additions and 4 deletions

View File

@@ -16,8 +16,6 @@
#include "../arm/uarch.h" #include "../arm/uarch.h"
#endif #endif
#define UNUSED(x) (void)(x)
#define STRING_YES "Yes" #define STRING_YES "Yes"
#define STRING_NO "No" #define STRING_NO "No"
#define STRING_NONE "None" #define STRING_NONE "None"

View File

@@ -5,6 +5,7 @@
#include <stddef.h> #include <stddef.h>
#define STRING_UNKNOWN "Unknown" #define STRING_UNKNOWN "Unknown"
#define UNUSED(x) (void)(x)
void set_log_level(bool verbose); void set_log_level(bool verbose);
void printWarn(const char *fmt, ...); void printWarn(const char *fmt, ...);

View File

@@ -7,8 +7,6 @@
#elif defined __FreeBSD__ #elif defined __FreeBSD__
#include <sys/param.h> #include <sys/param.h>
#include <sys/cpuset.h> #include <sys/cpuset.h>
#elif defined __APPLE__
#define UNUSED(x) (void)(x)
#endif #endif
#include <stdlib.h> #include <stdlib.h>
@@ -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) { bool fill_apic_ids(uint32_t* apic_ids, int first_core, int n, bool x2apic_id) {
#ifdef __APPLE__ #ifdef __APPLE__
// macOS extremely dirty approach... // macOS extremely dirty approach...
UNUSED(first_core);
printf("cpufetch is computing APIC IDs, please wait...\n"); printf("cpufetch is computing APIC IDs, please wait...\n");
bool end = false; bool end = false;
uint32_t apic; uint32_t apic;

View File

@@ -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) { bool set_cpu_module(int m, int total_modules, int32_t* first_core) {
if(total_modules > 1) { if(total_modules > 1) {
#ifdef __APPLE__
UNUSED(m);
printBug("Hybrid architectures are not supported under macOS");
return false;
#else
// We have a hybrid architecture. // We have a hybrid architecture.
// 1. Find the first core from module m // 1. Find the first core from module m
int32_t core_id = -1; 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)) { if(!bind_to_cpu(core_id)) {
return false; return false;
} }
#endif
} }
else { else {
// This is a normal architecture // This is a normal architecture
@@ -659,6 +665,7 @@ struct topology* get_topology_info(struct cpuInfo* cpu, struct cache* cach, int
#ifdef __linux__ #ifdef __linux__
topo->total_cores_module = get_total_cores_module(topo->total_cores, module); topo->total_cores_module = get_total_cores_module(topo->total_cores, module);
#else #else
UNUSED(module);
topo->total_cores_module = topo->total_cores; topo->total_cores_module = topo->total_cores;
#endif #endif
} }