Importing 'mstohz' from NetBSD.
Josef Karthauser
joe at FreeBSD.org
Mon Jul 14 12:05:29 PDT 2003
It looks like NetBSD have a net function defined in the kernel.
--- param.h 2002/03/17 19:43:07 1.137
+++ param.h 2002/04/05 18:27:57 1.138
@@ -1,4 +1,4 @@
-/* $NetBSD: param.h,v 1.136 2002/03/09 01:42:13 thorpej Exp $ */
+/* $NetBSD: param.h,v 1.137 2002/03/17 19:43:07 atatat Exp $ */
/*-
* Copyright (c) 1982, 1986, 1989, 1993
@@ -274,5 +274,20 @@
#ifndef UBC_NWINS
#define UBC_NWINS 1024
#endif
+
+#ifdef _KERNEL
+/*
+ * macro to convert from milliseconds to hz without integer overflow
+ * Default version using only 32bits arithmetics.
+ * 64bit port can define 64bit version in their <machine/param.h>
+ * 0x20000 is safe for hz < 20000
+ */
+#ifndef mstohz
+#define mstohz(ms) \
+ (__predict_false((ms) >= 0x20000) ? \
+ ((ms +0u) / 1000u) * hz : \
+ ((ms +0u) * hz) / 1000u)
+#endif
+#endif /* _KERNEL */
#endif /* !_SYS_PARAM_H_ */
They have replaced TICKS_TO_HZ with calls to 'mstohz' in the usb stack
as well as in other places. Is this something that we want to do also?
Joe
--
Josef Karthauser (joe at tao.org.uk) http://www.josef-k.net/
FreeBSD (cvs meister, admin and hacker) http://www.uk.FreeBSD.org/
Physics Particle Theory (student) http://www.pact.cpes.sussex.ac.uk/
================ An eclectic mix of fact and theory. =================
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-arch/attachments/20030714/f590e18b/attachment.bin
More information about the freebsd-arch
mailing list