matos/core/time.c

30 lines
550 B
C
Raw Normal View History

2020-04-27 23:08:36 +02:00
#include "time.h"
unsigned long volatile jiffies = INITIAL_JIFFIES;
unsigned int jiffies_to_msecs(const unsigned long j)
{
return (1000L / HZ) * j;
}
unsigned int jiffies_to_usecs(const unsigned long j)
{
return (1000000L / HZ) * j;
}
2020-04-30 23:16:41 +02:00
unsigned long msecs_to_jiffies(const unsigned int m)
{
#if HZ >= 1000 && !(HZ % 1000)
return m * (HZ / 1000L);
#else
// This could overflow
return (m * HZ) / 1000L;
#endif
}
2021-01-22 22:59:45 +01:00
unsigned long usecs_to_jiffies(const unsigned int u)
{
2020-04-30 23:16:41 +02:00
// This could overflow
return (u * HZ) / 1000000L;
}