From 1826d3e3f0a0a677837bd887fb621fe1d8e50357 Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Tue, 2 Apr 2024 17:46:22 +0200 Subject: [PATCH] Update cpuid_loongarch64.c --- cpuid_loongarch64.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/cpuid_loongarch64.c b/cpuid_loongarch64.c index 38055558c..a532a8e1a 100644 --- a/cpuid_loongarch64.c +++ b/cpuid_loongarch64.c @@ -93,6 +93,29 @@ void get_subdirname(void) { printf("loongarch64"); } +void get_cpucount(void) +{ + int n=0; + +#ifdef __linux + FILE *infile; + char buffer[2048], *p,*t; + p = (char *) NULL ; + + infile = fopen("/proc/cpuinfo", "r"); + + while (fgets(buffer, sizeof(buffer), infile)) + { + if (!strncmp("processor", buffer, 9)) + n++; + } + + fclose(infile); + + printf("#define NUM_CORES %d\n",n); +#endif +} + void get_cpuconfig(void) { uint32_t hwcaps = 0; int d = detect(); @@ -135,6 +158,7 @@ void get_cpuconfig(void) { hwcaps = (uint32_t)getauxval( AT_HWCAP ); if (hwcaps & LA_HWCAP_LSX) printf("#define HAVE_LSX\n"); if (hwcaps & LA_HWCAP_LASX) printf("#define HAVE_LASX\n"); + get_cpucount(); } void get_libname(void){