From 2fd0a129c3b9eaf8dea25b32ee4fe9deef629963 Mon Sep 17 00:00:00 2001 From: Martin Kroeker Date: Thu, 26 Dec 2024 10:45:57 +0100 Subject: [PATCH] count and sort cpu models on big.little systems --- cpuid_arm64.c | 77 +++++++++++++++++++-------------------------------- 1 file changed, 28 insertions(+), 49 deletions(-) diff --git a/cpuid_arm64.c b/cpuid_arm64.c index fbb78e794..0d9254888 100644 --- a/cpuid_arm64.c +++ b/cpuid_arm64.c @@ -25,6 +25,7 @@ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *****************************************************************************/ +#include #include #ifdef __APPLE__ #include @@ -42,11 +43,9 @@ size_t length64=sizeof(value64); #define CPU_CORTEXA57 3 #define CPU_CORTEXA72 4 #define CPU_CORTEXA73 5 -#define CPU_CORTEXA76 23 #define CPU_NEOVERSEN1 11 #define CPU_NEOVERSEV1 16 #define CPU_NEOVERSEN2 17 -#define CPU_NEOVERSEV2 24 #define CPU_CORTEXX1 18 #define CPU_CORTEXX2 19 #define CPU_CORTEXA510 20 @@ -91,9 +90,7 @@ static char *cpuname[] = { "CORTEXX2", "CORTEXA510", "CORTEXA710", - "FT2000", - "CORTEXA76", - "NEOVERSEV2" + "FT2000" }; static char *cpuname_lower[] = { @@ -119,15 +116,13 @@ static char *cpuname_lower[] = { "cortexx2", "cortexa510", "cortexa710", - "ft2000", - "cortexa76", - "neoversev2" + "ft2000" }; int get_feature(char *search) { -#if defined( __linux ) || defined( __NetBSD__ ) +#ifdef __linux FILE *infile; char buffer[2048], *p,*t; p = (char *) NULL ; @@ -158,19 +153,29 @@ int get_feature(char *search) #endif return(0); } - +static int cpusort(const void *model1, const void *model2) +{ + return (*(int*)model2-*(int*)model1); +} int detect(void) { -#if defined( __linux ) || defined( __NetBSD__ ) - +#ifdef __linux + int n,i; + int cpucores[1024]; FILE *infile; - char buffer[512], *p, *cpu_part = NULL, *cpu_implementer = NULL; + char cpupart[6]; + char buffer[2048], *p, *cpu_part = NULL, *cpu_implementer = NULL; p = (char *) NULL ; - + infile = fopen("/proc/cpuinfo", "r"); while (fgets(buffer, sizeof(buffer), infile)) { if (!strncmp("processor", buffer, 9)) n++; } + fclose(infile); + for (i=0;i<1024;i++)cpucores[i]=0; + cpu_implementer=NULL; infile = fopen("/proc/cpuinfo", "r"); + for (i=0;i