summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_timeout.c
diff options
context:
space:
mode:
authorblambert <blambert@openbsd.org>2008-10-22 08:38:06 +0000
committerblambert <blambert@openbsd.org>2008-10-22 08:38:06 +0000
commitda9155cce22ed9074313bc8ab8997cc2f1358efd (patch)
treeade3511aefa0a51f65fae7d360c9e8c27f0f1965 /sys/kern/kern_timeout.c
parentlog pcap stats upon SIGUSR1; ok canacar (diff)
downloadwireguard-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.c14
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;