panic() cleanup.
[minix.git] / lib / libsys / sys_hz.c
blobaf6f0346a59a80b69ba13e6abc5ed127ca9567e3
2 #include <stdio.h>
3 #include <sys/time.h>
4 #include <sys/types.h>
5 #include <minix/u64.h>
6 #include <minix/config.h>
7 #include <minix/const.h>
9 #include "sysutil.h"
11 static u32_t Hz;
13 u32_t
14 sys_hz(void)
16 if(Hz <= 0) {
17 int r;
18 /* Get HZ. */
19 if((r=sys_getinfo(GET_HZ, &Hz, sizeof(Hz), 0, 0)) != OK) {
20 Hz = DEFAULT_HZ;
21 printf("sys_hz: %d: reverting to HZ = %d\n", r, Hz);
25 return Hz;
28 u32_t
29 micros_to_ticks(u32_t micros)
31 u32_t ticks;
33 ticks = div64u(mul64u(micros, sys_hz()), 1000000);
34 if(ticks < 1) ticks = 1;
36 return ticks;