uint64_t tsc2nsec(uint64_t tsc_time) { if (mult_will_overflow_u64(tsc_time, 1000000000)) return tsc2usec(tsc_time) * 1000; else return (tsc_time * 1000000000) / system_timing.tsc_freq; }
uint64_t nsec2tsc(uint64_t nsec) { if (mult_will_overflow_u64(nsec, system_timing.tsc_freq)) return usec2tsc(nsec / 1000); else return (nsec * system_timing.tsc_freq) / 1000000000; }
uint64_t nsec2tsc(uint64_t nsec) { if (mult_will_overflow_u64(nsec, get_tsc_freq())) return usec2tsc(nsec / 1000); else return (nsec * get_tsc_freq()) / 1000000000; }
uint64_t sec2tsc(uint64_t sec) { if (mult_will_overflow_u64(sec, get_tsc_freq())) return (uint64_t)(-1); else return sec * get_tsc_freq(); }
uint64_t tsc2nsec(uint64_t tsc_time) { if (mult_will_overflow_u64(tsc_time, 1000000000)) return tsc2usec(tsc_time) * 1000; else return (tsc_time * 1000000000) / get_tsc_freq(); }
uint64_t sec2tsc(uint64_t sec) { if (mult_will_overflow_u64(sec, system_timing.tsc_freq)) { /* in this case, we simply can't express the number of ticks */ warn("Wraparound in sec2tsc(), rounding up"); return (uint64_t)(-1); } else { return sec * system_timing.tsc_freq; } }