15 #ifndef _LINUX_HRTIMER_H
16 #define _LINUX_HRTIMER_H
18 #include <linux/rbtree.h>
21 #include <linux/list.h>
22 #include <linux/wait.h>
80 #define HRTIMER_STATE_INACTIVE 0x00
81 #define HRTIMER_STATE_ENQUEUED 0x01
82 #define HRTIMER_STATE_CALLBACK 0x02
83 #define HRTIMER_STATE_MIGRATE 0x04
114 #ifdef CONFIG_TIMER_STATS
183 #ifdef CONFIG_HIGH_RES_TIMERS
187 unsigned long nr_events;
188 unsigned long nr_retries;
189 unsigned long nr_hangs;
213 static inline void hrtimer_set_expires_tv64(
struct hrtimer *timer,
s64 tv64)
215 timer->
node.expires.tv64 = tv64;
219 static inline void hrtimer_add_expires(
struct hrtimer *timer,
ktime_t time)
225 static inline void hrtimer_add_expires_ns(
struct hrtimer *timer,
u64 ns)
231 static inline ktime_t hrtimer_get_expires(
const struct hrtimer *timer)
233 return timer->
node.expires;
236 static inline ktime_t hrtimer_get_softexpires(
const struct hrtimer *timer)
241 static inline s64 hrtimer_get_expires_tv64(
const struct hrtimer *timer)
243 return timer->
node.expires.tv64;
245 static inline s64 hrtimer_get_softexpires_tv64(
const struct hrtimer *timer)
250 static inline s64 hrtimer_get_expires_ns(
const struct hrtimer *timer)
252 return ktime_to_ns(timer->
node.expires);
255 static inline ktime_t hrtimer_expires_remaining(
const struct hrtimer *timer)
257 return ktime_sub(timer->
node.expires, timer->
base->get_time());
260 #ifdef CONFIG_HIGH_RES_TIMERS
261 struct clock_event_device;
263 extern void hrtimer_interrupt(
struct clock_event_device *
dev);
270 return timer->
base->get_time();
273 static inline int hrtimer_is_hres_active(
struct hrtimer *timer)
275 return timer->
base->cpu_base->hres_active;
278 extern void hrtimer_peek_ahead_timers(
void);
286 # define HIGH_RES_NSEC 1
287 # define KTIME_HIGH_RES (ktime_t) { .tv64 = HIGH_RES_NSEC }
288 # define MONOTONIC_RES_NSEC HIGH_RES_NSEC
289 # define KTIME_MONOTONIC_RES KTIME_HIGH_RES
291 extern void clock_was_set_delayed(
void);
295 # define MONOTONIC_RES_NSEC LOW_RES_NSEC
296 # define KTIME_MONOTONIC_RES KTIME_LOW_RES
298 static inline void hrtimer_peek_ahead_timers(
void) { }
306 return timer->
base->softirq_time;
309 static inline int hrtimer_is_hres_active(
struct hrtimer *timer)
314 static inline void clock_was_set_delayed(
void) { }
319 #ifdef CONFIG_TIMERFD
341 #ifdef CONFIG_DEBUG_OBJECTS_TIMERS
342 extern void hrtimer_init_on_stack(
struct hrtimer *timer,
clockid_t which_clock,
345 extern void destroy_hrtimer_on_stack(
struct hrtimer *timer);
347 static inline void hrtimer_init_on_stack(
struct hrtimer *timer,
353 static inline void destroy_hrtimer_on_stack(
struct hrtimer *timer) { }
363 unsigned long delta_ns,
369 static inline int hrtimer_start_expires(
struct hrtimer *timer,
374 soft = hrtimer_get_softexpires(timer);
375 hard = hrtimer_get_expires(timer);
376 delta = ktime_to_ns(ktime_sub(hard, soft));
396 static inline int hrtimer_active(
const struct hrtimer *timer)
404 static inline int hrtimer_is_queued(
struct hrtimer *timer)
413 static inline int hrtimer_callback_running(
struct hrtimer *timer)
423 static inline u64 hrtimer_forward_now(
struct hrtimer *timer,
452 #if BITS_PER_LONG < 64
455 # define ktime_divns(kt, div) (u64)((kt).tv64 / (div))