@@ -222,6 +222,7 @@ static void detectArmName(FILE* cpuinfo, FFCPUResult* cpu, uint32_t implId)
222222static  const  char *  parseCpuInfo (
223223    FF_MAYBE_UNUSED  FILE *  cpuinfo ,
224224    FF_MAYBE_UNUSED  FFCPUResult *  cpu ,
225+     FF_MAYBE_UNUSED  FFstrbuf *  cpuPhysicalId ,
225226    FF_MAYBE_UNUSED  FFstrbuf *  physicalCoresBuffer ,
226227    FF_MAYBE_UNUSED  FFstrbuf *  cpuMHz ,
227228    FF_MAYBE_UNUSED  FFstrbuf *  cpuIsa ,
@@ -247,6 +248,9 @@ static const char* parseCpuInfo(
247248            #if  !(__arm__  ||  __aarch64__ )
248249            (cpu -> name .length  ==  0  &&  ffParsePropLine (line , "model name :" , & cpu -> name )) || 
249250            (cpu -> vendor .length  ==  0  &&  ffParsePropLine (line , "vendor_id :" , & cpu -> vendor )) || 
251+             //Is it cheaper to just parse every physical id or to check if it's already set to the parsed value? 
252+             (cpuPhysicalId -> length  ==  0  &&  ffParsePropLine (line , "physical id:" , cpuPhysicalId )) || 
253+             (cpuPhysicalId -> length  >  0  &&  ffParsePropLine (line , "physical id:" , cpuPhysicalId )) || 
250254            (physicalCoresBuffer -> length  ==  0  &&  ffParsePropLine (line , "cpu cores :" , physicalCoresBuffer )) || 
251255            (cpuMHz -> length  ==  0  &&  ffParsePropLine (line , "cpu MHz :" , cpuMHz )) || 
252256            #endif 
@@ -473,18 +477,20 @@ const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu)
473477
474478    cpu -> temperature  =  options -> temp  ? detectCPUTemp () : FF_CPU_TEMP_UNSET ;
475479
480+     FF_STRBUF_AUTO_DESTROY  cpuPhysicalId =  ffStrbufCreate ();
476481    FF_STRBUF_AUTO_DESTROY  physicalCoresBuffer  =  ffStrbufCreate ();
477482    FF_STRBUF_AUTO_DESTROY  cpuMHz  =  ffStrbufCreate ();
478483    FF_STRBUF_AUTO_DESTROY  cpuIsa  =  ffStrbufCreate ();
479484    FF_STRBUF_AUTO_DESTROY  cpuUarch  =  ffStrbufCreate ();
480485    FF_STRBUF_AUTO_DESTROY  cpuImplementerStr  =  ffStrbufCreate ();
481486
482-     const  char *  error  =  parseCpuInfo (cpuinfo , cpu , & physicalCoresBuffer , & cpuMHz , & cpuIsa , & cpuUarch , & cpuImplementerStr );
487+     const  char *  error  =  parseCpuInfo (cpuinfo , cpu , & cpuPhysicalId ,  & physicalCoresBuffer , & cpuMHz , & cpuIsa , & cpuUarch , & cpuImplementerStr );
483488    if  (error ) return  error ;
484489
485490    cpu -> coresLogical  =  (uint16_t ) get_nprocs_conf ();
486491    cpu -> coresOnline  =  (uint16_t ) get_nprocs ();
487492    cpu -> coresPhysical  =  (uint16_t ) ffStrbufToUInt (& physicalCoresBuffer , cpu -> coresLogical );
493+     cpu -> cpuCount  =  (uint16_t ) ffStrbufToUInt (& cpuPhysicalId , 1 ) + 1 ; //Assuming at least 1 CPU is present otherwise we wouldn't get this far 
488494
489495    // Ref https://github.com/fastfetch-cli/fastfetch/issues/1194#issuecomment-2295058252 
490496    ffCPUDetectSpeedByCpuid (cpu );
0 commit comments