Refactor saturatingSub() to be part of Macros.h

This commit is contained in:
fraggerfox 2021-04-25 21:44:32 +05:30 committed by BenBE
parent e42ae55d69
commit 2f5b3ef733
3 changed files with 5 additions and 8 deletions

View File

@ -69,4 +69,9 @@
#define IGNORE_WCASTQUAL_END #define IGNORE_WCASTQUAL_END
#endif #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 #endif

View File

@ -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) { static void getKernelCPUTimes(int cpuId, u_int64_t* times) {
const int mib[] = { CTL_KERN, KERN_CP_TIME, cpuId }; const int mib[] = { CTL_KERN, KERN_CP_TIME, cpuId };
size_t length = sizeof(*times) * CPUSTATES; size_t length = sizeof(*times) * CPUSTATES;

View File

@ -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) { static void getKernelCPUTimes(int cpuId, u_int64_t* times) {
const int mib[] = { CTL_KERN, KERN_CPTIME2, cpuId }; const int mib[] = { CTL_KERN, KERN_CPTIME2, cpuId };
size_t length = sizeof(*times) * CPUSTATES; size_t length = sizeof(*times) * CPUSTATES;