Skip to content

Commit 9a0f76a

Browse files
authored
Merge pull request #5746 from chenx97/mips-fix-implicit-declaration
MIPS: fix implicit declarations found in the cpuinfo detector
2 parents 75a9960 + a04ea2b commit 9a0f76a

File tree

2 files changed

+79
-81
lines changed

2 files changed

+79
-81
lines changed

cpuid_mips.c

Lines changed: 40 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*****************************************************************************
2-
Copyright (c) 2011-2014, The OpenBLAS Project
2+
Copyright (c) 2011-2026, The OpenBLAS Project
33
All rights reserved.
44
55
Redistribution 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
2121
THIS 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+
139173
void 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-

cpuid_mips64.c

Lines changed: 39 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*****************************************************************************
2-
Copyright (c) 2011-2014, The OpenBLAS Project
2+
Copyright (c) 2011-2026, The OpenBLAS Project
33
All rights reserved.
44
55
Redistribution 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
2121
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
@@ -145,13 +145,47 @@ void get_subarchitecture(void){
145145
printf("SICORTEX");
146146
}else{
147147
printf("MIPS64_GENERIC");
148-
}
148+
}
149149
}
150150

151151
void get_subdirname(void){
152152
printf("mips64");
153153
}
154154

155+
int get_feature(char *search) {
156+
157+
#ifdef __linux
158+
FILE *infile;
159+
char buffer[2048], *p, *t;
160+
p = (char *)NULL;
161+
162+
infile = fopen("/proc/cpuinfo", "r");
163+
164+
while (fgets(buffer, sizeof(buffer), infile)) {
165+
166+
if (!strncmp("Features", buffer, 8) ||
167+
!strncmp("ASEs implemented", buffer, 16)) {
168+
p = strchr(buffer, ':') + 2;
169+
break;
170+
}
171+
}
172+
173+
fclose(infile);
174+
175+
if (p == NULL)
176+
return 0;
177+
178+
t = strtok(p, " ");
179+
while (t = strtok(NULL, " ")) {
180+
if (strstr(t, search)) {
181+
return (1);
182+
}
183+
}
184+
185+
#endif
186+
return (0);
187+
}
188+
155189
void get_cpuconfig(void){
156190
if(detect()==CPU_LOONGSON3R3) {
157191
printf("#define LOONGSON3R3\n");
@@ -228,38 +262,3 @@ void get_libname(void){
228262
printf("mips64_generic\n");
229263
}
230264
}
231-
232-
int get_feature(char *search)
233-
{
234-
235-
#ifdef __linux
236-
FILE *infile;
237-
char buffer[2048], *p,*t;
238-
p = (char *) NULL ;
239-
240-
infile = fopen("/proc/cpuinfo", "r");
241-
242-
while (fgets(buffer, sizeof(buffer), infile))
243-
{
244-
245-
if (!strncmp("Features", buffer, 8) || !strncmp("ASEs implemented", buffer, 16))
246-
{
247-
p = strchr(buffer, ':') + 2;
248-
break;
249-
}
250-
}
251-
252-
fclose(infile);
253-
254-
if( p == NULL ) return 0;
255-
256-
t = strtok(p," ");
257-
while( t = strtok(NULL," "))
258-
{
259-
if (strstr(t, search)) { return(1); }
260-
}
261-
262-
#endif
263-
return(0);
264-
}
265-

0 commit comments

Comments
 (0)