11/*****************************************************************************
2- Copyright (c) 2011-2014 , The OpenBLAS Project
2+ Copyright (c) 2011-2026 , The OpenBLAS Project
33All rights reserved.
44
55Redistribution and use in source and binary forms, with or without
@@ -13,9 +13,9 @@ modification, are permitted provided that the following conditions are
1313 notice, this list of conditions and the following disclaimer in
1414 the documentation and/or other materials provided with the
1515 distribution.
16- 3. Neither the name of the OpenBLAS project nor the names of
17- its contributors may be used to endorse or promote products
18- derived from this software without specific prior written
16+ 3. Neither the name of the OpenBLAS project nor the names of
17+ its contributors may be used to endorse or promote products
18+ derived from this software without specific prior written
1919 permission.
2020
2121THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
@@ -109,7 +109,7 @@ int detect(void){
109109 return CPU_1004K ;
110110 } else if (strstr (p , " 24K" )) {
111111 return CPU_24K ;
112- } else
112+ } else
113113 return CPU_UNKNOWN ;
114114 }
115115#endif
@@ -136,6 +136,40 @@ void get_subdirname(void){
136136 printf ("mips" );
137137}
138138
139+ int get_feature (char * search ) {
140+
141+ #ifdef __linux
142+ FILE * infile ;
143+ char buffer [2048 ], * p , * t ;
144+ p = (char * )NULL ;
145+
146+ infile = fopen ("/proc/cpuinfo" , "r" );
147+
148+ while (fgets (buffer , sizeof (buffer ), infile )) {
149+
150+ if (!strncmp ("Features" , buffer , 8 ) ||
151+ !strncmp ("ASEs implemented" , buffer , 16 )) {
152+ p = strchr (buffer , ':' ) + 2 ;
153+ break ;
154+ }
155+ }
156+
157+ fclose (infile );
158+
159+ if (p == NULL )
160+ return 0 ;
161+
162+ t = strtok (p , " " );
163+ while (t = strtok (NULL , " " )) {
164+ if (strstr (t , search )) {
165+ return (1 );
166+ }
167+ }
168+
169+ #endif
170+ return (0 );
171+ }
172+
139173void get_cpuconfig (void ){
140174 if (detect ()== CPU_P5600 ){
141175 printf ("#define P5600\n" );
@@ -165,7 +199,7 @@ void get_cpuconfig(void){
165199 }else {
166200 printf ("#define UNKNOWN\n" );
167201 }
168- #ifndef NO_MSA
202+ #ifndef NO_MSA
169203 if (get_feature ("msa" )) printf ("#define HAVE_MSA\n" );
170204#endif
171205}
@@ -181,38 +215,3 @@ void get_libname(void){
181215 printf ("mips\n" );
182216 }
183217}
184-
185- int get_feature (char * search )
186- {
187-
188- #ifdef __linux
189- FILE * infile ;
190- char buffer [2048 ], * p ,* t ;
191- p = (char * ) NULL ;
192-
193- infile = fopen ("/proc/cpuinfo" , "r" );
194-
195- while (fgets (buffer , sizeof (buffer ), infile ))
196- {
197-
198- if (!strncmp ("Features" , buffer , 8 ) || !strncmp ("ASEs implemented" , buffer , 16 ))
199- {
200- p = strchr (buffer , ':' ) + 2 ;
201- break ;
202- }
203- }
204-
205- fclose (infile );
206-
207- if ( p == NULL ) return 0 ;
208-
209- t = strtok (p ," " );
210- while ( t = strtok (NULL ," " ))
211- {
212- if (strstr (t , search )) { return (1 ); }
213- }
214-
215- #endif
216- return (0 );
217- }
218-
0 commit comments