mirror of
https://github.com/Dr-Noob/cpufetch.git
synced 2026-03-25 16:00:39 +01:00
[v0.98] Patch to fix the compilation error reported by #93
This commit is contained in:
2
Makefile
2
Makefile
@@ -12,7 +12,7 @@ COMMON_HDR = $(SRC_COMMON)ascii.h $(SRC_COMMON)cpu.h $(SRC_COMMON)udev.h $(SRC_C
|
|||||||
|
|
||||||
ifneq ($(OS),Windows_NT)
|
ifneq ($(OS),Windows_NT)
|
||||||
arch := $(shell uname -m)
|
arch := $(shell uname -m)
|
||||||
ifeq ($(arch), $(filter $(arch), x86_64 i686))
|
ifeq ($(arch), $(filter $(arch), x86_64 amd64 i686))
|
||||||
SRC_DIR=src/x86/
|
SRC_DIR=src/x86/
|
||||||
SOURCE += $(COMMON_SRC) $(SRC_DIR)cpuid.c $(SRC_DIR)apic.c $(SRC_DIR)cpuid_asm.c $(SRC_DIR)uarch.c
|
SOURCE += $(COMMON_SRC) $(SRC_DIR)cpuid.c $(SRC_DIR)apic.c $(SRC_DIR)cpuid_asm.c $(SRC_DIR)uarch.c
|
||||||
HEADERS += $(COMMON_HDR) $(SRC_DIR)cpuid.h $(SRC_DIR)apic.h $(SRC_DIR)cpuid_asm.h $(SRC_DIR)uarch.h
|
HEADERS += $(COMMON_HDR) $(SRC_DIR)cpuid.h $(SRC_DIR)apic.h $(SRC_DIR)cpuid_asm.h $(SRC_DIR)uarch.h
|
||||||
|
|||||||
@@ -4,6 +4,9 @@
|
|||||||
#elif defined __linux__
|
#elif defined __linux__
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
|
#elif defined __FreeBSD__
|
||||||
|
#include <sys/param.h>
|
||||||
|
#include <sys/cpuset.h>
|
||||||
#elif defined __APPLE__
|
#elif defined __APPLE__
|
||||||
#define UNUSED(x) (void)(x)
|
#define UNUSED(x) (void)(x)
|
||||||
#endif
|
#endif
|
||||||
@@ -76,7 +79,7 @@ bool bind_to_cpu(int cpu_id) {
|
|||||||
HANDLE process = GetCurrentProcess();
|
HANDLE process = GetCurrentProcess();
|
||||||
DWORD_PTR processAffinityMask = 1 << cpu_id;
|
DWORD_PTR processAffinityMask = 1 << cpu_id;
|
||||||
return SetProcessAffinityMask(process, processAffinityMask);
|
return SetProcessAffinityMask(process, processAffinityMask);
|
||||||
#else
|
#elif defined __linux__
|
||||||
cpu_set_t currentCPU;
|
cpu_set_t currentCPU;
|
||||||
CPU_ZERO(¤tCPU);
|
CPU_ZERO(¤tCPU);
|
||||||
CPU_SET(cpu_id, ¤tCPU);
|
CPU_SET(cpu_id, ¤tCPU);
|
||||||
@@ -85,6 +88,15 @@ bool bind_to_cpu(int cpu_id) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
#elif defined __FreeBSD__
|
||||||
|
cpuset_t currentCPU;
|
||||||
|
CPU_ZERO(¤tCPU);
|
||||||
|
CPU_SET(cpu_id, ¤tCPU);
|
||||||
|
if(cpuset_setaffinity(CPU_LEVEL_WHICH, CPU_WHICH_TID, -1, sizeof(cpuset_t), ¤tCPU) == -1) {
|
||||||
|
perror("cpuset_setaffinity");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user