Skip to content

Commit e7630ae

Browse files
committed
NetBSD: support CPUUsage / Memory / Swap
1 parent e19ed4c commit e7630ae

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ elseif(NetBSD)
685685
src/detection/chassis/chassis_nbsd.c
686686
src/detection/cpu/cpu_bsd.c
687687
src/detection/cpucache/cpucache_nosupport.c
688-
src/detection/cpuusage/cpuusage_nosupport.c
688+
src/detection/cpuusage/cpuusage_bsd.c
689689
src/detection/cursor/cursor_linux.c
690690
src/detection/disk/disk_nosupport.c
691691
src/detection/dns/dns_linux.c
@@ -720,7 +720,7 @@ elseif(NetBSD)
720720
src/detection/localip/localip_linux.c
721721
src/detection/gamepad/gamepad_nosupport.c
722722
src/detection/media/media_linux.c
723-
src/detection/memory/memory_bsd.c
723+
src/detection/memory/memory_obsd.c
724724
src/detection/mouse/mouse_nosupport.c
725725
src/detection/netio/netio_nosupport.c
726726
src/detection/opengl/opengl_linux.c
@@ -730,7 +730,7 @@ elseif(NetBSD)
730730
src/detection/processes/processes_nosupport.c
731731
src/detection/gtk_qt/qt.c
732732
src/detection/sound/sound_nosupport.c
733-
src/detection/swap/swap_nosupport.c
733+
src/detection/swap/swap_obsd.c
734734
src/detection/terminalfont/terminalfont_linux.c
735735
src/detection/terminalshell/terminalshell_linux.c
736736
src/detection/terminalsize/terminalsize_linux.c

src/detection/cpuusage/cpuusage_bsd.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,19 @@
66
#include <sys/resource.h>
77
#include <stdlib.h>
88

9-
#ifdef __OpenBSD__
9+
#if __OpenBSD__ || __NetBSD__
1010
#include <sys/sched.h>
1111
#endif
1212

1313
const char* ffGetCpuUsageInfo(FFlist* cpuTimes)
1414
{
1515
size_t neededLength = 0;
16-
#ifdef __OpenBSD__
17-
int ctls[] = {CTL_KERN, KERN_CPTIME};
16+
#if __OpenBSD__|| __NetBSD__
17+
#ifdef KERN_CPTIME
18+
int ctls[] = {CTL_KERN, KERN_CPTIME};
19+
#else
20+
int ctls[] = {CTL_KERN, KERN_CP_TIME};
21+
#endif
1822
if (sysctl(ctls, 2, NULL, &neededLength, NULL, 0) != 0)
1923
return "sysctl({CTL_KERN, KERN_CPTIME}, 2, NULL) failed";
2024
#else
@@ -27,7 +31,7 @@ const char* ffGetCpuUsageInfo(FFlist* cpuTimes)
2731

2832
FF_AUTO_FREE uint64_t (*cpTimes)[CPUSTATES] = malloc(neededLength);
2933

30-
#ifdef __OpenBSD__
34+
#if __OpenBSD__ || __NetBSD__
3135
if (sysctl(ctls, 2, cpTimes, &neededLength, NULL, 0) != 0)
3236
return "sysctl({CTL_KERN, KERN_CPTIME}, 2, NULL) failed";
3337
#else

src/detection/memory/memory_obsd.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33

44
#include <sys/param.h>
55

6+
#if __NetBSD__
7+
#include <uvm/uvm_extern.h>
8+
#endif
9+
610
const char* ffDetectMemory(FFMemoryResult* ram)
711
{
812
struct uvmexp buf;

0 commit comments

Comments
 (0)