time-util: expose map_clock_usec_internal() as map_clock_usec_raw()

This will be used later.
This commit is contained in:
Yu Watanabe 2024-03-06 09:57:06 +09:00
parent b923ada838
commit 3ecd6fa98b
2 changed files with 9 additions and 8 deletions

View file

@ -83,7 +83,7 @@ triple_timestamp* triple_timestamp_now(triple_timestamp *ts) {
return ts;
}
static usec_t map_clock_usec_internal(usec_t from, usec_t from_base, usec_t to_base) {
usec_t map_clock_usec_raw(usec_t from, usec_t from_base, usec_t to_base) {
/* Maps the time 'from' between two clocks, based on a common reference point where the first clock
* is at 'from_base' and the second clock at 'to_base'. Basically calculates:
@ -121,7 +121,7 @@ usec_t map_clock_usec(usec_t from, clockid_t from_clock, clockid_t to_clock) {
if (from == USEC_INFINITY)
return from;
return map_clock_usec_internal(from, now(from_clock), now(to_clock));
return map_clock_usec_raw(from, now(from_clock), now(to_clock));
}
dual_timestamp* dual_timestamp_from_realtime(dual_timestamp *ts, usec_t u) {
@ -150,8 +150,8 @@ triple_timestamp* triple_timestamp_from_realtime(triple_timestamp *ts, usec_t u)
nowr = now(CLOCK_REALTIME);
ts->realtime = u;
ts->monotonic = map_clock_usec_internal(u, nowr, now(CLOCK_MONOTONIC));
ts->boottime = map_clock_usec_internal(u, nowr, now(CLOCK_BOOTTIME));
ts->monotonic = map_clock_usec_raw(u, nowr, now(CLOCK_MONOTONIC));
ts->boottime = map_clock_usec_raw(u, nowr, now(CLOCK_BOOTTIME));
return ts;
}
@ -169,8 +169,8 @@ triple_timestamp* triple_timestamp_from_boottime(triple_timestamp *ts, usec_t u)
nowb = now(CLOCK_BOOTTIME);
ts->boottime = u;
ts->monotonic = map_clock_usec_internal(u, nowb, now(CLOCK_MONOTONIC));
ts->realtime = map_clock_usec_internal(u, nowb, now(CLOCK_REALTIME));
ts->monotonic = map_clock_usec_raw(u, nowb, now(CLOCK_MONOTONIC));
ts->realtime = map_clock_usec_raw(u, nowb, now(CLOCK_REALTIME));
return ts;
}
@ -199,8 +199,8 @@ dual_timestamp* dual_timestamp_from_boottime(dual_timestamp *ts, usec_t u) {
}
nowm = now(CLOCK_BOOTTIME);
ts->monotonic = map_clock_usec_internal(u, nowm, now(CLOCK_MONOTONIC));
ts->realtime = map_clock_usec_internal(u, nowm, now(CLOCK_REALTIME));
ts->monotonic = map_clock_usec_raw(u, nowm, now(CLOCK_MONOTONIC));
ts->realtime = map_clock_usec_raw(u, nowm, now(CLOCK_REALTIME));
return ts;
}

View file

@ -77,6 +77,7 @@ typedef enum TimestampStyle {
usec_t now(clockid_t clock);
nsec_t now_nsec(clockid_t clock);
usec_t map_clock_usec_raw(usec_t from, usec_t from_base, usec_t to_base);
usec_t map_clock_usec(usec_t from, clockid_t from_clock, clockid_t to_clock);
dual_timestamp* dual_timestamp_now(dual_timestamp *ts);