Skip to content

Commit

Permalink
Refactor saturatingSub() to be part of Macros.h
Browse files Browse the repository at this point in the history
  • Loading branch information
fraggerfox authored and BenBE committed Jun 26, 2021
1 parent e42ae55 commit 2f5b3ef
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
5 changes: 5 additions & 0 deletions Macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 0 additions & 4 deletions netbsd/NetBSDProcessList.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 0 additions & 4 deletions openbsd/OpenBSDProcessList.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 2f5b3ef

Please sign in to comment.