+static uint32_t
+calend_adjust(void)
+{
+ uint64_t now, t64;
+ int32_t delta;
+ uint32_t interval = 0;
+
+ commpage_disable_timestamp();
+
+ now = mach_absolute_time();
+
+ delta = clock_calend.adjdelta;
+
+ if (delta > 0) {
+ clock_calend.offset += clock_calend.adjoffset;
+
+ calend_adjtotal -= delta;
+ if (delta > calend_adjtotal) {
+ clock_calend.adjdelta = delta = (int32_t)calend_adjtotal;
+
+ nanoseconds_to_absolutetime((uint64_t)delta, &t64);
+ clock_calend.adjoffset = (uint32_t)t64;
+ }
+ }
+ else
+ if (delta < 0) {
+ clock_calend.offset -= clock_calend.adjoffset;
+
+ calend_adjtotal -= delta;
+ if (delta < calend_adjtotal) {
+ clock_calend.adjdelta = delta = (int32_t)calend_adjtotal;
+
+ nanoseconds_to_absolutetime((uint64_t)-delta, &t64);
+ clock_calend.adjoffset = (uint32_t)t64;
+ }
+
+ if (clock_calend.adjdelta != 0)
+ clock_calend.adjstart = now;
+ }
+
+ if (clock_calend.adjdelta != 0)
+ interval = calend_adjinterval;
+
+#if CONFIG_DTRACE
+ clock_track_calend_nowait();
+#endif
+
+ return (interval);
+}