1/* Public domain. */ 2 3#ifndef _LINUX_JIFFIES_H 4#define _LINUX_JIFFIES_H 5 6#include <sys/types.h> 7#include <sys/param.h> 8#include <sys/time.h> 9#include <sys/limits.h> 10#include <sys/kernel.h> 11 12extern volatile unsigned long jiffies; 13#define jiffies_64 jiffies /* XXX */ 14#undef HZ 15#define HZ hz 16 17#define MAX_JIFFY_OFFSET ((INT_MAX >> 1) - 1) 18 19#define time_in_range(x, min, max) ((x) >= (min) && (x) <= (max)) 20 21static inline unsigned int 22jiffies_to_msecs(const unsigned long x) 23{ 24 return (((uint64_t)(x)) * 1000 / hz); 25} 26 27static inline unsigned int 28jiffies_to_usecs(const unsigned long x) 29{ 30 return (((uint64_t)(x)) * 1000000 / hz); 31} 32 33static inline unsigned int 34jiffies_to_nsecs(const unsigned long x) 35{ 36 return (((uint64_t)(x)) * 1000000000 / hz); 37} 38 39#define msecs_to_jiffies(x) (((uint64_t)(x)) * hz / 1000) 40#define usecs_to_jiffies(x) (((uint64_t)(x)) * hz / 1000000) 41#define nsecs_to_jiffies(x) (((uint64_t)(x)) * hz / 1000000000) 42#define nsecs_to_jiffies64(x) (((uint64_t)(x)) * hz / 1000000000) 43 44static inline uint64_t 45get_jiffies_64(void) 46{ 47 return jiffies; 48} 49 50static inline int 51time_after(const unsigned long a, const unsigned long b) 52{ 53 return((long)(b - a) < 0); 54} 55#define time_before(a,b) time_after(b,a) 56 57static inline int 58time_after_eq(const unsigned long a, const unsigned long b) 59{ 60 return((long)(b - a) <= 0); 61} 62 63static inline int 64time_after_eq64(const unsigned long long a, const unsigned long long b) 65{ 66 return((long long)(b - a) <= 0); 67} 68 69#define time_after32(a,b) ((int32_t)((uint32_t)(b) - (uint32_t)(a)) < 0) 70 71#endif 72