1 #ifndef _LINUX_JIFFIES_H
2 #define _LINUX_JIFFIES_H
4 #include <linux/kernel.h>
5 #include <linux/time64.h>
6 #include <linux/typecheck.h>
7 #include <linux/types.h>
9 #define time_after(a,b) \
10 (typecheck(unsigned long, a) && \
11 typecheck(unsigned long, b) && \
12 ((long)((b) - (a)) < 0))
13 #define time_before(a,b) time_after(b,a)
15 #define time_after_eq(a,b) \
16 (typecheck(unsigned long, a) && \
17 typecheck(unsigned long, b) && \
18 ((long)((a) - (b)) >= 0))
19 #define time_before_eq(a,b) time_after_eq(b,a)
21 #define time_in_range(a,b,c) \
22 (time_after_eq(a,b) && \
25 #define time_in_range_open(a,b,c) \
26 (time_after_eq(a,b) && \
29 #define time_after64(a,b) \
30 (typecheck(__u64, a) && \
31 typecheck(__u64, b) && \
32 ((__s64)((b) - (a)) < 0))
33 #define time_before64(a,b) time_after64(b,a)
35 #define time_after_eq64(a,b) \
36 (typecheck(__u64, a) && \
37 typecheck(__u64, b) && \
38 ((__s64)((a) - (b)) >= 0))
39 #define time_before_eq64(a,b) time_after_eq64(b,a)
41 #define time_in_range64(a, b, c) \
42 (time_after_eq64(a, b) && \
43 time_before_eq64(a, c))
47 static inline u64 jiffies_to_nsecs(const unsigned long j)
49 return (u64)j * NSEC_PER_MSEC;
52 static inline unsigned jiffies_to_msecs(const unsigned long j)
57 static inline unsigned long msecs_to_jiffies(const unsigned int m)
62 static inline unsigned long nsecs_to_jiffies(u64 n)
64 return n / NSEC_PER_MSEC;
67 static inline u64 sched_clock(void)
71 clock_gettime(CLOCK_MONOTONIC, &ts);
73 return ((s64) ts.tv_sec * NSEC_PER_SEC) + ts.tv_nsec;
76 static inline u64 local_clock(void)
81 #define jiffies nsecs_to_jiffies(sched_clock())