aboutsummaryrefslogtreecommitdiff
path: root/src/porting.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/porting.h')
-rw-r--r--src/porting.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/porting.h b/src/porting.h
index 937ca9464..383d4377a 100644
--- a/src/porting.h
+++ b/src/porting.h
@@ -275,6 +275,21 @@ inline u32 getTime(TimePrecision prec)
return 0;
}
+/**
+ * Delta calculation function taking two 32bit arguments.
+ * @param old_time_ms old time for delta calculation (order is relevant!)
+ * @param new_time_ms new time for delta calculation (order is relevant!)
+ * @return positive 32bit delta value
+ */
+inline u32 getDeltaMs(u32 old_time_ms, u32 new_time_ms)
+{
+ if (new_time_ms >= old_time_ms) {
+ return (new_time_ms - old_time_ms);
+ } else {
+ return (old_time_ms - new_time_ms);
+ }
+}
+
#if defined(linux) || defined(__linux)
#include <sys/prctl.h>