OpenCloudOS-Kernel/include
David Howells f0d1b0b30d [PATCH] LOG2: Implement a general integer log2 facility in the kernel
This facility provides three entry points:

	ilog2()		Log base 2 of unsigned long
	ilog2_u32()	Log base 2 of u32
	ilog2_u64()	Log base 2 of u64

These facilities can either be used inside functions on dynamic data:

	int do_something(long q)
	{
		...;
		y = ilog2(x)
		...;
	}

Or can be used to statically initialise global variables with constant values:

	unsigned n = ilog2(27);

When performing static initialisation, the compiler will report "error:
initializer element is not constant" if asked to take a log of zero or of
something not reducible to a constant.  They treat negative numbers as
unsigned.

When not dealing with a constant, they fall back to using fls() which permits
them to use arch-specific log calculation instructions - such as BSR on
x86/x86_64 or SCAN on FRV - if available.

[akpm@osdl.org: MMC fix]
Signed-off-by: David Howells <dhowells@redhat.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Herbert Xu <herbert@gondor.apana.org.au>
Cc: David Howells <dhowells@redhat.com>
Cc: Wojtek Kaniewski <wojtekka@toxygen.net>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-12-08 08:28:51 -08:00
..
acpi [PATCH] slab: remove kmem_cache_t 2006-12-07 08:39:25 -08:00
asm-alpha [PATCH] Pass struct dev pointer to dma_cache_sync() 2006-12-07 08:39:41 -08:00
asm-arm Merge branch 'for-linus' of master.kernel.org:/home/rmk/linux-2.6-arm 2006-12-07 15:40:39 -08:00
asm-arm26 [PATCH] cleanup asm/setup.h userspace visibility 2006-12-07 08:39:46 -08:00
asm-avr32 Merge branch 'for-linus' of master.kernel.org:/home/rmk/linux-2.6-arm 2006-12-07 15:40:39 -08:00
asm-cris [PATCH] include/asm-cris/: "extern inline" -> "static inline" 2006-12-07 08:39:45 -08:00
asm-frv [PATCH] LOG2: Implement a general integer log2 facility in the kernel 2006-12-08 08:28:51 -08:00
asm-generic [PATCH] Fix generic WARN_ON message 2006-12-08 08:28:39 -08:00
asm-h8300 [PATCH] include/asm-h8300/: "extern inline" -> "static inline" 2006-12-07 08:39:45 -08:00
asm-i386 [PATCH] Generic BUG for i386 2006-12-08 08:28:39 -08:00
asm-ia64 Merge branch 'release' of master.kernel.org:/pub/scm/linux/kernel/git/aegl/linux-2.6 2006-12-07 15:39:22 -08:00
asm-m32r [PATCH] m32r: bootloader support for OPSPUT platform 2006-12-08 08:28:37 -08:00
asm-m68k [PATCH] cleanup asm/setup.h userspace visibility 2006-12-07 08:39:46 -08:00
asm-m68knommu [PATCH] cleanup asm/setup.h userspace visibility 2006-12-07 08:39:46 -08:00
asm-mips [PATCH] cleanup asm/setup.h userspace visibility 2006-12-07 08:39:46 -08:00
asm-parisc [PATCH] Pass struct dev pointer to dma_cache_sync() 2006-12-07 08:39:41 -08:00
asm-powerpc [PATCH] cleanup asm/setup.h userspace visibility 2006-12-07 08:39:46 -08:00
asm-ppc [PATCH] mm: pagefault_{disable,enable}() 2006-12-07 08:39:21 -08:00
asm-s390 [PATCH] cleanup asm/setup.h userspace visibility 2006-12-07 08:39:46 -08:00
asm-sh [PATCH] cleanup asm/setup.h userspace visibility 2006-12-07 08:39:46 -08:00
asm-sh64 [PATCH] cleanup asm/setup.h userspace visibility 2006-12-07 08:39:46 -08:00
asm-sparc [PATCH] remove kernel syscalls 2006-12-07 08:39:37 -08:00
asm-sparc64 [PATCH] Pass struct dev pointer to dma_cache_sync() 2006-12-07 08:39:41 -08:00
asm-um [PATCH] UML: add generic BUG support 2006-12-08 08:28:39 -08:00
asm-v850 [PATCH] remove kernel syscalls 2006-12-07 08:39:37 -08:00
asm-x86_64 [PATCH] Generic BUG for x86-64 2006-12-08 08:28:39 -08:00
asm-xtensa [PATCH] Pass struct dev pointer to dma_cache_sync() 2006-12-07 08:39:41 -08:00
crypto [CRYPTO] lib: table driven multiplications in GF(2^128) 2006-12-06 18:38:55 -08:00
keys
linux [PATCH] LOG2: Implement a general integer log2 facility in the kernel 2006-12-08 08:28:51 -08:00
math-emu
media V4L/DVB (4666): Ensure the WM8775 driver is loaded generically for any board. 2006-10-03 15:13:48 -03:00
mtd Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6 2006-10-01 17:55:53 +01:00
net Merge master.kernel.org:/pub/scm/linux/kernel/git/davem/net-2.6 2006-12-07 09:05:15 -08:00
pcmcia [PATCH] pcmcia: multifunction card handling fixes 2006-12-04 20:09:15 -05:00
rdma IB/cm: Fix automatic path migration support 2006-11-29 15:33:10 -08:00
rxrpc
scsi [PATCH] slab: remove kmem_cache_t 2006-12-07 08:39:25 -08:00
sound Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6 2006-12-05 17:01:28 +00:00
video fix file specification in comments 2006-10-03 23:01:26 +02:00
Kbuild [HEADERS] One line per header in Kbuild files to reduce conflicts 2006-09-19 12:43:58 +01:00