From owner-freebsd-hackers Sun Aug 22 6:35:50 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from ns.skylink.it (ns.skylink.it [194.177.113.1]) by hub.freebsd.org (Postfix) with ESMTP id 93C7114F04 for ; Sun, 22 Aug 1999 06:35:42 -0700 (PDT) (envelope-from n_hibma@skylink.it) Received: from heidi.plazza.it (va-160.skylink.it [194.185.55.160]) by ns.skylink.it (8.9.1/8.8.8) with ESMTP id PAA11722; Sun, 22 Aug 1999 15:35:10 +0200 Received: from localhost (localhost [127.0.0.1]) by heidi.plazza.it (8.9.3/8.8.5) with ESMTP id PAA21846; Sun, 22 Aug 1999 15:32:26 +0200 (CEST) Date: Sun, 22 Aug 1999 15:32:25 +0200 (CEST) From: Nick Hibma X-Sender: n_hibma@heidi.plazza.it Reply-To: Nick Hibma To: Peter Dufault Cc: hackers@FreeBSD.ORG Subject: Re: from number to power of two In-Reply-To: <199908221314.JAA18225@hda.hda.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Unfortunately the kernel is compiled with -O which does not include inlining (dunno about explicit inlining, but don't think so). Nick On Sun, 22 Aug 1999, Peter Dufault wrote: > > It seems that all the solutions are too generic and slow. As I only have > > to check the numbers 0-32 (actually 1-32), a block of if statements is > > almost as fast as a table look up in 33 elements. > > I doubt it - use the table for a small fixed size set then > use Warner's "(n) ? (1 << (ffs(n) - 1)) : 0". > The possible inline ffs is in machine/cpufunc.h > > ffs() is fundamental to scheduling queues and cryptography and > should have attention paid to it. As Warner said, it could be > a single instruction on some architectures. > > Peter > > -- > Peter Dufault (dufault@hda.com) Realtime development, Machine control, > HD Associates, Inc. Safety critical systems, Agency approval > > -- e-Mail: hibma@skylink.it To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message