Re: Log2 all through the kernel?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Erik Mouw wrote:

On Wed, Aug 10, 2005 at 05:54:44PM +0200, Oliver Korpilla wrote:

Wouldn't it be more sensible to supply one portable one, with bit
shifts, and people with a need for O(1) timing could implement it using
an array?


Send a patch to the linux-kernel mailing list and see what happens.

Sticking a few defines in a header somewhere should do, I believe:

#define floor_log2(x) (fls(x) - 1)
#define ceil_log2(x) (fls((x) - 1)

fls() is both defined in the kernel and a gcc builtin.

Rene.

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux