summaryrefslogtreecommitdiff
path: root/src/basic/time-util.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/basic/time-util.h')
-rw-r--r--src/basic/time-util.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/basic/time-util.h b/src/basic/time-util.h
index 9c7758a959..87440faeee 100644
--- a/src/basic/time-util.h
+++ b/src/basic/time-util.h
@@ -140,3 +140,14 @@ static inline usec_t usec_add(usec_t a, usec_t b) {
return c;
}
+
+static inline usec_t usec_sub(usec_t timestamp, int64_t delta) {
+ if (delta < 0)
+ timestamp = usec_add(timestamp, (usec_t) (-delta));
+ else if (timestamp > (usec_t) delta)
+ timestamp -= delta;
+ else
+ timestamp = 0;
+
+ return timestamp;
+}