diff options
Diffstat (limited to 'src/detection/cpuusage/cpuusage_haiku.c')
| -rw-r--r-- | src/detection/cpuusage/cpuusage_haiku.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/detection/cpuusage/cpuusage_haiku.c b/src/detection/cpuusage/cpuusage_haiku.c new file mode 100644 index 0000000..f4d3c63 --- /dev/null +++ b/src/detection/cpuusage/cpuusage_haiku.c @@ -0,0 +1,27 @@ +#include "fastfetch.h" +#include "detection/cpuusage/cpuusage.h" +#include "common/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 = FF_LIST_ADD(FFCpuUsageInfo, *cpuTimes); + info->inUseAll = (uint64_t) cpuInfo[i].active_time; + info->totalAll = uptime; + } + + return NULL; +} |