+
+/*
+ * Compute number of hz until specified time.
+ * Used to compute third argument to timeout() from an
+ * absolute time.
+ */
+hzto(tv)
+ struct timeval *tv;
+{
+ register long ticks;
+ register long sec;
+ int s = splhigh();
+
+ /*
+ * If number of milliseconds will fit in 32 bit arithmetic,
+ * then compute number of milliseconds to time and scale to
+ * ticks. Otherwise just compute number of hz in time, rounding
+ * times greater than representible to maximum value.
+ *
+ * Delta times less than 25 days can be computed ``exactly''.
+ * Maximum value for any timeout in 10ms ticks is 250 days.
+ */
+ sec = tv->tv_sec - time.tv_sec;
+ if (sec <= 0x7fffffff / 1000 - 1000)
+ ticks = ((tv->tv_sec - time.tv_sec) * 1000 +
+ (tv->tv_usec - time.tv_usec) / 1000) / (tick / 1000);
+ else if (sec <= 0x7fffffff / hz)
+ ticks = sec * hz;
+ else
+ ticks = 0x7fffffff;
+ splx(s);
+ return (ticks);
+}
+
+profil()
+{
+ register struct a {
+ short *bufbase;
+ unsigned bufsize;
+ unsigned pcoffset;
+ unsigned pcscale;
+ } *uap = (struct a *)u.u_ap;
+ register struct uprof *upp = &u.u_prof;
+
+ upp->pr_base = uap->bufbase;
+ upp->pr_size = uap->bufsize;
+ upp->pr_off = uap->pcoffset;
+ upp->pr_scale = uap->pcscale;
+}