[v0.99][X86] Improve CPU abbreviate code

This commit is contained in:
Dr-Noob
2021-08-12 10:39:26 +02:00
parent 6d79a96fa8
commit ca5677a77f
5 changed files with 47 additions and 25 deletions

View File

@@ -34,9 +34,11 @@ int64_t get_freq(struct frequency* freq) {
#if defined(ARCH_X86) || defined(ARCH_PPC)
char* get_str_cpu_name(struct cpuInfo* cpu, bool fcpuname) {
if(cpu->cpu_vendor == CPU_VENDOR_INTEL && !fcpuname) {
abbreviate_intel_cpu_name(&cpu->cpu_name);
#ifdef ARCH_X86
if(!fcpuname) {
return get_str_cpu_name_abbreviated(cpu);
}
#endif
return cpu->cpu_name;
}

View File

@@ -73,6 +73,19 @@ int max(int a, int b) {
return a > b ? a : b;
}
char *strremove(char *str, const char *sub) {
char *p, *q, *r;
if (*sub && (q = r = strstr(str, sub)) != NULL) {
size_t len = strlen(sub);
while ((r = strstr(p = r + len, sub)) != NULL) {
memmove(q, p, r - p);
q += r - p;
}
memmove(q, p, strlen(p) + 1);
}
return str;
}
void* emalloc(size_t size) {
void* ptr = malloc(size);

View File

@@ -11,6 +11,7 @@ void printWarn(const char *fmt, ...);
void printErr(const char *fmt, ...);
void printBug(const char *fmt, ...);
int max(int a, int b);
char *strremove(char *str, const char *sub);
void* emalloc(size_t size);
void* ecalloc(size_t nmemb, size_t size);