+#endif
+ setsoftclock();
+}
+
+/*
+ * Software (low priority) clock interrupt.
+ * Run periodic events from timeout queue.
+ */
+/*ARGSUSED*/
+void
+softclock()
+{
+ register struct callout *c;
+ register void *arg;
+ register void (*func) __P((void *));
+ register int s;
+
+ s = splhigh();
+ while ((c = calltodo.c_next) != NULL && c->c_time <= 0) {
+ func = c->c_func;
+ arg = c->c_arg;
+ calltodo.c_next = c->c_next;
+ c->c_next = callfree;
+ callfree = c;
+ splx(s);
+ (*func)(arg);
+ (void) splhigh();
+ }
+ splx(s);
+}
+
+/*
+ * Arrange that (*func)(arg) is called in t/hz seconds.
+ */
+void
+timeout(func, arg, t)
+ void (*func) __P((void *));
+ void *arg;
+ register int t;
+{
+ register struct callout *p1, *p2, *pnew;
+ register int s;
+
+ s = splhigh();
+ if (t <= 0)
+ t = 1;
+ pnew = callfree;
+ if (pnew == NULL)
+ panic("timeout table overflow");
+ callfree = pnew->c_next;
+ pnew->c_arg = arg;
+ pnew->c_func = func;
+ for (p1 = &calltodo; (p2 = p1->c_next) && p2->c_time < t; p1 = p2)
+ if (p2->c_time > 0)
+ t -= p2->c_time;
+ p1->c_next = pnew;
+ pnew->c_next = p2;
+ pnew->c_time = t;
+ if (p2)
+ p2->c_time -= t;
+ splx(s);
+}
+
+/*
+ * untimeout is called to remove a function timeout call
+ * from the callout structure.
+ */
+void
+untimeout(func, arg)
+ void (*func) __P((void *));
+ void *arg;
+{
+ register struct callout *p1, *p2;
+ register int s;
+
+ s = splhigh();
+ for (p1 = &calltodo; (p2 = p1->c_next) != NULL; p1 = p2) {
+ if (p2->c_func == func && p2->c_arg == arg) {
+ if (p2->c_next && p2->c_time > 0)
+ p2->c_next->c_time += p2->c_time;
+ p1->c_next = p2->c_next;
+ p2->c_next = callfree;
+ callfree = p2;
+ break;
+ }
+ }
+ splx(s);
+}
+
+/*
+ * Compute number of hz until specified time.
+ * Used to compute third argument to timeout() from an
+ * absolute time.
+ */
+int
+hzto(tv)
+ struct timeval *tv;
+{
+ register long ticks, sec;
+ int s;