1 /* SPDX-License-Identifier: GPL-2.0+ */
6 #include <linux/typecheck.h>
8 unsigned long get_timer(unsigned long base);
11 * Return the current value of a monotonically increasing microsecond timer.
12 * Granularity may be larger than 1us if hardware does not support this.
14 unsigned long timer_get_us(void);
17 * These inlines deal with timer wrapping correctly. You are
18 * strongly encouraged to use them
19 * 1. Because people otherwise forget
20 * 2. Because if the timer wrap changes in future you won't have to
21 * alter your driver code.
23 * time_after(a,b) returns true if the time a is after time b.
25 * Do this with "<0" and ">=0" to only test the sign of the result. A
26 * good compiler would generate better code (and a really good compiler
27 * wouldn't care). Gcc is currently neither.
29 #define time_after(a,b) \
30 (typecheck(unsigned long, a) && \
31 typecheck(unsigned long, b) && \
32 ((long)((b) - (a)) < 0))
33 #define time_before(a,b) time_after(b,a)
35 #define time_after_eq(a,b) \
36 (typecheck(unsigned long, a) && \
37 typecheck(unsigned long, b) && \
38 ((long)((a) - (b)) >= 0))
39 #define time_before_eq(a,b) time_after_eq(b,a)
42 * Calculate whether a is in the range of [b, c].
44 #define time_in_range(a,b,c) \
45 (time_after_eq(a,b) && \
49 * Calculate whether a is in the range of [b, c).
51 #define time_in_range_open(a,b,c) \
52 (time_after_eq(a,b) && \