diff options
author | Lennart Poettering <lennart@poettering.net> | 2017-06-22 20:49:12 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2017-06-22 20:51:06 +0200 |
commit | 54d8ef14d8ca92caa80c01bb6ebf09b5edb3df9d (patch) | |
tree | c24b1fb802109307125965260687a37448d2d4e9 /src/basic/time-util.c | |
parent | 8825742c445222d61e27942ed963343876373a6d (diff) | |
download | systemd-54d8ef14d8ca92caa80c01bb6ebf09b5edb3df9d.tar.gz |
time-util: rename usec_sub() to usec_sub_signed() and add usec_sub_unsigned()
Quite often we just want to subtract two normal usec_t values, hence
provide an implementation for that.
Diffstat (limited to 'src/basic/time-util.c')
-rw-r--r-- | src/basic/time-util.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/basic/time-util.c b/src/basic/time-util.c index 8d55af8492..51b06698ad 100644 --- a/src/basic/time-util.c +++ b/src/basic/time-util.c @@ -107,7 +107,7 @@ dual_timestamp* dual_timestamp_from_realtime(dual_timestamp *ts, usec_t u) { ts->realtime = u; delta = (int64_t) now(CLOCK_REALTIME) - (int64_t) u; - ts->monotonic = usec_sub(now(CLOCK_MONOTONIC), delta); + ts->monotonic = usec_sub_signed(now(CLOCK_MONOTONIC), delta); return ts; } @@ -124,8 +124,8 @@ triple_timestamp* triple_timestamp_from_realtime(triple_timestamp *ts, usec_t u) ts->realtime = u; delta = (int64_t) now(CLOCK_REALTIME) - (int64_t) u; - ts->monotonic = usec_sub(now(CLOCK_MONOTONIC), delta); - ts->boottime = clock_boottime_supported() ? usec_sub(now(CLOCK_BOOTTIME), delta) : USEC_INFINITY; + ts->monotonic = usec_sub_signed(now(CLOCK_MONOTONIC), delta); + ts->boottime = clock_boottime_supported() ? usec_sub_signed(now(CLOCK_BOOTTIME), delta) : USEC_INFINITY; return ts; } @@ -141,7 +141,7 @@ dual_timestamp* dual_timestamp_from_monotonic(dual_timestamp *ts, usec_t u) { ts->monotonic = u; delta = (int64_t) now(CLOCK_MONOTONIC) - (int64_t) u; - ts->realtime = usec_sub(now(CLOCK_REALTIME), delta); + ts->realtime = usec_sub_signed(now(CLOCK_REALTIME), delta); return ts; } @@ -156,8 +156,8 @@ dual_timestamp* dual_timestamp_from_boottime_or_monotonic(dual_timestamp *ts, us dual_timestamp_get(ts); delta = (int64_t) now(clock_boottime_or_monotonic()) - (int64_t) u; - ts->realtime = usec_sub(ts->realtime, delta); - ts->monotonic = usec_sub(ts->monotonic, delta); + ts->realtime = usec_sub_signed(ts->realtime, delta); + ts->monotonic = usec_sub_signed(ts->monotonic, delta); return ts; } |