mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-30 00:37:23 +01:00
CpuUsage: support freebsd
This commit is contained in:
+2
-1
@@ -310,6 +310,7 @@ endif()
|
||||
if(LINUX OR ANDROID)
|
||||
list(APPEND LIBFASTFETCH_SRC
|
||||
src/detection/cpu/cpu_linux.c
|
||||
src/detection/cpuUsage/cpuUsage_linux.c
|
||||
src/detection/memory/memory_linux.c
|
||||
src/detection/processes/processes_linux.c
|
||||
src/detection/swap/swap_linux.c
|
||||
@@ -319,7 +320,6 @@ endif()
|
||||
|
||||
if(LINUX OR ANDROID OR BSD)
|
||||
list(APPEND LIBFASTFETCH_SRC
|
||||
src/detection/cpuUsage/cpuUsage_linux.c
|
||||
src/detection/disk/disk_linux.c
|
||||
src/detection/temps/temps_linux.c
|
||||
src/detection/opengl/opengl_linux.c
|
||||
@@ -418,6 +418,7 @@ endif()
|
||||
if(BSD)
|
||||
list(APPEND LIBFASTFETCH_SRC
|
||||
src/detection/cpu/cpu_bsd.c
|
||||
src/detection/cpuUsage/cpuUsage_bsd.c
|
||||
src/detection/memory/memory_bsd.c
|
||||
src/detection/swap/swap_bsd.c
|
||||
)
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
#include "cpuUsage.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/user.h>
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
const char* ffGetCpuUsageInfo(uint64_t* inUseAll, uint64_t* totalAll)
|
||||
{
|
||||
// interrupt processing, user processes, system processing, lock spinning, and idling
|
||||
uint64_t cpTime[5];
|
||||
size_t neededLength = sizeof(cpTime);
|
||||
if(sysctlbyname("kern.cp_time", cpTime, &neededLength, NULL, 0) != 0)
|
||||
return "sysctlbyname(kern.cp_time) failed";
|
||||
|
||||
*inUseAll = cpTime[0] + cpTime[1] + cpTime[2] + cpTime[3];
|
||||
*totalAll = *inUseAll + cpTime[4];
|
||||
|
||||
return NULL;
|
||||
}
|
||||
Reference in New Issue
Block a user