arm: protect state after signal handler
[minix.git] / lib / libsys / sys_hz.c
blob33c9c6aadde0f30afca6ef7a0365bb49d77806df
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: can not get HZ: error %d.\nUsing default HZ = %u\n",
22 r, (unsigned int) Hz);
26 return Hz;
29 u32_t
30 micros_to_ticks(u32_t micros)
32 u32_t ticks;
34 ticks = div64u(mul64u(micros, sys_hz()), 1000000);
35 if(ticks < 1) ticks = 1;
37 return ticks;