@@ -138,10 +138,10 @@ static void detectArmName(FILE* cpuinfo, FFCPUResult* cpu, uint32_t implId)
138138#endif
139139
140140static const char * parseCpuInfo (
141- FILE * cpuinfo ,
142- FFCPUResult * cpu ,
143- FFstrbuf * physicalCoresBuffer ,
144- FFstrbuf * cpuMHz ,
141+ FF_MAYBE_UNUSED FILE * cpuinfo ,
142+ FF_MAYBE_UNUSED FFCPUResult * cpu ,
143+ FF_MAYBE_UNUSED FFstrbuf * physicalCoresBuffer ,
144+ FF_MAYBE_UNUSED FFstrbuf * cpuMHz ,
145145 FF_MAYBE_UNUSED FFstrbuf * cpuIsa ,
146146 FF_MAYBE_UNUSED FFstrbuf * cpuUarch ,
147147 FF_MAYBE_UNUSED FFstrbuf * cpuImplementer )
@@ -153,21 +153,25 @@ static const char* parseCpuInfo(
153153 {
154154 //Stop after reasonable information is acquired
155155 if ((* line == '\0' || * line == '\n' )
156- #if __ANDROID__ && __arm__
157- && cpu -> name .length > 0 // #1202
156+ #if __arm__ || __loongarch__
157+ && cpu -> name .length > 0 // #1202 #1204
158158 #endif
159159 )
160160 break ;
161161
162162 (void )(
163- ffParsePropLine (line , "model name :" , & cpu -> name ) ||
164- ffParsePropLine (line , "vendor_id :" , & cpu -> vendor ) ||
165- ffParsePropLine (line , "cpu cores :" , physicalCoresBuffer ) ||
166- ffParsePropLine (line , "cpu MHz :" , cpuMHz ) ||
163+ // arm64 doesn't have "model name"; arm32 does have "model name" but its value is not useful.
164+ // "Hardware" should always be used in this case
165+ #if !(__arm__ || __aarch64__ )
166+ (cpu -> name .length == 0 && ffParsePropLine (line , "model name :" , & cpu -> name )) ||
167+ (cpu -> vendor .length == 0 && ffParsePropLine (line , "vendor_id :" , & cpu -> vendor )) ||
168+ (physicalCoresBuffer -> length == 0 && ffParsePropLine (line , "cpu cores :" , physicalCoresBuffer )) ||
169+ (cpuMHz -> length == 0 && ffParsePropLine (line , "cpu MHz :" , cpuMHz )) ||
170+ #endif
167171
168172 #if !(__x86_64__ || __i386__ || __arm__ || __aarch64__ )
169- ffParsePropLine (line , "isa :" , cpuIsa ) ||
170- ffParsePropLine (line , "uarch :" , cpuUarch ) ||
173+ ( cpuIsa -> length == 0 && ffParsePropLine (line , "isa :" , cpuIsa ) ) ||
174+ ( cpuUarch -> length == 0 && ffParsePropLine (line , "uarch :" , cpuUarch ) ) ||
171175 #endif
172176
173177 #if __arm__ || __aarch64__
@@ -177,10 +181,10 @@ static const char* parseCpuInfo(
177181 (cpu -> name .length == 0 && ffParsePropLine (line , "Hardware :" , & cpu -> name )) || //For Android devices
178182 #endif
179183 #if __powerpc__ || __powerpc
180- (cpu -> name .length == 0 && ffParsePropLine (line , "cpu :" , & cpu -> name )) || //For POWER
184+ (cpu -> name .length == 0 && ffParsePropLine (line , "cpu :" , & cpu -> name )) || //For POWER
181185 #endif
182186 #if __mips__
183- (cpu -> name .length == 0 && ffParsePropLine (line , "cpu model :" , & cpu -> name )) || //For MIPS
187+ (cpu -> name .length == 0 && ffParsePropLine (line , "cpu model :" , & cpu -> name )) || //For MIPS
184188 #endif
185189 false
186190 );
@@ -289,6 +293,9 @@ static double detectCPUTemp(void)
289293
290294FF_MAYBE_UNUSED static void parseIsa (FFstrbuf * cpuIsa )
291295{
296+ // Always use the last part of the ISA string. Ref: #590 #1204
297+ ffStrbufSubstrAfterLastC (cpuIsa , ' ' );
298+
292299 if (ffStrbufStartsWithS (cpuIsa , "rv" ))
293300 {
294301 // RISC-V ISA string example: "rv64imafdch_zicsr_zifencei".
@@ -304,10 +311,6 @@ FF_MAYBE_UNUSED static void parseIsa(FFstrbuf* cpuIsa)
304311 }
305312 // The final ISA output of the above example is "rv64gch".
306313 }
307- if (ffStrbufStartsWithS (cpuIsa , "mips" ))
308- {
309- ffStrbufSubstrAfterLastC (cpuIsa , ' ' );
310- }
311314}
312315
313316FF_MAYBE_UNUSED static void detectAsahi (FFCPUResult * cpu )
0 commit comments