mirror of
https://github.com/Dr-Noob/cpufetch.git
synced 2026-03-25 16:00:39 +01:00
Merge remote-tracking branch 'origin/master' into bugfix2
This commit is contained in:
31
Makefile
31
Makefile
@@ -1,8 +1,10 @@
|
|||||||
CXX=gcc
|
CC=gcc
|
||||||
|
|
||||||
CXXFLAGS=-Wall -Wextra -Werror -pedantic -fstack-protector-all -pedantic -std=c99
|
CFLAGS=-Wall -Wextra -Werror -pedantic -fstack-protector-all -pedantic -std=c99
|
||||||
SANITY_FLAGS=-Wfloat-equal -Wshadow -Wpointer-arith
|
SANITY_FLAGS=-Wfloat-equal -Wshadow -Wpointer-arith
|
||||||
|
|
||||||
|
PREFIX ?= /usr
|
||||||
|
|
||||||
SRC_COMMON=src/common/
|
SRC_COMMON=src/common/
|
||||||
|
|
||||||
COMMON_SRC = $(SRC_COMMON)main.c $(SRC_COMMON)cpu.c $(SRC_COMMON)udev.c $(SRC_COMMON)printer.c $(SRC_COMMON)args.c $(SRC_COMMON)global.c
|
COMMON_SRC = $(SRC_COMMON)main.c $(SRC_COMMON)cpu.c $(SRC_COMMON)udev.c $(SRC_COMMON)printer.c $(SRC_COMMON)args.c $(SRC_COMMON)global.c
|
||||||
@@ -10,16 +12,16 @@ 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), x86_64)
|
ifeq ($(arch), $(filter $(arch), x86_64 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
|
||||||
CXXFLAGS += -DARCH_X86
|
CFLAGS += -DARCH_X86
|
||||||
else
|
else
|
||||||
SRC_DIR=src/arm/
|
SRC_DIR=src/arm/
|
||||||
SOURCE += $(COMMON_SRC) $(SRC_DIR)midr.c $(SRC_DIR)uarch.c $(SRC_DIR)soc.c $(SRC_DIR)udev.c
|
SOURCE += $(COMMON_SRC) $(SRC_DIR)midr.c $(SRC_DIR)uarch.c $(SRC_DIR)soc.c $(SRC_DIR)udev.c
|
||||||
HEADERS += $(COMMON_HDR) $(SRC_DIR)midr.h $(SRC_DIR)uarch.h $(SRC_DIR)soc.h $(SRC_DIR)udev.c $(SRC_DIR)socs.h
|
HEADERS += $(COMMON_HDR) $(SRC_DIR)midr.h $(SRC_DIR)uarch.h $(SRC_DIR)soc.h $(SRC_DIR)udev.c $(SRC_DIR)socs.h
|
||||||
CXXFLAGS += -DARCH_ARM -Wno-unused-parameter
|
CFLAGS += -DARCH_ARM -Wno-unused-parameter
|
||||||
endif
|
endif
|
||||||
|
|
||||||
OUTPUT=cpufetch
|
OUTPUT=cpufetch
|
||||||
@@ -28,21 +30,21 @@ else
|
|||||||
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
|
||||||
CXXFLAGS += -DARCH_X86
|
CFLAGS += -DARCH_X86
|
||||||
SANITY_FLAGS += -Wno-pedantic-ms-format
|
SANITY_FLAGS += -Wno-pedantic-ms-format
|
||||||
OUTPUT=cpufetch.exe
|
OUTPUT=cpufetch.exe
|
||||||
endif
|
endif
|
||||||
|
|
||||||
all: $(OUTPUT)
|
all: $(OUTPUT)
|
||||||
|
|
||||||
debug: CXXFLAGS += -g -O0
|
debug: CFLAGS += -g -O0
|
||||||
debug: $(OUTPUT)
|
debug: $(OUTPUT)
|
||||||
|
|
||||||
release: CXXFLAGS += -static -O3
|
release: CFLAGS += -static -O3
|
||||||
release: $(OUTPUT)
|
release: $(OUTPUT)
|
||||||
|
|
||||||
$(OUTPUT): Makefile $(SOURCE) $(HEADERS)
|
$(OUTPUT): Makefile $(SOURCE) $(HEADERS)
|
||||||
$(CXX) $(CXXFLAGS) $(SANITY_FLAGS) $(SOURCE) -o $(OUTPUT)
|
$(CC) $(CFLAGS) $(SANITY_FLAGS) $(SOURCE) -o $(OUTPUT)
|
||||||
|
|
||||||
run: $(OUTPUT)
|
run: $(OUTPUT)
|
||||||
./$(OUTPUT)
|
./$(OUTPUT)
|
||||||
@@ -51,6 +53,11 @@ clean:
|
|||||||
@rm $(OUTPUT)
|
@rm $(OUTPUT)
|
||||||
|
|
||||||
install: $(OUTPUT)
|
install: $(OUTPUT)
|
||||||
install -Dm755 "cpufetch" "/usr/bin/cpufetch"
|
install -Dm755 "cpufetch" "$(PREFIX)/bin/cpufetch"
|
||||||
install -Dm644 "LICENSE" "/usr/share/licenses/cpufetch-git/LICENSE"
|
install -Dm644 "LICENSE" "$(PREFIX)/share/licenses/cpufetch-git/LICENSE"
|
||||||
install -Dm644 "cpufetch.8" "/usr/share/man/man8/cpufetch.8.gz"
|
install -Dm644 "cpufetch.8" "$(PREFIX)/share/man/man8/cpufetch.8.gz"
|
||||||
|
|
||||||
|
uninstall:
|
||||||
|
rm -f "$(PREFIX)/bin/cpufetch"
|
||||||
|
rm -f "$(PREFIX)/share/licenses/cpufetch-git/LICENSE"
|
||||||
|
rm -f "$(PREFIX)/share/man/man8/cpufetch.8.gz"
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||

|

|
||||||
[](https://opensource.org/licenses/MIT)
|
[](https://opensource.org/licenses/MIT)
|
||||||
|
|
||||||
<h4 align="center">Simplistic yet fancy CPU architecture fetching tool</h4>
|
<h4 align="center">Simple yet fancy CPU architecture fetching tool</h4>
|
||||||
|
|
||||||
|
|
||||||

|

|
||||||
|
|||||||
@@ -6,7 +6,7 @@ cpufetch \- manual page for cpufetch v0.96 (x86_64 build)
|
|||||||
.B cpufetch
|
.B cpufetch
|
||||||
[\fI\,OPTION\/\fR]...
|
[\fI\,OPTION\/\fR]...
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
Simplistic yet fancy CPU architecture fetching tool
|
Simple yet fancy CPU architecture fetching tool
|
||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
.TP
|
.TP
|
||||||
\fB\-c\fR, \fB\-\-color\fR
|
\fB\-c\fR, \fB\-\-color\fR
|
||||||
|
|||||||
@@ -436,12 +436,21 @@ bool match_special(char* soc_name, struct system_on_chip* soc) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Snapdragon 730 reported as "Qualcomm Technologies, Inc. SDMMAGPIE"
|
||||||
|
if((tmp = strstr(soc_name, "SDMMAGPIE")) != NULL) {
|
||||||
|
fill_soc(soc, "730", SOC_SNAPD_SM7150_AA, 8);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct system_on_chip* parse_soc_from_string(struct system_on_chip* soc) {
|
struct system_on_chip* parse_soc_from_string(struct system_on_chip* soc) {
|
||||||
char* raw_name = soc->raw_name;
|
char* raw_name = soc->raw_name;
|
||||||
|
|
||||||
|
if(match_special(raw_name, soc))
|
||||||
|
return soc;
|
||||||
|
|
||||||
if (match_qualcomm(raw_name, soc))
|
if (match_qualcomm(raw_name, soc))
|
||||||
return soc;
|
return soc;
|
||||||
|
|
||||||
@@ -454,10 +463,7 @@ struct system_on_chip* parse_soc_from_string(struct system_on_chip* soc) {
|
|||||||
if(match_hisilicon(raw_name, soc))
|
if(match_hisilicon(raw_name, soc))
|
||||||
return soc;
|
return soc;
|
||||||
|
|
||||||
if(match_broadcom(raw_name, soc))
|
match_broadcom(raw_name, soc);
|
||||||
return soc;
|
|
||||||
|
|
||||||
match_special(raw_name, soc);
|
|
||||||
|
|
||||||
return soc;
|
return soc;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ void print_help(char *argv[]) {
|
|||||||
int max_len = max_arg_str_length();
|
int max_len = max_arg_str_length();
|
||||||
|
|
||||||
printf("Usage: %s [OPTION]...\n", argv[0]);
|
printf("Usage: %s [OPTION]...\n", argv[0]);
|
||||||
printf("Simplistic yet fancy CPU architecture fetching tool\n\n");
|
printf("Simple yet fancy CPU architecture fetching tool\n\n");
|
||||||
|
|
||||||
printf("Options: \n");
|
printf("Options: \n");
|
||||||
printf(" -%c, --%s %*s Set the color scheme (by default, cpufetch uses the system color scheme)\n", c[ARG_COLOR], t[ARG_COLOR], (int) (max_len-strlen(t[ARG_COLOR])), "");
|
printf(" -%c, --%s %*s Set the color scheme (by default, cpufetch uses the system color scheme)\n", c[ARG_COLOR], t[ARG_COLOR], (int) (max_len-strlen(t[ARG_COLOR])), "");
|
||||||
|
|||||||
@@ -364,13 +364,12 @@ bool get_cache_topology_amd(struct cpuInfo* cpu, struct topology* topo) {
|
|||||||
topo->cach->L3->num_caches = topo->logical_cores / num_sharing_cache;
|
topo->cach->L3->num_caches = topo->logical_cores / num_sharing_cache;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printBug("Found unified cache at level %d (expected == 2 or 3)", cache_level);
|
printWarn("Found unknown unified cache at level %d", cache_level);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: // Unknown Type Cache
|
default: // Unknown cache type
|
||||||
printBug("Unknown Type Cache found at ID %d", i);
|
printBug("Unknown cache type %d with level %d found at i=%d", cache_type, cache_level, i);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -427,7 +426,7 @@ struct topology* get_topology_info(struct cpuInfo* cpu, struct cache* cach) {
|
|||||||
get_topology_from_apic(cpu, topo);
|
get_topology_from_apic(cpu, topo);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printErr("Can't read topology information from cpuid (needed level is 0x%.8X, max is 0x%.8X)", 0x00000001, cpu->maxLevels);
|
printWarn("Can't read topology information from cpuid (needed level is 0x%.8X, max is 0x%.8X)", 0x00000001, cpu->maxLevels);
|
||||||
topo->physical_cores = 1;
|
topo->physical_cores = 1;
|
||||||
topo->logical_cores = 1;
|
topo->logical_cores = 1;
|
||||||
topo->smt_available = 1;
|
topo->smt_available = 1;
|
||||||
@@ -451,7 +450,7 @@ struct topology* get_topology_info(struct cpuInfo* cpu, struct cache* cach) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printErr("Can't read topology information from cpuid (needed extended level is 0x%.8X, max is 0x%.8X)", 0x80000008, cpu->maxExtendedLevels);
|
printWarn("Can't read topology information from cpuid (needed extended level is 0x%.8X, max is 0x%.8X)", 0x80000008, cpu->maxExtendedLevels);
|
||||||
topo->physical_cores = 1;
|
topo->physical_cores = 1;
|
||||||
topo->logical_cores = 1;
|
topo->logical_cores = 1;
|
||||||
topo->smt_supported = 1;
|
topo->smt_supported = 1;
|
||||||
@@ -573,13 +572,12 @@ struct cache* get_cache_info_general(struct cache* cach, uint32_t level) {
|
|||||||
cach->L3->exists = true;
|
cach->L3->exists = true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printBug("Found unified cache at level %d (expected == 2 or 3)", cache_level);
|
printWarn("Found unknown unified cache at level %d (size is %d bytes)", cache_level, cache_total_size);
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: // Unknown Type Cache
|
default: // Unknown cache type
|
||||||
printBug("Unknown Type Cache found at ID %d", i);
|
printBug("Unknown cache type %d with level %d found at i=%d", cache_type, cache_level, i);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -602,7 +600,7 @@ struct cache* get_cache_info(struct cpuInfo* cpu) {
|
|||||||
if(cpu->cpu_vendor == CPU_VENDOR_INTEL) {
|
if(cpu->cpu_vendor == CPU_VENDOR_INTEL) {
|
||||||
level = 0x00000004;
|
level = 0x00000004;
|
||||||
if(cpu->maxLevels < level) {
|
if(cpu->maxLevels < level) {
|
||||||
printErr("Can't read cache information from cpuid (needed level is 0x%.8X, max is 0x%.8X)", level, cpu->maxLevels);
|
printWarn("Can't read cache information from cpuid (needed level is 0x%.8X, max is 0x%.8X)", level, cpu->maxLevels);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -615,7 +613,7 @@ struct cache* get_cache_info(struct cpuInfo* cpu) {
|
|||||||
printWarn("Can't read cache information from cpuid (needed extended level is 0x%.8X, max is 0x%.8X)", level, cpu->maxExtendedLevels);
|
printWarn("Can't read cache information from cpuid (needed extended level is 0x%.8X, max is 0x%.8X)", level, cpu->maxExtendedLevels);
|
||||||
level = 0x80000006;
|
level = 0x80000006;
|
||||||
if(cpu->maxExtendedLevels < level) {
|
if(cpu->maxExtendedLevels < level) {
|
||||||
printErr("Can't read cache information from cpuid using old method (needed extended level is 0x%.8X, max is 0x%.8X)", level, cpu->maxExtendedLevels);
|
printWarn("Can't read cache information from cpuid using old method (needed extended level is 0x%.8X, max is 0x%.8X)", level, cpu->maxExtendedLevels);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
printWarn("Fallback to old method using 0x%.8X and 0x%.8X", level-1, level);
|
printWarn("Fallback to old method using 0x%.8X and 0x%.8X", level-1, level);
|
||||||
@@ -656,17 +654,8 @@ struct frequency* get_frequency_info(struct cpuInfo* cpu) {
|
|||||||
struct frequency* freq = malloc(sizeof(struct frequency));
|
struct frequency* freq = malloc(sizeof(struct frequency));
|
||||||
|
|
||||||
if(cpu->maxLevels < 0x00000016) {
|
if(cpu->maxLevels < 0x00000016) {
|
||||||
#ifdef _WIN32
|
#if defined (_WIN32) || defined (__APPLE__)
|
||||||
if(cpu->hv->present) {
|
printWarn("Can't read frequency information from cpuid (needed level is 0x%.8X, max is 0x%.8X)", 0x00000016, cpu->maxLevels);
|
||||||
printWarn("Can't read frequency information from cpuid (needed level is 0x%.8X, max is 0x%.8X)", 0x00000016, cpu->maxLevels);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
printErr("Can't read frequency information from cpuid (needed level is 0x%.8X, max is 0x%.8X)", 0x00000016, cpu->maxLevels);
|
|
||||||
}
|
|
||||||
freq->base = UNKNOWN_FREQ;
|
|
||||||
freq->max = UNKNOWN_FREQ;
|
|
||||||
#elif defined __APPLE__
|
|
||||||
printErr("Can't read frequency information from cpuid (needed level is 0x%.8X, max is 0x%.8X)", 0x00000016, cpu->maxLevels);
|
|
||||||
freq->base = UNKNOWN_FREQ;
|
freq->base = UNKNOWN_FREQ;
|
||||||
freq->max = UNKNOWN_FREQ;
|
freq->max = UNKNOWN_FREQ;
|
||||||
#else
|
#else
|
||||||
|
|||||||
Reference in New Issue
Block a user