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

Function callout_when

freebsd/kern/kern_timeout.c:834–875  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

832}
833
834void
835callout_when(sbintime_t sbt, sbintime_t precision, int flags,
836 sbintime_t *res, sbintime_t *prec_res)
837{
838 sbintime_t to_sbt, to_pr;
839
840 if ((flags & (C_ABSOLUTE | C_PRECALC)) != 0) {
841 *res = sbt;
842 *prec_res = precision;
843 return;
844 }
845 if ((flags & C_HARDCLOCK) != 0 && sbt < tick_sbt)
846 sbt = tick_sbt;
847 if ((flags & C_HARDCLOCK) != 0 || sbt >= sbt_tickthreshold) {
848 /*
849 * Obtain the time of the last hardclock() call on
850 * this CPU directly from the kern_clocksource.c.
851 * This value is per-CPU, but it is equal for all
852 * active ones.
853 */
854#ifdef __LP64__
855 to_sbt = DPCPU_GET(hardclocktime);
856#else
857 spinlock_enter();
858 to_sbt = DPCPU_GET(hardclocktime);
859 spinlock_exit();
860#endif
861 if (cold && to_sbt == 0)
862 to_sbt = sbinuptime();
863 if ((flags & C_HARDCLOCK) == 0)
864 to_sbt += tick_sbt;
865 } else
866 to_sbt = sbinuptime();
867 if (SBT_MAX - to_sbt < sbt)
868 to_sbt = SBT_MAX;
869 else
870 to_sbt += sbt;
871 *res = to_sbt;
872 to_pr = ((C_PRELGET(flags) < 0) ? sbt >> tc_precexp :
873 sbt >> C_PRELGET(flags));
874 *prec_res = to_pr > precision ? to_pr : precision;
875}
876
877/*
878 * New interface; clients allocate their own callout structures.

Callers 2

sleepq_set_timeout_sbtFunction · 0.85
callout_reset_sbt_onFunction · 0.85

Calls 3

sbinuptimeFunction · 0.85
spinlock_enterFunction · 0.50
spinlock_exitFunction · 0.50

Tested by

no test coverage detected