hrtimer
enum hrtimer_restart (*function)(struct hrtimer *);
#define hrtimer_active(hrtimer) linux_hrtimer_active(hrtimer)
#define hrtimer_try_to_cancel(hrtimer) linux_hrtimer_try_to_cancel(hrtimer)
#define hrtimer_cancel(hrtimer) linux_hrtimer_cancel(hrtimer)
#define hrtimer_init(hrtimer, clock, mode) do { \
linux_hrtimer_init(hrtimer); \
#define hrtimer_set_expires(hrtimer, time) \
linux_hrtimer_set_expires(hrtimer, time)
#define hrtimer_start(hrtimer, time, mode) do { \
linux_hrtimer_start(hrtimer, time); \
#define hrtimer_start_range_ns(hrtimer, time, prec, mode) do { \
linux_hrtimer_start_range_ns(hrtimer, time, prec); \
#define hrtimer_forward_now(hrtimer, interval) do { \
linux_hrtimer_forward_now(hrtimer, interval); \
bool linux_hrtimer_active(struct hrtimer *);
int linux_hrtimer_try_to_cancel(struct hrtimer *);
int linux_hrtimer_cancel(struct hrtimer *);
void linux_hrtimer_init(struct hrtimer *);
void linux_hrtimer_set_expires(struct hrtimer *, ktime_t);
void linux_hrtimer_start(struct hrtimer *, ktime_t);
void linux_hrtimer_start_range_ns(struct hrtimer *, ktime_t, int64_t);
void linux_hrtimer_forward_now(struct hrtimer *, ktime_t);
memset(hrtimer, 0, sizeof(*hrtimer));
mtx_init(&hrtimer->mtx, "hrtimer", NULL,
callout_init_mtx(&hrtimer->callout, &hrtimer->mtx, 0);
linux_hrtimer_set_expires(struct hrtimer *hrtimer, ktime_t time)
hrtimer->expires = ktime_to_ns(time);
linux_hrtimer_start(struct hrtimer *hrtimer, ktime_t time)
linux_hrtimer_start_range_ns(hrtimer, time, 0);
linux_hrtimer_start_range_ns(struct hrtimer *hrtimer, ktime_t time,
mtx_lock(&hrtimer->mtx);
hrtimer->precision = nsec;
callout_reset_sbt(&hrtimer->callout, nstosbt(ktime_to_ns(time)),
nstosbt(nsec), hrtimer_call_handler, hrtimer, 0);
mtx_unlock(&hrtimer->mtx);
linux_hrtimer_forward_now(struct hrtimer *hrtimer, ktime_t interval)
mtx_lock(&hrtimer->mtx);
callout_reset_sbt(&hrtimer->callout, nstosbt(ktime_to_ns(interval)),
nstosbt(hrtimer->precision), hrtimer_call_handler, hrtimer, 0);
mtx_unlock(&hrtimer->mtx);
struct hrtimer *hrtimer;
hrtimer = arg;
ret = hrtimer->function(hrtimer);
callout_schedule_sbt(&hrtimer->callout,
nstosbt(hrtimer->expires), nstosbt(hrtimer->precision), 0);
callout_deactivate(&hrtimer->callout);
linux_hrtimer_active(struct hrtimer *hrtimer)
mtx_lock(&hrtimer->mtx);
ret = callout_active(&hrtimer->callout);
mtx_unlock(&hrtimer->mtx);
linux_hrtimer_try_to_cancel(struct hrtimer *hrtimer)
mtx_lock(&hrtimer->mtx);
ret = callout_stop(&hrtimer->callout);
mtx_unlock(&hrtimer->mtx);
linux_hrtimer_cancel(struct hrtimer *hrtimer)
return (callout_drain(&hrtimer->callout) > 0);
linux_hrtimer_init(struct hrtimer *hrtimer)
struct hrtimer mit_timer;