- realtime = (uint64_t) rts.tv_sec * 1000000000ULL;
- realtime += rts.tv_nsec;
- if (tcf != 1000000000ULL) {
- realtime /= 1000000000ULL / tcf;
+ realtime = (uint64_t) rts.tv_sec * tcf;
+ if (tcf == NSEC_PER_SEC) {
+ realtime += rts.tv_nsec;
+ } else {
+ realtime += (uint64_t) rts.tv_nsec * tcf / NSEC_PER_SEC;