MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ffclock_convert_abs

Function ffclock_convert_abs

freebsd/kern/kern_tc.c:815–848  ·  view source on GitHub ↗

* Absolute clock conversion. Low level function to convert ffcounter to * bintime. The ffcounter is converted using the current ffclock period estimate * or the "interpolated period" to ensure monotonicity. * NOTE: this conversion may have been deferred, and the clock updated since the * hardware counter has been read. */

Source from the content-addressed store, hash-verified

813 * hardware counter has been read.
814 */
815void
816ffclock_convert_abs(ffcounter ffcount, struct bintime *bt, uint32_t flags)
817{
818 struct fftimehands *ffth;
819 struct bintime bt2;
820 ffcounter ffdelta;
821 uint8_t gen;
822
823 /*
824 * No locking but check generation has not changed. Also need to make
825 * sure ffdelta is positive, i.e. ffcount > tick_ffcount.
826 */
827 do {
828 ffth = fftimehands;
829 gen = ffth->gen;
830 if (ffcount > ffth->tick_ffcount)
831 ffdelta = ffcount - ffth->tick_ffcount;
832 else
833 ffdelta = ffth->tick_ffcount - ffcount;
834
835 if ((flags & FFCLOCK_LERP) == FFCLOCK_LERP) {
836 *bt = ffth->tick_time_lerp;
837 ffclock_convert_delta(ffdelta, ffth->period_lerp, &bt2);
838 } else {
839 *bt = ffth->tick_time;
840 ffclock_convert_delta(ffdelta, ffth->cest.period, &bt2);
841 }
842
843 if (ffcount > ffth->tick_ffcount)
844 bintime_add(bt, &bt2);
845 else
846 bintime_sub(bt, &bt2);
847 } while (gen == 0 || gen != ffth->gen);
848}
849
850/*
851 * Difference clock conversion.

Callers 1

ffclock_abstimeFunction · 0.85

Calls 3

ffclock_convert_deltaFunction · 0.85
bintime_addFunction · 0.85
bintime_subFunction · 0.85

Tested by

no test coverage detected