aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2006-12-08 05:37:49 -0500
committerLinus Torvalds <torvalds@woody.osdl.org>2006-12-08 11:28:51 -0500
commitf0d1b0b30d250a07627ad8b9fbbb5c7cc08422e8 (patch)
tree0aa5379150574374351fb92af7881a48dbfcf2ce /arch
parentb3d7ae5f47a58a9f7b152deeaf7daa1fc558a8f1 (diff)
[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>
Diffstat (limited to 'arch')
-rw-r--r--arch/alpha/Kconfig8
-rw-r--r--arch/arm/Kconfig8
-rw-r--r--arch/arm26/Kconfig8
-rw-r--r--arch/avr32/Kconfig8
-rw-r--r--arch/cris/Kconfig8
-rw-r--r--arch/frv/Kconfig8
-rw-r--r--arch/h8300/Kconfig8
-rw-r--r--arch/i386/Kconfig.cpu8
-rw-r--r--arch/ia64/Kconfig8
-rw-r--r--arch/m32r/Kconfig8
-rw-r--r--arch/m68k/Kconfig8
-rw-r--r--arch/m68knommu/Kconfig8
-rw-r--r--arch/mips/Kconfig8
-rw-r--r--arch/parisc/Kconfig8
-rw-r--r--arch/powerpc/Kconfig8
-rw-r--r--arch/ppc/Kconfig8
-rw-r--r--arch/s390/Kconfig8
-rw-r--r--arch/sh/Kconfig8
-rw-r--r--arch/sh64/Kconfig8
-rw-r--r--arch/sparc/Kconfig8
-rw-r--r--arch/sparc64/Kconfig8
-rw-r--r--arch/v850/Kconfig8
-rw-r--r--arch/x86_64/Kconfig8
-rw-r--r--arch/xtensa/Kconfig8
24 files changed, 192 insertions, 0 deletions
diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig
index 7e55ea66c6d..84caf50725b 100644
--- a/arch/alpha/Kconfig
+++ b/arch/alpha/Kconfig
@@ -25,6 +25,14 @@ config RWSEM_XCHGADD_ALGORITHM
25 bool 25 bool
26 default y 26 default y
27 27
28config ARCH_HAS_ILOG2_U32
29 bool
30 default n
31
32config ARCH_HAS_ILOG2_U64
33 bool
34 default n
35
28config GENERIC_FIND_NEXT_BIT 36config GENERIC_FIND_NEXT_BIT
29 bool 37 bool
30 default y 38 default y
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 8c05d4321ae..aa1d400d721 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -74,6 +74,14 @@ config RWSEM_GENERIC_SPINLOCK
74config RWSEM_XCHGADD_ALGORITHM 74config RWSEM_XCHGADD_ALGORITHM
75 bool 75 bool
76 76
77config ARCH_HAS_ILOG2_U32
78 bool
79 default n
80
81config ARCH_HAS_ILOG2_U64
82 bool
83 default n
84
77config GENERIC_HWEIGHT 85config GENERIC_HWEIGHT
78 bool 86 bool
79 default y 87 default y
diff --git a/arch/arm26/Kconfig b/arch/arm26/Kconfig
index c14fe918bc4..74eba8b5a8c 100644
--- a/arch/arm26/Kconfig
+++ b/arch/arm26/Kconfig
@@ -41,6 +41,14 @@ config RWSEM_GENERIC_SPINLOCK
41config RWSEM_XCHGADD_ALGORITHM 41config RWSEM_XCHGADD_ALGORITHM
42 bool 42 bool
43 43
44config ARCH_HAS_ILOG2_U32
45 bool
46 default n
47
48config ARCH_HAS_ILOG2_U64
49 bool
50 default n
51
44config GENERIC_HWEIGHT 52config GENERIC_HWEIGHT
45 bool 53 bool
46 default y 54 default y
diff --git a/arch/avr32/Kconfig b/arch/avr32/Kconfig
index 5f1694eea84..bb059a4e1df 100644
--- a/arch/avr32/Kconfig
+++ b/arch/avr32/Kconfig
@@ -45,6 +45,14 @@ config GENERIC_TIME
45config RWSEM_XCHGADD_ALGORITHM 45config RWSEM_XCHGADD_ALGORITHM
46 bool 46 bool
47 47
48config ARCH_HAS_ILOG2_U32
49 bool
50 default n
51
52config ARCH_HAS_ILOG2_U64
53 bool
54 default n
55
48config GENERIC_BUST_SPINLOCK 56config GENERIC_BUST_SPINLOCK
49 bool 57 bool
50 58
diff --git a/arch/cris/Kconfig b/arch/cris/Kconfig
index 6a1238a29d6..3474309e049 100644
--- a/arch/cris/Kconfig
+++ b/arch/cris/Kconfig
@@ -16,6 +16,14 @@ config RWSEM_GENERIC_SPINLOCK
16config RWSEM_XCHGADD_ALGORITHM 16config RWSEM_XCHGADD_ALGORITHM
17 bool 17 bool
18 18
19config ARCH_HAS_ILOG2_U32
20 bool
21 default n
22
23config ARCH_HAS_ILOG2_U64
24 bool
25 default n
26
19config GENERIC_FIND_NEXT_BIT 27config GENERIC_FIND_NEXT_BIT
20 bool 28 bool
21 default y 29 default y
diff --git a/arch/frv/Kconfig b/arch/frv/Kconfig
index cf1c446e003..7561d7b72e7 100644
--- a/arch/frv/Kconfig
+++ b/arch/frv/Kconfig
@@ -41,6 +41,14 @@ config TIME_LOW_RES
41 bool 41 bool
42 default y 42 default y
43 43
44config ARCH_HAS_ILOG2_U32
45 bool
46 default y
47
48config ARCH_HAS_ILOG2_U64
49 bool
50 default y
51
44mainmenu "Fujitsu FR-V Kernel Configuration" 52mainmenu "Fujitsu FR-V Kernel Configuration"
45 53
46source "init/Kconfig" 54source "init/Kconfig"
diff --git a/arch/h8300/Kconfig b/arch/h8300/Kconfig
index cabf0bfffc5..34a84bc4baf 100644
--- a/arch/h8300/Kconfig
+++ b/arch/h8300/Kconfig
@@ -29,6 +29,14 @@ config RWSEM_XCHGADD_ALGORITHM
29 bool 29 bool
30 default n 30 default n
31 31
32config ARCH_HAS_ILOG2_U32
33 bool
34 default n
35
36config ARCH_HAS_ILOG2_U64
37 bool
38 default n
39
32config GENERIC_FIND_NEXT_BIT 40config GENERIC_FIND_NEXT_BIT
33 bool 41 bool
34 default y 42 default y
diff --git a/arch/i386/Kconfig.cpu b/arch/i386/Kconfig.cpu
index 821fd269ca5..2aecfba4ac4 100644
--- a/arch/i386/Kconfig.cpu
+++ b/arch/i386/Kconfig.cpu
@@ -248,6 +248,14 @@ config RWSEM_XCHGADD_ALGORITHM
248 depends on !M386 248 depends on !M386
249 default y 249 default y
250 250
251config ARCH_HAS_ILOG2_U32
252 bool
253 default n
254
255config ARCH_HAS_ILOG2_U64
256 bool
257 default n
258
251config GENERIC_CALIBRATE_DELAY 259config GENERIC_CALIBRATE_DELAY
252 bool 260 bool
253 default y 261 default y
diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
index 75d839715b2..fcacfe291b9 100644
--- a/arch/ia64/Kconfig
+++ b/arch/ia64/Kconfig
@@ -34,6 +34,14 @@ config RWSEM_XCHGADD_ALGORITHM
34 bool 34 bool
35 default y 35 default y
36 36
37config ARCH_HAS_ILOG2_U32
38 bool
39 default n
40
41config ARCH_HAS_ILOG2_U64
42 bool
43 default n
44
37config GENERIC_FIND_NEXT_BIT 45config GENERIC_FIND_NEXT_BIT
38 bool 46 bool
39 default y 47 default y
diff --git a/arch/m32r/Kconfig b/arch/m32r/Kconfig
index 41fd490af3b..f383dab973f 100644
--- a/arch/m32r/Kconfig
+++ b/arch/m32r/Kconfig
@@ -214,6 +214,14 @@ config RWSEM_XCHGADD_ALGORITHM
214 bool 214 bool
215 default n 215 default n
216 216
217config ARCH_HAS_ILOG2_U32
218 bool
219 default n
220
221config ARCH_HAS_ILOG2_U64
222 bool
223 default n
224
217config GENERIC_FIND_NEXT_BIT 225config GENERIC_FIND_NEXT_BIT
218 bool 226 bool
219 default y 227 default y
diff --git a/arch/m68k/Kconfig b/arch/m68k/Kconfig
index 7bc14461a6a..70a577c89c7 100644
--- a/arch/m68k/Kconfig
+++ b/arch/m68k/Kconfig
@@ -17,6 +17,14 @@ config RWSEM_GENERIC_SPINLOCK
17config RWSEM_XCHGADD_ALGORITHM 17config RWSEM_XCHGADD_ALGORITHM
18 bool 18 bool
19 19
20config ARCH_HAS_ILOG2_U32
21 bool
22 default n
23
24config ARCH_HAS_ILOG2_U64
25 bool
26 default n
27
20config GENERIC_HWEIGHT 28config GENERIC_HWEIGHT
21 bool 29 bool
22 default y 30 default y
diff --git a/arch/m68knommu/Kconfig b/arch/m68knommu/Kconfig
index aa70dde5422..25993c2a8fb 100644
--- a/arch/m68knommu/Kconfig
+++ b/arch/m68knommu/Kconfig
@@ -25,6 +25,14 @@ config RWSEM_XCHGADD_ALGORITHM
25 bool 25 bool
26 default n 26 default n
27 27
28config ARCH_HAS_ILOG2_U32
29 bool
30 default n
31
32config ARCH_HAS_ILOG2_U64
33 bool
34 default n
35
28config GENERIC_FIND_NEXT_BIT 36config GENERIC_FIND_NEXT_BIT
29 bool 37 bool
30 default y 38 default y
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index d8af858fe3f..57af8d8cf46 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -819,6 +819,14 @@ config RWSEM_GENERIC_SPINLOCK
819config RWSEM_XCHGADD_ALGORITHM 819config RWSEM_XCHGADD_ALGORITHM
820 bool 820 bool
821 821
822config ARCH_HAS_ILOG2_U32
823 bool
824 default n
825
826config ARCH_HAS_ILOG2_U64
827 bool
828 default n
829
822config GENERIC_FIND_NEXT_BIT 830config GENERIC_FIND_NEXT_BIT
823 bool 831 bool
824 default y 832 default y
diff --git a/arch/parisc/Kconfig b/arch/parisc/Kconfig
index d2101237442..0f9ff618c6d 100644
--- a/arch/parisc/Kconfig
+++ b/arch/parisc/Kconfig
@@ -25,6 +25,14 @@ config RWSEM_GENERIC_SPINLOCK
25config RWSEM_XCHGADD_ALGORITHM 25config RWSEM_XCHGADD_ALGORITHM
26 bool 26 bool
27 27
28config ARCH_HAS_ILOG2_U32
29 bool
30 default n
31
32config ARCH_HAS_ILOG2_U64
33 bool
34 default n
35
28config GENERIC_FIND_NEXT_BIT 36config GENERIC_FIND_NEXT_BIT
29 bool 37 bool
30 default y 38 default y
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index 291c95ac4b3..97c7a212cdd 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -41,6 +41,14 @@ config RWSEM_XCHGADD_ALGORITHM
41 bool 41 bool
42 default y 42 default y
43 43
44config ARCH_HAS_ILOG2_U32
45 bool
46 default n
47
48config ARCH_HAS_ILOG2_U64
49 bool
50 default n
51
44config GENERIC_HWEIGHT 52config GENERIC_HWEIGHT
45 bool 53 bool
46 default y 54 default y
diff --git a/arch/ppc/Kconfig b/arch/ppc/Kconfig
index f76a146cff1..692b5ba5320 100644
--- a/arch/ppc/Kconfig
+++ b/arch/ppc/Kconfig
@@ -19,6 +19,14 @@ config RWSEM_XCHGADD_ALGORITHM
19 bool 19 bool
20 default y 20 default y
21 21
22config ARCH_HAS_ILOG2_U32
23 bool
24 default y
25
26config ARCH_HAS_ILOG2_U64
27 bool
28 default n
29
22config GENERIC_HWEIGHT 30config GENERIC_HWEIGHT
23 bool 31 bool
24 default y 32 default y
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index 583d9ff0a57..45e47bfb68a 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -22,6 +22,14 @@ config RWSEM_XCHGADD_ALGORITHM
22 bool 22 bool
23 default y 23 default y
24 24
25config ARCH_HAS_ILOG2_U32
26 bool
27 default n
28
29config ARCH_HAS_ILOG2_U64
30 bool
31 default n
32
25config GENERIC_HWEIGHT 33config GENERIC_HWEIGHT
26 bool 34 bool
27 default y 35 default y
diff --git a/arch/sh/Kconfig b/arch/sh/Kconfig
index d83d64af31f..8e24c40662e 100644
--- a/arch/sh/Kconfig
+++ b/arch/sh/Kconfig
@@ -59,6 +59,14 @@ config LOCKDEP_SUPPORT
59 bool 59 bool
60 default y 60 default y
61 61
62config ARCH_HAS_ILOG2_U32
63 bool
64 default n
65
66config ARCH_HAS_ILOG2_U64
67 bool
68 default n
69
62source "init/Kconfig" 70source "init/Kconfig"
63 71
64menu "System type" 72menu "System type"
diff --git a/arch/sh64/Kconfig b/arch/sh64/Kconfig
index 58c678e0666..7bc0744b7ab 100644
--- a/arch/sh64/Kconfig
+++ b/arch/sh64/Kconfig
@@ -39,6 +39,14 @@ config RWSEM_XCHGADD_ALGORITHM
39config GENERIC_ISA_DMA 39config GENERIC_ISA_DMA
40 bool 40 bool
41 41
42config ARCH_HAS_ILOG2_U32
43 bool
44 default n
45
46config ARCH_HAS_ILOG2_U64
47 bool
48 default n
49
42source init/Kconfig 50source init/Kconfig
43 51
44menu "System type" 52menu "System type"
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index 92a7c8a636d..d0dec1ea2ee 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -166,6 +166,14 @@ config ARCH_MAY_HAVE_PC_FDC
166 bool 166 bool
167 default y 167 default y
168 168
169config ARCH_HAS_ILOG2_U32
170 bool
171 default n
172
173config ARCH_HAS_ILOG2_U64
174 bool
175 default n
176
169config SUN_PM 177config SUN_PM
170 bool 178 bool
171 default y 179 default y
diff --git a/arch/sparc64/Kconfig b/arch/sparc64/Kconfig
index b627f8dbcaa..d391d11f245 100644
--- a/arch/sparc64/Kconfig
+++ b/arch/sparc64/Kconfig
@@ -34,6 +34,14 @@ config ARCH_MAY_HAVE_PC_FDC
34 bool 34 bool
35 default y 35 default y
36 36
37config ARCH_HAS_ILOG2_U32
38 bool
39 default n
40
41config ARCH_HAS_ILOG2_U64
42 bool
43 default n
44
37config AUDIT_ARCH 45config AUDIT_ARCH
38 bool 46 bool
39 default y 47 default y
diff --git a/arch/v850/Kconfig b/arch/v850/Kconfig
index 37ec644603a..bcf825875d1 100644
--- a/arch/v850/Kconfig
+++ b/arch/v850/Kconfig
@@ -38,6 +38,14 @@ config TIME_LOW_RES
38 bool 38 bool
39 default y 39 default y
40 40
41config ARCH_HAS_ILOG2_U32
42 bool
43 default n
44
45config ARCH_HAS_ILOG2_U64
46 bool
47 default n
48
41# Turn off some random 386 crap that can affect device config 49# Turn off some random 386 crap that can affect device config
42config ISA 50config ISA
43 bool 51 bool
diff --git a/arch/x86_64/Kconfig b/arch/x86_64/Kconfig
index 3254a616c69..3ac581d1720 100644
--- a/arch/x86_64/Kconfig
+++ b/arch/x86_64/Kconfig
@@ -101,6 +101,14 @@ config GENERIC_BUG
101 default y 101 default y
102 depends on BUG 102 depends on BUG
103 103
104config ARCH_HAS_ILOG2_U32
105 bool
106 default n
107
108config ARCH_HAS_ILOG2_U64
109 bool
110 default n
111
104source "init/Kconfig" 112source "init/Kconfig"
105 113
106 114
diff --git a/arch/xtensa/Kconfig b/arch/xtensa/Kconfig
index c1e69a1f92a..9eccfbd1b53 100644
--- a/arch/xtensa/Kconfig
+++ b/arch/xtensa/Kconfig
@@ -34,6 +34,14 @@ config GENERIC_HARDIRQS
34 bool 34 bool
35 default y 35 default y
36 36
37config ARCH_HAS_ILOG2_U32
38 bool
39 default n
40
41config ARCH_HAS_ILOG2_U64
42 bool
43 default n
44
37source "init/Kconfig" 45source "init/Kconfig"
38 46
39menu "Processor type and features" 47menu "Processor type and features"