Skip to content

Commit 36cf585

Browse files
authored
Merge pull request #952 from fastfetch-cli/dev
Release: v2.13.1
2 parents 43bdb68 + 01d1336 commit 36cf585

File tree

10 files changed

+90
-37
lines changed

10 files changed

+90
-37
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
# 2.13.1
2+
3+
Fix a regression introduced in v2.13.0
4+
5+
Bugfixes:
6+
* Fix CPU frequency not displayed if `bios_limit` is not available (CPU, Linux)
7+
8+
Features:
9+
* Add `--cpu-show-pe-core-count` to detect and display core count for performance / efficiency cores (CPU, FreeBSD)
10+
111
# 2.13.0
212

313
Changes:

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cmake_minimum_required(VERSION 3.12.0) # target_link_libraries with OBJECT libs & project homepage url
22

33
project(fastfetch
4-
VERSION 2.13.0
4+
VERSION 2.13.1
55
LANGUAGES C
66
DESCRIPTION "Fast neofetch-like system information tool"
77
HOMEPAGE_URL "https://github.com/fastfetch-cli/fastfetch"

doc/json_schema.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,6 +1074,11 @@
10741074
"maximum": 9,
10751075
"default": 2
10761076
},
1077+
"showPeCoreCount": {
1078+
"description": "Detect and display CPU frequency of different core types (eg. Pcore and Ecore) if supported",
1079+
"type": "boolean",
1080+
"default": false
1081+
},
10771082
"key": {
10781083
"$ref": "#/$defs/key"
10791084
},

src/data/help.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,6 +1152,15 @@
11521152
"default": 2
11531153
}
11541154
},
1155+
{
1156+
"long": "cpu-show-pe-core-count",
1157+
"desc": "Detect and display CPU frequency of different core types (eg. Pcore and Ecore) if supported",
1158+
"arg": {
1159+
"type": "bool",
1160+
"optional": true,
1161+
"default": false
1162+
}
1163+
},
11551164
{
11561165
"long": "cpuusage-separate",
11571166
"desc": "Display CPU usage per CPU logical core, instead of an average result",

src/detection/cpu/cpu_apple.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu)
121121
cpu->coresOnline = (uint16_t) ffSysctlGetInt("hw.activecpu", 1);
122122

123123
detectFrequency(cpu);
124-
detectCoreCount(cpu);
124+
if (options->showPeCoreCount) detectCoreCount(cpu);
125125

126126
cpu->temperature = options->temp ? detectCpuTemp(&cpu->name) : FF_CPU_TEMP_UNSET;
127127

src/detection/cpu/cpu_bsd.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu)
3939
}
4040
}
4141

42-
uint32_t ifreq = (uint32_t) -1;
4342
for (uint16_t i = 0; i < cpu->coresLogical; ++i)
4443
{
4544
ffStrbufClear(&buffer);
@@ -56,12 +55,15 @@ const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu)
5655
if (!(cpu->frequencyMin <= fmin)) cpu->frequencyMin = fmin; // Counting for NaN
5756
if (!(cpu->frequencyMax >= fmax)) cpu->frequencyMax = fmax;
5857

59-
uint32_t ifreq = 0;
60-
while (cpu->coreTypes[ifreq].freq != fmax && cpu->coreTypes[ifreq].freq > 0)
61-
++ifreq;
62-
if (cpu->coreTypes[ifreq].freq == 0)
63-
cpu->coreTypes[ifreq].freq = fmax;
64-
cpu->coreTypes[ifreq].count++;
58+
if (options->showPeCoreCount)
59+
{
60+
uint32_t ifreq = 0;
61+
while (cpu->coreTypes[ifreq].freq != fmax && cpu->coreTypes[ifreq].freq > 0)
62+
++ifreq;
63+
if (cpu->coreTypes[ifreq].freq == 0)
64+
cpu->coreTypes[ifreq].freq = fmax;
65+
cpu->coreTypes[ifreq].count++;
66+
}
6567
}
6668
}
6769
cpu->frequencyMin /= 1000;

src/detection/cpu/cpu_linux.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ static uint8_t getNumCores(FFstrbuf* basePath, FFstrbuf* buffer)
127127
return 0;
128128
}
129129

130-
static bool detectFrequency(FFCPUResult* cpu)
130+
static bool detectFrequency(FFCPUResult* cpu, const FFCPUOptions* options)
131131
{
132132
FF_STRBUF_AUTO_DESTROY path = ffStrbufCreateS("/sys/devices/system/cpu/cpufreq/");
133133
FF_AUTO_CLOSE_DIR DIR* dir = opendir(path.chars);
@@ -175,13 +175,16 @@ static bool detectFrequency(FFCPUResult* cpu)
175175
cpu->frequencyMin = fmin;
176176
}
177177

