From 9c37d63b31d845553e5fe1b39d562cca815ef914 Mon Sep 17 00:00:00 2001 From: Constantine A. Murenin Date: Wed, 24 Feb 2010 18:23:50 -0500 Subject: [PATCH 1/2] callout(9): introduce callout_reset_{,m}s, similarly to timeout_add_{,m}sec on OpenBSD --- sys/kern/kern_timeout.c | 26 ++++++++++++++++++++++++++ sys/sys/callout.h | 2 ++ 2 files changed, 28 insertions(+), 0 deletions(-) diff --git a/sys/kern/kern_timeout.c b/sys/kern/kern_timeout.c index 189ffb0..c296c1c 100644 --- a/sys/kern/kern_timeout.c +++ b/sys/kern/kern_timeout.c @@ -109,6 +109,8 @@ #include #include +#include + #ifndef MAX_SOFTCLOCK_STEPS #define MAX_SOFTCLOCK_STEPS 100 /* Maximum allowed value of steps. */ #endif @@ -385,6 +387,30 @@ callout_reset(struct callout *c, int to_ticks, void (*ftn)(void *), crit_exit_gd(gd); } +void +callout_reset_s(struct callout *c, int s, void (*ftn)(void *), + void *arg) +{ + uintmax_t t; + + t = (uintmax_t)s * hz; + if (t > INT_MAX) + t = INT_MAX; + callout_reset(c, t, ftn, arg); +} + +void +callout_reset_ms(struct callout *c, int ms, void (*ftn)(void *), + void *arg) +{ + uintmax_t t; + + t = (uintmax_t)ms * hz / 1000; + if (t > INT_MAX) + t = INT_MAX; + callout_reset(c, t, ftn, arg); +} + /* * Stop a running timer. WARNING! If called on a cpu other then the one * the callout was started on this function will liveloop on its IPI to diff --git a/sys/sys/callout.h b/sys/sys/callout.h index 5113793..492c01e 100644 --- a/sys/sys/callout.h +++ b/sys/sys/callout.h @@ -92,6 +92,8 @@ void hardclock_softtick(struct globaldata *); void callout_init (struct callout *); void callout_init_mp (struct callout *); void callout_reset (struct callout *, int, void (*)(void *), void *); +void callout_reset_s (struct callout *, int, void (*)(void *), void *); +void callout_reset_ms (struct callout *, int, void (*)(void *), void *); int callout_stop (struct callout *); #endif -- 1.6.6