summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_sysctl.c
diff options
context:
space:
mode:
authorandre <andre@FreeBSD.org>2006-02-16 15:40:36 +0000
committerandre <andre@FreeBSD.org>2006-02-16 15:40:36 +0000
commit201a4f94009c982484911945dd073976fcbc30b6 (patch)
tree1cf7bcf54161058ad8b1b8ccb3e5e20521c58e33 /sys/kern/kern_sysctl.c
parent1372d441b5f58d5f1595729e8d1cdbbf98cf4cd7 (diff)
downloadFreeBSD-src-201a4f94009c982484911945dd073976fcbc30b6.zip
FreeBSD-src-201a4f94009c982484911945dd073976fcbc30b6.tar.gz
Make sysctl_msec_to_ticks(SYSCTL_HANDLER_ARGS) generally available instead
of being private to tcp_timer.c. Sponsored by: TCP/IP Optimization Fundraise 2005 MFC after: 3 days
Diffstat (limited to 'sys/kern/kern_sysctl.c')
-rw-r--r--sys/kern/kern_sysctl.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/sys/kern/kern_sysctl.c b/sys/kern/kern_sysctl.c
index 38fb5dc..aaa3dc3 100644
--- a/sys/kern/kern_sysctl.c
+++ b/sys/kern/kern_sysctl.c
@@ -822,6 +822,32 @@ sysctl_handle_int(SYSCTL_HANDLER_ARGS)
return (error);
}
+
+/*
+ * Based on on sysctl_handle_int() convert milliseconds into ticks.
+ */
+
+int
+sysctl_msec_to_ticks(SYSCTL_HANDLER_ARGS)
+{
+ int error, s, tt;
+
+ tt = *(int *)oidp->oid_arg1;
+ s = (int)((int64_t)tt * 1000 / hz);
+
+ error = sysctl_handle_int(oidp, &s, 0, req);
+ if (error || !req->newptr)
+ return (error);
+
+ tt = (int)((int64_t)s * hz / 1000);
+ if (tt < 1)
+ return (EINVAL);
+
+ *(int *)oidp->oid_arg1 = tt;
+ return (0);
+}
+
+
/*
* Handle a long, signed or unsigned. arg1 points to it.
*/
OpenPOWER on IntegriCloud