X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=include%2Fbabeltrace%2Fclock-internal.h;fp=include%2Fbabeltrace%2Fclock-internal.h;h=cd6bdbae03b9d2ecc8ad7f04142378cf280b0a95;hb=c64b79435d932e3a7e96fd3831d16b58a1278361;hp=002cc7fd848bd26c291c298ac22ce7ff33ee7b56;hpb=d521c3185c6e7849454cf055fc913f8848e59e83;p=babeltrace.git diff --git a/include/babeltrace/clock-internal.h b/include/babeltrace/clock-internal.h index 002cc7fd..cd6bdbae 100644 --- a/include/babeltrace/clock-internal.h +++ b/include/babeltrace/clock-internal.h @@ -42,4 +42,17 @@ uint64_t clock_cycles_to_ns(struct ctf_clock *clock, uint64_t cycles) } } +/* + * Note: if using a frequency different from 1GHz for clock->offset, it + * is recommended to express the seconds in offset_s, otherwise there + * will be a loss of precision caused by the limited size of the double + * mantissa. + */ +static inline +uint64_t clock_offset_ns(struct ctf_clock *clock) +{ + return clock->offset_s * 1000000000ULL + + clock_cycles_to_ns(clock, clock->offset); +} + #endif /* _BABELTRACE_CLOCK_INTERNAL_H */