xref: /openbsd-src/sys/dev/pci/drm/include/linux/jiffies.h (revision 3374c67d44f9b75b98444cbf63020f777792342e)
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 static inline unsigned int
34 jiffies_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 #define get_jiffies_64()	jiffies
44 #define time_after(a,b)		((long)(b) - (long)(a) < 0)
45 #define time_after32(a,b)	((int32_t)((uint32_t)(b) - (uint32_t)(a)) < 0)
46 #define time_after_eq(a,b)	((long)(b) - (long)(a) <= 0)
47 #define time_before(a,b)	((long)(a) - (long)(b) < 0)
48 
49 #endif
50