From 2f5b3ef7337857e04cbb4287517fd51e58ee5beb Mon Sep 17 00:00:00 2001 From: fraggerfox Date: Sun, 25 Apr 2021 21:44:32 +0530 Subject: Refactor saturatingSub() to be part of Macros.h --- Macros.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'Macros.h') 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 -- cgit v1.2.3