看板FB_security
标 题Re: Collecting entropy from device_attach() times.
发信站NCTU CS FreeBSD Server (Thu Sep 20 19:58:54 2012)
转信站ptt!csnews.cs.nctu!news.cs.nctu!.cs.nctucs.nctu!.org!ownorg!owner-free
Pawel Jakub Dawidek <
[email protected]> 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 -
[email protected]
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-security
To unsubscribe, send any mail to "
[email protected]"