From owner-freebsd-arch@FreeBSD.ORG Mon Jul 14 12:05:29 2003 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 53B1F37B401 for ; Mon, 14 Jul 2003 12:05:29 -0700 (PDT) Received: from genius.tao.org.uk (genius.tao.org.uk [212.135.162.51]) by mx1.FreeBSD.org (Postfix) with ESMTP id A623043F85 for ; Mon, 14 Jul 2003 12:05:28 -0700 (PDT) (envelope-from joe@genius.tao.org.uk) Received: by genius.tao.org.uk (Postfix, from userid 100) id F01284A7C; Mon, 14 Jul 2003 20:05:14 +0100 (BST) Date: Mon, 14 Jul 2003 20:05:14 +0100 From: Josef Karthauser To: arch@freebsd.org Message-ID: <20030714190514.GA3270@genius.tao.org.uk> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="LZvS9be/3tNcYl/X" Content-Disposition: inline User-Agent: Mutt/1.5.4i Subject: Importing 'mstohz' from NetBSD. X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Jul 2003 19:05:29 -0000 --LZvS9be/3tNcYl/X Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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 $ */ =20 /*- * 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 + * 0x20000 is safe for hz < 20000 + */ +#ifndef mstohz +#define mstohz(ms) \ + (__predict_false((ms) >=3D 0x20000) ? \ + ((ms +0u) / 1000u) * hz : \ + ((ms +0u) * hz) / 1000u) +#endif +#endif /* _KERNEL */ =20 #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 --=20 Josef Karthauser (joe@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/ =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D An eclectic mix of fact an= d theory. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --LZvS9be/3tNcYl/X Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2 (FreeBSD) iEYEARECAAYFAj8S/uoACgkQXVIcjOaxUBaKHgCfVLa4RfUMCoCBfN0aKmqWlpZ3 rwwAnRizAO3TlWVsZ/zGmKtwwTNAyTC3 =bUOR -----END PGP SIGNATURE----- --LZvS9be/3tNcYl/X--