about summary refs log tree commit diff stats
path: root/src/tools
diff options
context:
space:
mode:
authorYang Liu <liuyang22@iscas.ac.cn>2024-12-26 21:40:04 +0800
committerGitHub <noreply@github.com>2024-12-26 14:40:04 +0100
commitcf24eaf9d2bcb739aaec5b4c75d6bb09b4b902ae (patch)
treea9ac91cf3005c7e867ef87ec7cc0a2bdd172e6e8 /src/tools
parentcd1ac51b7932dbd2eb158e67f7dc6bee71163b96 (diff)
downloadbox64-cf24eaf9d2bcb739aaec5b4c75d6bb09b4b902ae.tar.gz
box64-cf24eaf9d2bcb739aaec5b4c75d6bb09b4b902ae.zip
[LA64_DYNAREC] Added hardware wall-clock support (#2216)
* [LA64_DYNAREC] Added hardware wall-clock support

* Refined multi-language support
Diffstat (limited to 'src/tools')
-rw-r--r--src/tools/my_cpuid.c10
1 files changed, 2 insertions, 8 deletions
diff --git a/src/tools/my_cpuid.c b/src/tools/my_cpuid.c
index b30466f3..b201bd71 100644
--- a/src/tools/my_cpuid.c
+++ b/src/tools/my_cpuid.c
@@ -134,7 +134,7 @@ const char* getCpuName()
     }
     setenv("BOX64_CPUNAME", name, 1);   // temporary set
     #ifndef STATICBUILD
-    FILE* f = popen("lscpu | grep \"Model name:\" | sed -r 's/Model name:\\s{1,}//g'", "r");
+    FILE* f = popen("LC_ALL=C lscpu | grep -i \"model name:\" | head -n 1 | sed -r 's/(model name:)\\s{1,}//gi'", "r");
     if(f) {
         char tmp[200] = "";
         ssize_t s = fread(tmp, 1, 200, f);
@@ -145,9 +145,6 @@ const char* getCpuName()
                 // trim ending
                 while(strlen(tmp) && tmp[strlen(tmp)-1]=='\n')
                     tmp[strlen(tmp)-1] = 0;
-                // incase multiple cpu type are present, there will be multiple lines
-                while(strchr(tmp, '\n'))
-                    *strchr(tmp,'\n') = ' ';
                 strncpy(name, tmp, 199);
             }
             setenv("BOX64_CPUNAME", name, 1);
@@ -155,7 +152,7 @@ const char* getCpuName()
         }
     }
     // failled, try to get architecture at least
-    f = popen("lscpu | grep \"Architecture:\" | sed -r 's/Architecture:\\s{1,}//g'", "r");
+    f = popen("LC_ALL=C lscpu | grep -i \"architecture:\" | head -n 1 | sed -r 's/(architecture:)\\s{1,}//gi'", "r");
     if(f) {
         char tmp[200] = "";
         ssize_t s = fread(tmp, 1, 200, f);
@@ -165,9 +162,6 @@ const char* getCpuName()
             // trim ending
             while(strlen(tmp) && tmp[strlen(tmp)-1]=='\n')
                 tmp[strlen(tmp)-1] = 0;
-            // incase multiple cpu type are present, there will be multiple lines
-            while(strchr(tmp, '\n'))
-                *strchr(tmp,'\n') = ' ';
             snprintf(name, 199, "unknown %s cpu", tmp);
             setenv("BOX64_CPUNAME", name, 1);
             return name;