minix/lib/libsys/sys_hz.c
Gerard 78da142dab Replaced common u64.h functions with operators.
Change-Id: I71b7b4879209eeff89ce5748d67102afebf871dc
2014-03-02 12:28:32 +01:00

39 lines
629 B
C

#include <stdio.h>
#include <sys/time.h>
#include <sys/types.h>
#include <minix/u64.h>
#include <minix/config.h>
#include <minix/const.h>
#include "sysutil.h"
static u32_t Hz;
u32_t
sys_hz(void)
{
if(Hz <= 0) {
int r;
/* Get HZ. */
if((r=sys_getinfo(GET_HZ, &Hz, sizeof(Hz), 0, 0)) != OK) {
Hz = DEFAULT_HZ;
printf("sys_hz: can not get HZ: error %d.\nUsing default HZ = %u\n",
r, (unsigned int) Hz);
}
}
return Hz;
}
u32_t
micros_to_ticks(u32_t micros)
{
u32_t ticks;
ticks = (u32_t)(((u64_t)micros * sys_hz()) / 1000000);
if(ticks < 1) ticks = 1;
return ticks;
}