178-
uint32_t freq = fbase == 0 ? fmax : fbase; // seems base frequencies are more stable
179-
uint32_t ifreq = 0;
180-
while (cpu->coreTypes[ifreq].freq != freq && cpu->coreTypes[ifreq].freq > 0)
181-
++ifreq;
182-
if (cpu->coreTypes[ifreq].freq == 0)
183-
cpu->coreTypes[ifreq].freq = freq;
184-
cpu->coreTypes[ifreq].count += getNumCores(&path, &buffer);
178+
if (options->showPeCoreCount)
179+
{
180+
uint32_t freq = fbase == 0 ? fmax : fbase; // seems base frequencies are more stable
181+
uint32_t ifreq = 0;
182+
while (cpu->coreTypes[ifreq].freq != freq && cpu->coreTypes[ifreq].freq > 0)
183+
++ifreq;
184+
if (cpu->coreTypes[ifreq].freq == 0)
185+
cpu->coreTypes[ifreq].freq = freq;
186+
cpu->coreTypes[ifreq].count += getNumCores(&path, &buffer);
187+
}
185188
ffStrbufSubstrBefore(&path, baseLen);
186189
}
187190
}
@@ -270,7 +273,7 @@ const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu)
270273
cpu->coresOnline = (uint16_t) get_nprocs();
271274
cpu->coresPhysical = (uint16_t) ffStrbufToUInt(&physicalCoresBuffer, cpu->coresLogical);
272275

273-
if (!detectFrequency(cpu) || cpu->frequencyBase != cpu->frequencyBase)
276+
if (!detectFrequency(cpu, options) || cpu->frequencyBase != cpu->frequencyBase)
274277
cpu->frequencyBase = ffStrbufToDouble(&cpuMHz) / 1000;
275278

276279
if(cpuUarch.length > 0)

src/detection/cpu/cpu_windows.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,10 @@ static const char* detectByRegistry(FFCPUResult* cpu)
157157
cpu->coresOnline = cpu->coresPhysical = cpu->coresLogical = (uint16_t) cores;
158158
}
159159

160+
uint32_t mhz;
161+
if(ffRegReadUint(hKey, L"~MHz", &mhz, NULL))
162+
cpu->frequencyBase = mhz / 1000.0;
163+
160164
return NULL;
161165
}
162166

@@ -190,7 +194,7 @@ const char* ffDetectCPUImpl(const FFCPUOptions* options, FFCPUResult* cpu)
190194
return error;
191195

192196
detectSpeedByCpuid(cpu);
193-
detectCoreTypes(cpu);
197+
if (options->showPeCoreCount) detectCoreTypes(cpu);
194198

195199
if (cpu->frequencyMax != cpu->frequencyMax)
196200
detectMaxSpeedBySmbios(cpu);

