-/* Suspends execution for approximately NS nanoseconds.
- Note: this is ridiculously inaccurate. */
-void
-timer_nsleep (int64_t ns)
+/* Returns US microseconds in timer ticks, rounding up. */
+int64_t
+timer_us2ticks (int64_t us)
+{
+ return DIV_ROUND_UP (us * TIMER_FREQ, 1000000);
+}
+
+/* Returns NS nanoseconds in timer ticks, rounding up. */
+int64_t
+timer_ns2ticks (int64_t ns)