diff options
author | Lennart Poettering <lennart@poettering.net> | 2016-02-09 00:23:47 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2016-02-09 00:23:47 +0100 |
commit | 70b65964d7ef03621f5d4abd23150c1b121989b4 (patch) | |
tree | 023e8a63f92c50102469cece69f517f5325324ac /src/basic/time-util.h | |
parent | 41c24512cc399ca01f70ec9de6b17273446b170a (diff) | |
parent | 5d634ca8cefb3d738d9efa70dfcc2f67d85d99e9 (diff) |
Merge pull request #2542 from 0xAX/get_ts_delta
time-util: cleanups
Diffstat (limited to 'src/basic/time-util.h')
-rw-r--r-- | src/basic/time-util.h | 11 |
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; +} |