diff options
author | Bret Lambert <blambert@cvs.openbsd.org> | 2008-10-22 08:38:07 +0000 |
---|---|---|
committer | Bret Lambert <blambert@cvs.openbsd.org> | 2008-10-22 08:38:07 +0000 |
commit | ac935939d2c0019152c349397699491e8118a0e6 (patch) | |
tree | ba1001b9de2386de736ce483a58bdddd52c411df /sys | |
parent | 904e95b26845976fcb52afa20db47ac4f9b75ee2 (diff) |
Add timeout_add_msec(), for timeouts in milliseconds.
Idea and original patch mk@
ok mk@, krw@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/kern_timeout.c | 14 | ||||
-rw-r--r-- | sys/sys/timeout.h | 3 |
2 files changed, 15 insertions, 2 deletions
diff --git a/sys/kern/kern_timeout.c b/sys/kern/kern_timeout.c index 9a8afbf2c55..492a892fe4b 100644 --- a/sys/kern/kern_timeout.c +++ b/sys/kern/kern_timeout.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_timeout.c,v 1.28 2008/07/14 15:17:08 art Exp $ */ +/* $OpenBSD: kern_timeout.c,v 1.29 2008/10/22 08:38:06 blambert Exp $ */ /* * Copyright (c) 2001 Thomas Nordin <nordin@openbsd.org> * Copyright (c) 2000-2001 Artur Grabowski <art@openbsd.org> @@ -233,6 +233,18 @@ timeout_add_sec(struct timeout *to, int secs) } void +timeout_add_msec(struct timeout *to, int msecs) +{ + long long to_ticks; + + to_ticks = (long long)msecs * 1000 / tick; + if (to_ticks > INT_MAX) + to_ticks = INT_MAX; + + timeout_add(to, (int)to_ticks); +} + +void timeout_add_usec(struct timeout *to, int usecs) { int to_ticks = usecs / tick; diff --git a/sys/sys/timeout.h b/sys/sys/timeout.h index 283cf365119..8350029fcdb 100644 --- a/sys/sys/timeout.h +++ b/sys/sys/timeout.h @@ -1,4 +1,4 @@ -/* $OpenBSD: timeout.h,v 1.17 2008/07/11 14:18:39 blambert Exp $ */ +/* $OpenBSD: timeout.h,v 1.18 2008/10/22 08:38:06 blambert Exp $ */ /* * Copyright (c) 2000-2001 Artur Grabowski <art@openbsd.org> * All rights reserved. @@ -87,6 +87,7 @@ void timeout_add_tv(struct timeout *, struct timeval *); void timeout_add_ts(struct timeout *, struct timespec *); void timeout_add_bt(struct timeout *, struct bintime *); void timeout_add_sec(struct timeout *, int); +void timeout_add_msec(struct timeout *, int); void timeout_add_usec(struct timeout *, int); void timeout_add_nsec(struct timeout *, int); void timeout_del(struct timeout *); |