mirror of
https://github.com/Dr-Noob/cpufetch.git
synced 2026-03-25 16:00:39 +01:00
[v1.00][X86] Show unknown string when the number of cores cannot be retrieved (like #119)
This commit is contained in:
@@ -324,7 +324,7 @@ bool fill_apic_ids(uint32_t* apic_ids, int n, bool x2apic_id) {
|
||||
|
||||
for(int i=0; i < n; i++) {
|
||||
if(!bind_to_cpu(i)) {
|
||||
printErr("Failed binding to CPU %d", i);
|
||||
printErr("Failed binding the process to CPU %d", i);
|
||||
return false;
|
||||
}
|
||||
apic_ids[i] = get_apic_id(x2apic_id);
|
||||
@@ -385,8 +385,13 @@ bool get_topology_from_apic(struct cpuInfo* cpu, struct topology* topo) {
|
||||
|
||||
get_cache_topology_from_apic(topo);
|
||||
|
||||
if(!fill_apic_ids(apic_ids, topo->total_cores, x2apic_id))
|
||||
if(!fill_apic_ids(apic_ids, topo->total_cores, x2apic_id)) {
|
||||
topo->logical_cores = UNKNOWN_DATA;
|
||||
topo->physical_cores = UNKNOWN_DATA;
|
||||
topo->smt_available = 1;
|
||||
topo->smt_supported = 1;
|
||||
return false;
|
||||
}
|
||||
|
||||
for(int i=0; i < topo->total_cores; i++) {
|
||||
apic_id = apic_ids[i];
|
||||
|
||||
@@ -203,7 +203,7 @@ int64_t get_peak_performance(struct cpuInfo* cpu, struct topology* topo, int64_t
|
||||
#endif
|
||||
|
||||
//First, check we have consistent data
|
||||
if(freq == UNKNOWN_FREQ) {
|
||||
if(freq == UNKNOWN_DATA || topo->logical_cores == UNKNOWN_DATA) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -710,16 +710,16 @@ struct frequency* get_frequency_info(struct cpuInfo* cpu) {
|
||||
if(cpu->maxLevels < 0x00000016) {
|
||||
#if defined (_WIN32) || defined (__APPLE__)
|
||||
printWarn("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;
|
||||
freq->base = UNKNOWN_DATA;
|
||||
freq->max = UNKNOWN_DATA;
|
||||
#else
|
||||
printWarn("Can't read frequency information from cpuid (needed level is 0x%.8X, max is 0x%.8X). Using udev", 0x00000016, cpu->maxLevels);
|
||||
freq->base = UNKNOWN_FREQ;
|
||||
freq->base = UNKNOWN_DATA;
|
||||
freq->max = get_max_freq_from_file(0);
|
||||
|
||||
if(freq->max == 0) {
|
||||
printWarn("Read max CPU frequency from udev and got 0 MHz");
|
||||
freq->max = UNKNOWN_FREQ;
|
||||
freq->max = UNKNOWN_DATA;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -736,7 +736,7 @@ struct frequency* get_frequency_info(struct cpuInfo* cpu) {
|
||||
|
||||
if(freq->base == 0) {
|
||||
printWarn("Read base CPU frequency from CPUID and got 0 MHz");
|
||||
freq->base = UNKNOWN_FREQ;
|
||||
freq->base = UNKNOWN_DATA;
|
||||
}
|
||||
if(freq->max == 0) {
|
||||
printWarn("Read max CPU frequency from CPUID and got 0 MHz");
|
||||
@@ -746,10 +746,10 @@ struct frequency* get_frequency_info(struct cpuInfo* cpu) {
|
||||
|
||||
if(freq->max == 0) {
|
||||
printWarn("Read max CPU frequency from udev and got 0 MHz");
|
||||
freq->max = UNKNOWN_FREQ;
|
||||
freq->max = UNKNOWN_DATA;
|
||||
}
|
||||
#else
|
||||
freq->max = UNKNOWN_FREQ;
|
||||
freq->max = UNKNOWN_DATA;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -771,7 +771,11 @@ char* get_str_topology(struct cpuInfo* cpu, struct topology* topo, bool dual_soc
|
||||
int topo_sockets = dual_socket ? topo->sockets : 1;
|
||||
char* string;
|
||||
|
||||
if(topo->smt_supported > 1) {
|
||||
if(topo->logical_cores == UNKNOWN_DATA) {
|
||||
string = emalloc(sizeof(char) * (strlen(STRING_UNKNOWN) + 1));
|
||||
strcpy(string, STRING_UNKNOWN);
|
||||
}
|
||||
else if(topo->smt_supported > 1) {
|
||||
// 4 for digits, 21 for ' cores (SMT disabled)' which is the longest possible output
|
||||
uint32_t max_size = 4+21+1;
|
||||
string = emalloc(sizeof(char) * max_size);
|
||||
|
||||
Reference in New Issue
Block a user