Files
fastfetch/src/modules/cpu.c
T

55 lines
1.7 KiB
C
Raw Normal View History

2021-02-18 22:25:36 +01:00
#include "fastfetch.h"
#include "common/printing.h"
#include "common/caching.h"
2022-09-04 22:20:12 +02:00
#include "detection/cpu/cpu.h"
2021-04-09 14:07:05 +02:00
2021-04-15 18:59:26 +02:00
#define FF_CPU_MODULE_NAME "CPU"
2022-09-04 22:20:12 +02:00
#define FF_CPU_NUM_FORMAT_ARGS 8
2021-02-27 18:30:05 +01:00
void ffPrintCPU(FFinstance* instance)
2021-02-18 22:25:36 +01:00
{
2022-09-21 17:26:10 +02:00
const FFCPUResult* cpu = ffDetectCPU(instance);
2021-06-16 11:28:33 +02:00
2022-09-19 23:16:43 +02:00
if(cpu->vendor.length == 0 && cpu->name.length == 0 && cpu->coresOnline <= 1)
2021-02-19 16:23:41 +01:00
{
2022-09-04 22:20:12 +02:00
ffPrintError(instance, FF_CPU_MODULE_NAME, 0, &instance->config.cpu, "No CPU detected");
2021-04-03 21:51:50 +02:00
return;
}
2022-09-21 17:26:10 +02:00
if(instance->config.cpu.outputFormat.length == 0)
2021-03-19 20:57:07 +01:00
{
2022-09-21 17:26:10 +02:00
ffPrintLogoAndKey(instance, FF_CPU_MODULE_NAME, 0, &instance->config.cpu.key);
if(cpu->name.length > 0)
ffStrbufWriteTo(&cpu->name, stdout);
else if(cpu->vendor.length > 0)
{
ffStrbufWriteTo(&cpu->vendor, stdout);
fputs(" CPU", stdout);
}
else
fputs("CPU", stdout);
if(cpu->coresOnline > 1)
printf(" (%u)", cpu->coresOnline);
if(cpu->frequencyMax > 0.0)
printf(" @ %.9g GHz", cpu->frequencyMax);
putchar('\n');
2021-03-19 20:57:07 +01:00
}
else
2022-09-21 17:26:10 +02:00
{
ffPrintFormat(instance, FF_CPU_MODULE_NAME, 0, &instance->config.cpu, FF_CPU_NUM_FORMAT_ARGS, (FFformatarg[]){
{FF_FORMAT_ARG_TYPE_STRBUF, &cpu->name},
{FF_FORMAT_ARG_TYPE_STRBUF, &cpu->vendor},
{FF_FORMAT_ARG_TYPE_UINT16, &cpu->coresPhysical},
{FF_FORMAT_ARG_TYPE_UINT16, &cpu->coresLogical},
{FF_FORMAT_ARG_TYPE_UINT16, &cpu->coresOnline},
{FF_FORMAT_ARG_TYPE_DOUBLE, &cpu->frequencyMin},
{FF_FORMAT_ARG_TYPE_DOUBLE, &cpu->frequencyMax},
{FF_FORMAT_ARG_TYPE_DOUBLE, &cpu->temperature}
});
}
2021-03-27 18:14:19 +01:00
}