+/*
+ * Set a timeout.
+ *
+ * fcn: function to call
+ * param: parameter to pass to function
+ * ts: timeout interval, in timespec
+ */
+void
+bsd_timeout(
+ timeout_fcn_t fcn,
+ void *param,
+ struct timespec *ts)
+{
+ uint64_t deadline = 0;
+
+ if (ts && (ts->tv_sec || ts->tv_nsec)) {
+ nanoseconds_to_absolutetime((uint64_t)ts->tv_sec * NSEC_PER_SEC + ts->tv_nsec, &deadline );
+ clock_absolutetime_interval_to_deadline( deadline, &deadline );
+ }
+ thread_call_func_delayed((thread_call_func_t)fcn, param, deadline);
+}
+
+/*
+ * Cancel a timeout.
+ */
+void
+bsd_untimeout(
+ register timeout_fcn_t fcn,
+ register void *param)
+{
+ thread_call_func_cancel((thread_call_func_t)fcn, param, FALSE);
+}
+