CPUUsage (Haiku): add support

This commit is contained in:
李通洲 2025-02-16 19:13:47 +08:00
parent 8e5c2adda3
commit 9ff3142b61
No known key found for this signature in database
GPG Key ID: 79D0E1C4B64C86A0
2 changed files with 28 additions and 1 deletions

View File

@ -1132,7 +1132,7 @@ elseif(Haiku)
src/detection/chassis/chassis_windows.c
src/detection/cpu/cpu_haiku.c
src/detection/cpucache/cpucache_shared.c
src/detection/cpuusage/cpuusage_nosupport.c
src/detection/cpuusage/cpuusage_haiku.c
src/detection/cursor/cursor_nosupport.c
src/detection/bluetooth/bluetooth_nosupport.c
src/detection/bluetoothradio/bluetoothradio_nosupport.c

View File

@ -0,0 +1,27 @@
#include "fastfetch.h"
#include "detection/cpuusage/cpuusage.h"
#include "util/mallocHelper.h"
#include <OS.h>
const char* ffGetCpuUsageInfo(FFlist* cpuTimes)
{
system_info sysInfo;
if (get_system_info(&sysInfo) != B_OK)
return "get_system_info() failed";
FF_AUTO_FREE cpu_info* cpuInfo = malloc(sizeof(*cpuInfo) * sysInfo.cpu_count);
if (get_cpu_info(0, sysInfo.cpu_count, cpuInfo) != B_OK)
return "get_cpu_info() failed";
uint64_t uptime = (uint64_t) system_time();
for (uint32_t i = 0; i < sysInfo.cpu_count; ++i)
{
FFCpuUsageInfo* info = (FFCpuUsageInfo*) ffListAdd(cpuTimes);
info->inUseAll = (uint64_t) cpuInfo[i].active_time;
info->totalAll = uptime;
}
return NULL;
}