src/modules/cpu/cpu.c

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,20 @@ void ffPrintCPU(FFCPUOptions* options)
3737
}
3838
else
3939
{
40+
FF_STRBUF_AUTO_DESTROY coreTypes = ffStrbufCreate();
41+
if (options->showPeCoreCount)
42+
{
43+
uint32_t typeCount = 0;
44+
while (cpu.coreTypes[typeCount].count != 0 && typeCount < sizeof(cpu.coreTypes) / sizeof(cpu.coreTypes[0])) typeCount++;
45+
if (typeCount > 0)
46+
{
47+
qsort(cpu.coreTypes, typeCount, sizeof(cpu.coreTypes[0]), (void*) sortCores);
48+
49+
for (uint32_t i = 0; i < typeCount; i++)
50+
ffStrbufAppendF(&coreTypes, "%s%u", i == 0 ? "" : "+", cpu.coreTypes[i].count);
51+
}
52+
}
53+
4054
if(options->moduleArgs.outputFormat.length == 0)
4155
{
4256
ffPrintLogoAndKey(FF_CPU_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT);
@@ -53,13 +67,15 @@ void ffPrintCPU(FFCPUOptions* options)
5367
else
5468
ffStrbufAppendS(&str, "Unknown");
5569

56-
if(cpu.coresOnline > 1)
70+
if(coreTypes.length > 0)
71+
ffStrbufAppendF(&str, " (%s)", coreTypes.chars);
72+
else if(cpu.coresOnline > 1)
5773
ffStrbufAppendF(&str, " (%u)", cpu.coresOnline);
5874

5975
double freq = cpu.frequencyBiosLimit;
60-
if(freq <= 0.0000001)
76+
if(!(freq > 0.0000001))
6177
freq = cpu.frequencyMax;
62-
if(freq <= 0.0000001)
78+
if(!(freq > 0.0000001))
6379
freq = cpu.frequencyBase;
6480
if(freq > 0.0000001)
6581
ffStrbufAppendF(&str, " @ %.*f GHz", options->freqNdigits, freq);
@@ -74,19 +90,6 @@ void ffPrintCPU(FFCPUOptions* options)
7490
}
7591
else
7692
{
77-
FF_STRBUF_AUTO_DESTROY coreTypes = ffStrbufCreate();
78-
uint32_t typeCount = 0;
79-
while (cpu.coreTypes[typeCount].count != 0 && typeCount < sizeof(cpu.coreTypes) / sizeof(cpu.coreTypes[0])) typeCount++;
80-
if (typeCount > 0)
81-
{
82-
qsort(cpu.coreTypes, typeCount, sizeof(cpu.coreTypes[0]), (void*) sortCores);
83-
84-
for (uint32_t i = 0; i < typeCount; i++)
85-
ffStrbufAppendF(&coreTypes, "%s%u", i == 0 ? "" : "+", cpu.coreTypes[i].count);
86-
}
87-
else
88-
ffStrbufAppendF(&coreTypes, "%u", cpu.coresOnline);
89-
9093
char freqBase[32], freqMax[32], freqBioslimit[32];
9194
if (cpu.frequencyBase > 0)
9295
snprintf(freqBase, sizeof(freqBase), "%.*f", options->freqNdigits, cpu.frequencyBase);
@@ -122,7 +125,7 @@ void ffPrintCPU(FFCPUOptions* options)
122125
ffStrbufDestroy(&cpu.vendor);
123126
}
124127

125-
bool ffParseCPUCPUOptions(FFCPUOptions* options, const char* key, const char* value)
128+
bool ffParseCPUCommandOptions(FFCPUOptions* options, const char* key, const char* value)
126129
{
127130
const char* subKey = ffOptionTestPrefix(key, FF_CPU_MODULE_NAME);
128131
if (!subKey) return false;
@@ -138,6 +141,12 @@ bool ffParseCPUCPUOptions(FFCPUOptions* options, const char* key, const char* va
138141
return true;
139142
}
140143

144+
if (ffStrEqualsIgnCase(subKey, "show-pe-core-count"))
145+
{
146+
options->showPeCoreCount = ffOptionParseBoolean(value);
147+
return true;
148+
}
149+
141150
return false;
142151
}
143152

@@ -163,6 +172,12 @@ void ffParseCPUJsonObject(FFCPUOptions* options, yyjson_val* module)
163172
continue;
164173
}
165174

175+
if (ffStrEqualsIgnCase(key, "showPeCoreCount"))
176+
{
177+
options->showPeCoreCount = yyjson_get_bool(val);
178+
continue;
179+
}
180+
166181
ffPrintError(FF_CPU_MODULE_NAME, 0, &options->moduleArgs, FF_PRINT_TYPE_DEFAULT, "Unknown JSON key %s", key);
167182
}
168183
}
@@ -178,6 +193,9 @@ void ffGenerateCPUJsonConfig(FFCPUOptions* options, yyjson_mut_doc* doc, yyjson_
178193

179194
if (defaultOptions.freqNdigits != options->freqNdigits)
180195
yyjson_mut_obj_add_uint(doc, module, "freqNdigits", options->freqNdigits);
196+
197+
if (defaultOptions.showPeCoreCount != options->showPeCoreCount)
198+
yyjson_mut_obj_add_bool(doc, module, "showPeCoreCount", options->showPeCoreCount);
181199
}
182200

183201
void ffGenerateCPUJsonResult(FFCPUOptions* options, yyjson_mut_doc* doc, yyjson_mut_val* module)
@@ -256,7 +274,7 @@ void ffInitCPUOptions(FFCPUOptions* options)
256274
&options->moduleInfo,
257275
FF_CPU_MODULE_NAME,
258276
"Print CPU name, frequency, etc",
259-
ffParseCPUCPUOptions,
277+
ffParseCPUCommandOptions,
260278
ffParseCPUJsonObject,
261279
ffPrintCPU,
262280
ffGenerateCPUJsonResult,
@@ -267,6 +285,7 @@ void ffInitCPUOptions(FFCPUOptions* options)
267285
options->temp = false;
268286
options->tempConfig = (FFColorRangeConfig) { 60, 80 };
269287
options->freqNdigits = 2;
288+
options->showPeCoreCount = false;
270289
}
271290

272291
void ffDestroyCPUOptions(FFCPUOptions* options)

src/modules/cpu/option.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ typedef struct FFCPUOptions
1212
bool temp;
1313
FFColorRangeConfig tempConfig;
1414
uint8_t freqNdigits;
15+
bool showPeCoreCount;
1516
} FFCPUOptions;

0 commit comments

Comments
 (0)