make vfs & filesystems use failable copying
[minix3.git] / lib / libsys / sys_hz.c
blob1f2c776585e8ee2d6381f5deb477b9d3e2cc0713
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 = (u32_t)(((u64_t)micros * sys_hz()) / 1000000);
35 if(ticks < 1) ticks = 1;
37 return ticks;