diff --git a/src/common/global.c b/src/common/global.c index 74feb8b..6d39ed7 100644 --- a/src/common/global.c +++ b/src/common/global.c @@ -21,7 +21,7 @@ #endif #ifdef ARCH_X86 - static const char* ARCH_STR = "x86_64 build"; + static const char* ARCH_STR = "x86 / x86_64 build"; #include "../x86/cpuid.h" #elif ARCH_PPC static const char* ARCH_STR = "PowerPC build"; diff --git a/src/x86/cpuid.c b/src/x86/cpuid.c index 139fa22..2636707 100644 --- a/src/x86/cpuid.c +++ b/src/x86/cpuid.c @@ -486,8 +486,8 @@ struct cpuInfo* get_cpu_info(void) { cpu->cpu_name = get_str_cpu_name_internal(); } else { + cpu->cpu_name = NULL; printWarn("Can't read CPU name from cpuid (needed extended level is 0x%.8X, max is 0x%.8X)", 0x80000004, cpu->maxExtendedLevels); - cpu->cpu_name = infer_cpu_name_from_uarch(cpu->arch); } cpu->topology_extensions = false; @@ -537,12 +537,17 @@ struct cpuInfo* get_cpu_info(void) { ptr->first_core_id = first_core; ptr->feat = get_features_info(ptr); - // If any field of the struct is NULL, - // return inmideately, as further functions - // require valid fields (cach, topo, etc) ptr->arch = get_cpu_uarch(ptr); ptr->freq = get_frequency_info(ptr); + if (cpu->cpu_name == NULL && ptr == cpu) { + // If we couldnt read CPU name from cpuid, infer it now + cpu->cpu_name = infer_cpu_name_from_uarch(cpu->arch); + } + + // If any field of the struct is NULL, + // return early, as next functions + // require non NULL fields in cach and topo ptr->cach = get_cache_info(ptr); if(ptr->cach == NULL) return cpu;