summaryrefslogtreecommitdiffstats
path: root/src/basic/time-util.h
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2016-02-09 00:23:47 +0100
committerLennart Poettering <lennart@poettering.net>2016-02-09 00:23:47 +0100
commit70b65964d7ef03621f5d4abd23150c1b121989b4 (patch)
tree023e8a63f92c50102469cece69f517f5325324ac /src/basic/time-util.h
parentMerge pull request #2547 from 0xAX/generalize-format-timestamp-internal (diff)
parenttime-util: introduce usec_sub() (diff)
downloadsystemd-70b65964d7ef03621f5d4abd23150c1b121989b4.tar.xz
systemd-70b65964d7ef03621f5d4abd23150c1b121989b4.zip
Merge pull request #2542 from 0xAX/get_ts_delta
time-util: cleanups
Diffstat (limited to '')
-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;
+}