summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfraggerfox <santhosh.raju@gmail.com>2021-04-25 21:44:32 +0530
committerBenBE <BenBE@geshi.org>2021-06-26 12:18:37 +0200
commit2f5b3ef7337857e04cbb4287517fd51e58ee5beb (patch)
treea2efa0b4c6602d7a32102766570d8e0a27b66b69
parente42ae55d691b0e2018d3569ae687cf0cda98c0f8 (diff)
Refactor saturatingSub() to be part of Macros.h
-rw-r--r--Macros.h5
-rw-r--r--netbsd/NetBSDProcessList.c4
-rw-r--r--openbsd/OpenBSDProcessList.c4
3 files changed, 5 insertions, 8 deletions
diff --git a/Macros.h b/Macros.h
index 789b09b6..1fdfb1ed 100644
--- a/Macros.h
+++ b/Macros.h
@@ -69,4 +69,9 @@
#define IGNORE_WCASTQUAL_END
#endif
+/* This subtraction is used by NetBSD / OpenBSD for calculation of CPU usage items. */
+static inline unsigned long long saturatingSub(unsigned long long a, unsigned long long b) {
+ return a > b ? a - b : 0;
+}
+
#endif
diff --git a/netbsd/NetBSDProcessList.c b/netbsd/NetBSDProcessList.c
index 54588b7b..cfc00d53 100644
--- a/netbsd/NetBSDProcessList.c
+++ b/netbsd/NetBSDProcessList.c
@@ -242,10 +242,6 @@ static void NetBSDProcessList_scanProcs(NetBSDProcessList* this) {
}
}
-static unsigned long long saturatingSub(unsigned long long a, unsigned long long b) {
- return a > b ? a - b : 0;
-}
-
static void getKernelCPUTimes(int cpuId, u_int64_t* times) {
const int mib[] = { CTL_KERN, KERN_CP_TIME, cpuId };
size_t length = sizeof(*times) * CPUSTATES;
diff --git a/openbsd/OpenBSDProcessList.c b/openbsd/OpenBSDProcessList.c
index a02b4901..c9b1db7a 100644
--- a/openbsd/OpenBSDProcessList.c
+++ b/openbsd/OpenBSDProcessList.c
@@ -351,10 +351,6 @@ static void OpenBSDProcessList_scanProcs(OpenBSDProcessList* this) {
}
}
-static unsigned long long saturatingSub(unsigned long long a, unsigned long long b) {
- return a > b ? a - b : 0;
-}
-
static void getKernelCPUTimes(int cpuId, u_int64_t* times) {
const int mib[] = { CTL_KERN, KERN_CPTIME2, cpuId };
size_t length = sizeof(*times) * CPUSTATES;

© 2014-2024 Faster IT GmbH | imprint | privacy policy