1
linux/arch/mips
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
..
arc
au1000 [MIPS] IRQ cleanups 2006-11-30 01:14:46 +00:00
basler/excite [MIPS] Complete fixes after removal of pt_regs argument to int handlers. 2006-10-08 02:38:28 +01:00
boot
cobalt [MIPS] Rewrite GALILEO_INL/GALILEO_OUTL to GT_READ/GT_WRITE 2006-11-30 01:14:43 +00:00
configs [MIPS] Update tb0287_defconfig 2006-10-19 17:55:14 +01:00
ddb5xxx [MIPS] IRQ cleanups 2006-11-30 01:14:46 +00:00
dec [MIPS] *-berr: Header inclusions for DEC bus error handlers 2006-12-06 20:16:09 +00:00
emma2rh [MIPS] Compile __do_IRQ() when really needed 2006-12-06 20:16:08 +00:00
gt64120 [MIPS] IRQ cleanups 2006-11-30 01:14:46 +00:00
jazz [MIPS] Compile __do_IRQ() when really needed 2006-12-06 20:16:08 +00:00
jmr3927 [MIPS] mips HPT cleanup: make clocksource_mips public 2006-11-30 01:14:49 +00:00
kernel [PATCH] struct path: convert mips 2006-12-08 08:28:47 -08:00
lasat [PATCH] struct path: convert mips 2006-12-08 08:28:47 -08:00
lib [MIPS] Unify csum_partial.S 2006-12-04 22:43:13 +00:00
lib-32 [MIPS] Unify csum_partial.S 2006-12-04 22:43:13 +00:00
lib-64 [MIPS] Unify csum_partial.S 2006-12-04 22:43:13 +00:00
math-emu [MIPS] Make sure cpu_has_fpu is used only in atomic context 2006-10-09 23:20:48 +01:00
mips-boards [MIPS] Fix double inclusions 2006-11-30 01:14:47 +00:00
mm [PATCH] Pass struct dev pointer to dma_cache_sync() 2006-12-07 08:39:41 -08:00
momentum [MIPS] Compile __do_IRQ() when really needed 2006-12-06 20:16:08 +00:00
oprofile [MIPS] Oprofile: kernel support for the R10000. 2006-11-30 01:14:45 +00:00
pci [MIPS] Rewrite GALILEO_INL/GALILEO_OUTL to GT_READ/GT_WRITE 2006-11-30 01:14:43 +00:00
philips/pnx8550 [MIPS] Compile __do_IRQ() when really needed 2006-12-06 20:16:08 +00:00
pmc-sierra [MIPS] mips hpt cleanup: get rid of mips_hpt_init 2006-11-30 01:14:46 +00:00
qemu [MIPS] Complete fixes after removal of pt_regs argument to int handlers. 2006-10-08 02:38:28 +01:00
sgi-ip22 [MIPS] Compile __do_IRQ() when really needed 2006-12-06 20:16:08 +00:00
sgi-ip27 [MIPS] Compile __do_IRQ() when really needed 2006-12-06 20:16:08 +00:00
sgi-ip32 [MIPS] IRQ cleanups 2006-11-30 01:14:46 +00:00
sibyte [MIPS] SWARM: Fix a typo in #error directives 2006-12-04 22:43:13 +00:00
sni [MIPS] IRQ cleanups 2006-11-30 01:14:46 +00:00
tx4927 [MIPS] Compile __do_IRQ() when really needed 2006-12-06 20:16:08 +00:00
tx4938 [MIPS] Compile __do_IRQ() when really needed 2006-12-06 20:16:08 +00:00
vr41xx [MIPS] Compile __do_IRQ() when really needed 2006-12-06 20:16:08 +00:00
defconfig [MIPS] lockdep: update defconfigs 2006-10-01 23:16:57 +01:00
Kconfig [PATCH] LOG2: Implement a general integer log2 facility in the kernel 2006-12-08 08:28:51 -08:00
Kconfig.debug
Makefile [MIPS] Load modules to CKSEG0 if CONFIG_BUILD_ELF64=n 2006-11-30 01:14:44 +00:00