Pawel Jakub Dawidek <pjd@FreeBSD.org> writes:
> http://people.freebsd.org/~pjd/patches/harvest_device_attach.2.patch
You can replace highbit(x) - 9 with flsll(x) - 10. Unfortunately, we
don't have flsll() in the kernel, but here's a simple implementation:
/*
* Find last bit set in an unsigned long long. Assumes that ULL is
* always 64 bits wide while UL may be either 32 or 64 bits wide.
*/
static __inline unsigned int
flsll(unsigned long long mask)
{
#ifdef __LP64__
return (flsl(mask));
#else
return (mask >> 32 ? 32 + flsl(mask >> 32) : flsl(mask));
#endif
}
On i386 and amd64, flsl() is an inline function that expands to a single
assembler instruction. On all other platforms, it is a function in
libkern, which is stupid - gcc and clang have builtin functions for it
which are almost certainly faster than a function call.
Same goes for s/last bit/first bit/; s/fls/ffs/g.
DES
--=20
Dag-Erling Sm=C3=B8rgrav - des@des.no
_______________________________________________
freebsd-security@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-security
To unsubscribe, send any mail to "freebsd-security-unsubscribe@freebsd.org"