diff options
author | 2008-10-22 08:38:06 +0000 | |
---|---|---|
committer | 2008-10-22 08:38:06 +0000 | |
commit | da9155cce22ed9074313bc8ab8997cc2f1358efd (patch) | |
tree | ade3511aefa0a51f65fae7d360c9e8c27f0f1965 /sys/kern/kern_timeout.c | |
parent | log pcap stats upon SIGUSR1; ok canacar (diff) | |
download | wireguard-openbsd-da9155cce22ed9074313bc8ab8997cc2f1358efd.tar.xz wireguard-openbsd-da9155cce22ed9074313bc8ab8997cc2f1358efd.zip |
Add timeout_add_msec(), for timeouts in milliseconds.
Idea and original patch mk@
ok mk@, krw@
Diffstat (limited to 'sys/kern/kern_timeout.c')
-rw-r--r-- | sys/kern/kern_timeout.c | 14 |
1 files changed, 13 insertions, 1 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; |