mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-06 13:17:44 +03:00
time: minor simplification
This commit is contained in:
parent
65de0395ff
commit
75a5f1d837
@ -49,25 +49,20 @@ dual_timestamp* dual_timestamp_from_realtime(dual_timestamp *ts, usec_t u) {
|
||||
int64_t delta;
|
||||
assert(ts);
|
||||
|
||||
if (u == USEC_INFINITY) {
|
||||
ts->realtime = ts->monotonic = USEC_INFINITY;
|
||||
if (u == USEC_INFINITY || u <= 0) {
|
||||
ts->realtime = ts->monotonic = u;
|
||||
return ts;
|
||||
}
|
||||
|
||||
ts->realtime = u;
|
||||
|
||||
if (u == 0)
|
||||
delta = (int64_t) now(CLOCK_REALTIME) - (int64_t) u;
|
||||
ts->monotonic = now(CLOCK_MONOTONIC);
|
||||
|
||||
if ((int64_t) ts->monotonic > delta)
|
||||
ts->monotonic -= delta;
|
||||
else
|
||||
ts->monotonic = 0;
|
||||
else {
|
||||
delta = (int64_t) now(CLOCK_REALTIME) - (int64_t) u;
|
||||
|
||||
ts->monotonic = now(CLOCK_MONOTONIC);
|
||||
|
||||
if ((int64_t) ts->monotonic > delta)
|
||||
ts->monotonic -= delta;
|
||||
else
|
||||
ts->monotonic = 0;
|
||||
}
|
||||
|
||||
return ts;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user