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 12 extern 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 21 static inline unsigned int 22 jiffies_to_msecs(const unsigned long x) 23 { 24 return (((uint64_t)(x)) * 1000 / hz); 25 } 26 27 static inline unsigned int 28 jiffies_to_usecs(const unsigned long x) 29 { 30 return (((uint64_t)(x)) * 1000000 / hz); 31 } 32 33 #define msecs_to_jiffies(x) (((uint64_t)(x)) * hz / 1000) 34 #define usecs_to_jiffies(x) (((uint64_t)(x)) * hz / 1000000) 35 #define nsecs_to_jiffies(x) (((uint64_t)(x)) * hz / 1000000000) 36 #define nsecs_to_jiffies64(x) (((uint64_t)(x)) * hz / 1000000000) 37 #define get_jiffies_64() jiffies 38 #define time_after(a,b) ((long)(b) - (long)(a) < 0) 39 #define time_after32(a,b) ((int32_t)((uint32_t)(b) - (uint32_t)(a)) < 0) 40 #define time_after_eq(a,b) ((long)(b) - (long)(a) <= 0) 41 #define time_before(a,b) ((long)(a) - (long)(b) < 0) 42 43 #endif 44