diff --git a/cpuid_mips.c b/cpuid_mips.c index 77567a2e5f..3944934471 100644 --- a/cpuid_mips.c +++ b/cpuid_mips.c @@ -1,5 +1,5 @@ /***************************************************************************** -Copyright (c) 2011-2014, The OpenBLAS Project +Copyright (c) 2011-2026, The OpenBLAS Project All rights reserved. Redistribution and use in source and binary forms, with or without @@ -13,9 +13,9 @@ modification, are permitted provided that the following conditions are notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - 3. Neither the name of the OpenBLAS project nor the names of - its contributors may be used to endorse or promote products - derived from this software without specific prior written + 3. Neither the name of the OpenBLAS project nor the names of + its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" @@ -109,7 +109,7 @@ int detect(void){ return CPU_1004K; } else if (strstr(p, " 24K")) { return CPU_24K; - } else + } else return CPU_UNKNOWN; } #endif @@ -136,6 +136,40 @@ void get_subdirname(void){ printf("mips"); } +int get_feature(char *search) { + +#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("Features", buffer, 8) || + !strncmp("ASEs implemented", buffer, 16)) { + p = strchr(buffer, ':') + 2; + break; + } + } + + fclose(infile); + + if (p == NULL) + return 0; + + t = strtok(p, " "); + while (t = strtok(NULL, " ")) { + if (strstr(t, search)) { + return (1); + } + } + +#endif + return (0); +} + void get_cpuconfig(void){ if(detect()==CPU_P5600){ printf("#define P5600\n"); @@ -165,7 +199,7 @@ void get_cpuconfig(void){ }else{ printf("#define UNKNOWN\n"); } -#ifndef NO_MSA +#ifndef NO_MSA if (get_feature("msa")) printf("#define HAVE_MSA\n"); #endif } @@ -181,38 +215,3 @@ void get_libname(void){ printf("mips\n"); } } - -int get_feature(char *search) -{ - -#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("Features", buffer, 8) || !strncmp("ASEs implemented", buffer, 16)) - { - p = strchr(buffer, ':') + 2; - break; - } - } - - fclose(infile); - - if( p == NULL ) return 0; - - t = strtok(p," "); - while( t = strtok(NULL," ")) - { - if (strstr(t, search)) { return(1); } - } - -#endif - return(0); -} - diff --git a/cpuid_mips64.c b/cpuid_mips64.c index 8895cb1578..69921265b0 100644 --- a/cpuid_mips64.c +++ b/cpuid_mips64.c @@ -1,5 +1,5 @@ /***************************************************************************** -Copyright (c) 2011-2014, The OpenBLAS Project +Copyright (c) 2011-2026, The OpenBLAS Project All rights reserved. Redistribution and use in source and binary forms, with or without @@ -13,9 +13,9 @@ modification, are permitted provided that the following conditions are notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - 3. Neither the name of the OpenBLAS project nor the names of - its contributors may be used to endorse or promote products - derived from this software without specific prior written + 3. Neither the name of the OpenBLAS project nor the names of + its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" @@ -145,13 +145,47 @@ void get_subarchitecture(void){ printf("SICORTEX"); }else{ printf("MIPS64_GENERIC"); - } + } } void get_subdirname(void){ printf("mips64"); } +int get_feature(char *search) { + +#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("Features", buffer, 8) || + !strncmp("ASEs implemented", buffer, 16)) { + p = strchr(buffer, ':') + 2; + break; + } + } + + fclose(infile); + + if (p == NULL) + return 0; + + t = strtok(p, " "); + while (t = strtok(NULL, " ")) { + if (strstr(t, search)) { + return (1); + } + } + +#endif + return (0); +} + void get_cpuconfig(void){ if(detect()==CPU_LOONGSON3R3) { printf("#define LOONGSON3R3\n"); @@ -228,38 +262,3 @@ void get_libname(void){ printf("mips64_generic\n"); } } - -int get_feature(char *search) -{ - -#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("Features", buffer, 8) || !strncmp("ASEs implemented", buffer, 16)) - { - p = strchr(buffer, ':') + 2; - break; - } - } - - fclose(infile); - - if( p == NULL ) return 0; - - t = strtok(p," "); - while( t = strtok(NULL," ")) - { - if (strstr(t, search)) { return(1); } - } - -#endif - return(0); -} -