Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 8 Jun 2015 07:47:47 +0800
From:      Erich Dollansky <erichsfreebsdlist@alogt.com>
To:        Hans Petter Selasky <hps@selasky.org>
Cc:        "freebsd-hackers@freebsd.org" <freebsd-hackers@FreeBSD.org>
Subject:   Re: allow ffs & co. a binary search
Message-ID:  <20150608074747.55be51c8@B85M-HD3-0.alogt.com>
In-Reply-To: <55745D08.5000505@selasky.org>
References:  <20150607081315.7c0f09fb@B85M-HD3-0.alogt.com> <5573EA5E.40806@selasky.org> <20150607195245.62dc191f@B85M-HD3-0.alogt.com> <55745D08.5000505@selasky.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Hi Hans,

On Sun, 07 Jun 2015 17:02:32 +0200
Hans Petter Selasky <hps@selasky.org> wrote:

> On 06/07/15 13:52, Erich Dollansky wrote:
> > On Sun, 07 Jun 2015 08:53:18 +0200
> > Hans Petter Selasky <hps@selasky.org> wrote:
> >> On 06/07/15 02:13, Erich Dollansky wrote:
> >>> If you like the binary way I could give you the sources for the
> >>> complete family following your style to replace the older
> >>> functions.
> >>>
> >> I think this is not the fastest way to do it. You first find the
> >> LSB,
> >
> > I never thought of this as I took the code a long, long time from
> > university and expanded it over time from 8 to 64 bits.
> >
> >> then you do a sumbits, which doesn't have any conditionals IF/ELSE
> >> and performs better with the CPU pipeline. I think the software
> >> ffs() is only used for platforms which doesn't have a hardware
> >> version btw:
> >
> > The code is not x86 specific.
> >>
> > This one is the same:
> >
> >>   From my libmbin:
> >>
> >> int ffs(int value)
> >> {
> >> 	int retval = mbin_sumbits32(mbin_lsb32(value) - 1);
> >> 	if (retval == 32)
> >> 		retval = 0;
> >> 	else
> >> 		retval++;
> >> 	return (retval);
> >> }
> >>
> > Where is this? Should this also be in 10.1?
> 
> It is currently nowhere, just in my private SVN. Would you wrap up 
> complete patch, and I can put it into Phabricator and let more people 
> look at it. Does your patch cover both kernel and userspace?
> 
I can do this but will need some help especially in the coding style
department. Can I e-mail the source first to see if it matches the
formal requirements?
> >
> > What I saw is that all CPUs except ARM uses the software version.
> 
> Kernel too?

I did not check.

Erich



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20150608074747.55be51c8>