diff options
author | Chris Metcalf <cmetcalf@ezchip.com> | 2015-04-29 12:48:40 -0400 |
---|---|---|
committer | Chris Metcalf <cmetcalf@ezchip.com> | 2015-07-08 16:41:55 -0400 |
commit | a6e2f029ae34f41adb6ae3812c32c5d326e1abd2 (patch) | |
tree | 17a28881ffaf9b613eb1df580ab6ba6e90cac3bd | |
parent | d770e558e21961ad6cfdf0ff7df0eb5d7d4f0754 (diff) |
Make asm/word-at-a-time.h available on all architectures
Added the x86 implementation of word-at-a-time to the
generic version, which previously only supported big-endian.
Omitted the x86-specific load_unaligned_zeropad(), which in
any case is also not present for the existing BE-only
implementation of a word-at-a-time, and is only used under
CONFIG_DCACHE_WORD_ACCESS.
Added as a "generic-y" to the Kbuilds of all architectures
that didn't previously have it.
Signed-off-by: Chris Metcalf <cmetcalf@ezchip.com>
-rw-r--r-- | arch/arc/include/asm/Kbuild | 1 | ||||
-rw-r--r-- | arch/avr32/include/asm/Kbuild | 1 | ||||
-rw-r--r-- | arch/blackfin/include/asm/Kbuild | 1 | ||||
-rw-r--r-- | arch/c6x/include/asm/Kbuild | 1 | ||||
-rw-r--r-- | arch/cris/include/asm/Kbuild | 1 | ||||
-rw-r--r-- | arch/frv/include/asm/Kbuild | 1 | ||||
-rw-r--r-- | arch/hexagon/include/asm/Kbuild | 1 | ||||
-rw-r--r-- | arch/ia64/include/asm/Kbuild | 1 | ||||
-rw-r--r-- | arch/m32r/include/asm/Kbuild | 1 | ||||
-rw-r--r-- | arch/metag/include/asm/Kbuild | 1 | ||||
-rw-r--r-- | arch/microblaze/include/asm/Kbuild | 1 | ||||
-rw-r--r-- | arch/mips/include/asm/Kbuild | 1 | ||||
-rw-r--r-- | arch/mn10300/include/asm/Kbuild | 1 | ||||
-rw-r--r-- | arch/nios2/include/asm/Kbuild | 1 | ||||
-rw-r--r-- | arch/powerpc/include/asm/Kbuild | 1 | ||||
-rw-r--r-- | arch/s390/include/asm/Kbuild | 1 | ||||
-rw-r--r-- | arch/score/include/asm/Kbuild | 1 | ||||
-rw-r--r-- | arch/tile/include/asm/Kbuild | 1 | ||||
-rw-r--r-- | arch/um/include/asm/Kbuild | 1 | ||||
-rw-r--r-- | arch/unicore32/include/asm/Kbuild | 1 | ||||
-rw-r--r-- | arch/xtensa/include/asm/Kbuild | 1 | ||||
-rw-r--r-- | include/asm-generic/word-at-a-time.h | 80 |
22 files changed, 93 insertions, 8 deletions
diff --git a/arch/arc/include/asm/Kbuild b/arch/arc/include/asm/Kbuild index 1a80cc91a03b..c8f07ce1c757 100644 --- a/arch/arc/include/asm/Kbuild +++ b/arch/arc/include/asm/Kbuild | |||
@@ -47,4 +47,5 @@ generic-y += types.h | |||
47 | generic-y += ucontext.h | 47 | generic-y += ucontext.h |
48 | generic-y += user.h | 48 | generic-y += user.h |
49 | generic-y += vga.h | 49 | generic-y += vga.h |
50 | generic-y += word-at-a-time.h | ||
50 | generic-y += xor.h | 51 | generic-y += xor.h |
diff --git a/arch/avr32/include/asm/Kbuild b/arch/avr32/include/asm/Kbuild index 1d66afdfac07..519810d0d5e1 100644 --- a/arch/avr32/include/asm/Kbuild +++ b/arch/avr32/include/asm/Kbuild | |||
@@ -19,4 +19,5 @@ generic-y += sections.h | |||
19 | generic-y += topology.h | 19 | generic-y += topology.h |
20 | generic-y += trace_clock.h | 20 | generic-y += trace_clock.h |
21 | generic-y += vga.h | 21 | generic-y += vga.h |
22 | generic-y += word-at-a-time.h | ||
22 | generic-y += xor.h | 23 | generic-y += xor.h |
diff --git a/arch/blackfin/include/asm/Kbuild b/arch/blackfin/include/asm/Kbuild index 07051a63415d..c80181e4454f 100644 --- a/arch/blackfin/include/asm/Kbuild +++ b/arch/blackfin/include/asm/Kbuild | |||
@@ -45,4 +45,5 @@ generic-y += types.h | |||
45 | generic-y += ucontext.h | 45 | generic-y += ucontext.h |
46 | generic-y += unaligned.h | 46 | generic-y += unaligned.h |
47 | generic-y += user.h | 47 | generic-y += user.h |
48 | generic-y += word-at-a-time.h | ||
48 | generic-y += xor.h | 49 | generic-y += xor.h |
diff --git a/arch/c6x/include/asm/Kbuild b/arch/c6x/include/asm/Kbuild index 7aeb32272975..2f697020a8fd 100644 --- a/arch/c6x/include/asm/Kbuild +++ b/arch/c6x/include/asm/Kbuild | |||
@@ -58,4 +58,5 @@ generic-y += types.h | |||
58 | generic-y += ucontext.h | 58 | generic-y += ucontext.h |
59 | generic-y += user.h | 59 | generic-y += user.h |
60 | generic-y += vga.h | 60 | generic-y += vga.h |
61 | generic-y += word-at-a-time.h | ||
61 | generic-y += xor.h | 62 | generic-y += xor.h |
diff --git a/arch/cris/include/asm/Kbuild b/arch/cris/include/asm/Kbuild index d294f6aaff1d..09916c8073ac 100644 --- a/arch/cris/include/asm/Kbuild +++ b/arch/cris/include/asm/Kbuild | |||
@@ -25,4 +25,5 @@ generic-y += sections.h | |||
25 | generic-y += topology.h | 25 | generic-y += topology.h |
26 | generic-y += trace_clock.h | 26 | generic-y += trace_clock.h |
27 | generic-y += vga.h | 27 | generic-y += vga.h |
28 | generic-y += word-at-a-time.h | ||
28 | generic-y += xor.h | 29 | generic-y += xor.h |
diff --git a/arch/frv/include/asm/Kbuild b/arch/frv/include/asm/Kbuild index 30edce31e5c2..2c987dc05af4 100644 --- a/arch/frv/include/asm/Kbuild +++ b/arch/frv/include/asm/Kbuild | |||
@@ -6,3 +6,4 @@ generic-y += irq_work.h | |||
6 | generic-y += mcs_spinlock.h | 6 | generic-y += mcs_spinlock.h |
7 | generic-y += preempt.h | 7 | generic-y += preempt.h |
8 | generic-y += trace_clock.h | 8 | generic-y += trace_clock.h |
9 | generic-y += word-at-a-time.h | ||
diff --git a/arch/hexagon/include/asm/Kbuild b/arch/hexagon/include/asm/Kbuild index 5ade4a163558..0988816dded0 100644 --- a/arch/hexagon/include/asm/Kbuild +++ b/arch/hexagon/include/asm/Kbuild | |||
@@ -57,4 +57,5 @@ generic-y += types.h | |||
57 | generic-y += ucontext.h | 57 | generic-y += ucontext.h |
58 | generic-y += unaligned.h | 58 | generic-y += unaligned.h |
59 | generic-y += vga.h | 59 | generic-y += vga.h |
60 | generic-y += word-at-a-time.h | ||
60 | generic-y += xor.h | 61 | generic-y += xor.h |
diff --git a/arch/ia64/include/asm/Kbuild b/arch/ia64/include/asm/Kbuild index ccff13d33fa2..dc05773e1f11 100644 --- a/arch/ia64/include/asm/Kbuild +++ b/arch/ia64/include/asm/Kbuild | |||
@@ -7,3 +7,4 @@ generic-y += mcs_spinlock.h | |||
7 | generic-y += preempt.h | 7 | generic-y += preempt.h |
8 | generic-y += trace_clock.h | 8 | generic-y += trace_clock.h |
9 | generic-y += vtime.h | 9 | generic-y += vtime.h |
10 | generic-y += word-at-a-time.h | ||
diff --git a/arch/m32r/include/asm/Kbuild b/arch/m32r/include/asm/Kbuild index ba1cdc018731..219e54b33685 100644 --- a/arch/m32r/include/asm/Kbuild +++ b/arch/m32r/include/asm/Kbuild | |||
@@ -8,3 +8,4 @@ generic-y += module.h | |||
8 | generic-y += preempt.h | 8 | generic-y += preempt.h |
9 | generic-y += sections.h | 9 | generic-y += sections.h |
10 | generic-y += trace_clock.h | 10 | generic-y += trace_clock.h |
11 | generic-y += word-at-a-time.h | ||
diff --git a/arch/metag/include/asm/Kbuild b/arch/metag/include/asm/Kbuild index 199320f3c345..611c0df2be39 100644 --- a/arch/metag/include/asm/Kbuild +++ b/arch/metag/include/asm/Kbuild | |||
@@ -53,4 +53,5 @@ generic-y += ucontext.h | |||
53 | generic-y += unaligned.h | 53 | generic-y += unaligned.h |
54 | generic-y += user.h | 54 | generic-y += user.h |
55 | generic-y += vga.h | 55 | generic-y += vga.h |
56 | generic-y += word-at-a-time.h | ||
56 | generic-y += xor.h | 57 | generic-y += xor.h |
diff --git a/arch/microblaze/include/asm/Kbuild b/arch/microblaze/include/asm/Kbuild index 9989ddb169ca..cefeabae24cc 100644 --- a/arch/microblaze/include/asm/Kbuild +++ b/arch/microblaze/include/asm/Kbuild | |||
@@ -9,3 +9,4 @@ generic-y += mcs_spinlock.h | |||
9 | generic-y += preempt.h | 9 | generic-y += preempt.h |
10 | generic-y += syscalls.h | 10 | generic-y += syscalls.h |
11 | generic-y += trace_clock.h | 11 | generic-y += trace_clock.h |
12 | generic-y += word-at-a-time.h | ||
diff --git a/arch/mips/include/asm/Kbuild b/arch/mips/include/asm/Kbuild index 7fe5c61a3cb8..dee810fa973e 100644 --- a/arch/mips/include/asm/Kbuild +++ b/arch/mips/include/asm/Kbuild | |||
@@ -17,4 +17,5 @@ generic-y += serial.h | |||
17 | generic-y += trace_clock.h | 17 | generic-y += trace_clock.h |
18 | generic-y += ucontext.h | 18 | generic-y += ucontext.h |
19 | generic-y += user.h | 19 | generic-y += user.h |
20 | generic-y += word-at-a-time.h | ||
20 | generic-y += xor.h | 21 | generic-y += xor.h |
diff --git a/arch/mn10300/include/asm/Kbuild b/arch/mn10300/include/asm/Kbuild index de30b0c88796..27cbc0267b9c 100644 --- a/arch/mn10300/include/asm/Kbuild +++ b/arch/mn10300/include/asm/Kbuild | |||
@@ -8,3 +8,4 @@ generic-y += mcs_spinlock.h | |||
8 | generic-y += preempt.h | 8 | generic-y += preempt.h |
9 | generic-y += sections.h | 9 | generic-y += sections.h |
10 | generic-y += trace_clock.h | 10 | generic-y += trace_clock.h |
11 | generic-y += word-at-a-time.h | ||
diff --git a/arch/nios2/include/asm/Kbuild b/arch/nios2/include/asm/Kbuild index 434639d510b3..e22478929719 100644 --- a/arch/nios2/include/asm/Kbuild +++ b/arch/nios2/include/asm/Kbuild | |||
@@ -60,4 +60,5 @@ generic-y += types.h | |||
60 | generic-y += unaligned.h | 60 | generic-y += unaligned.h |
61 | generic-y += user.h | 61 | generic-y += user.h |
62 | generic-y += vga.h | 62 | generic-y += vga.h |
63 | generic-y += word-at-a-time.h | ||
63 | generic-y += xor.h | 64 | generic-y += xor.h |
diff --git a/arch/powerpc/include/asm/Kbuild b/arch/powerpc/include/asm/Kbuild index 050712e1ce41..d9c0b44191b0 100644 --- a/arch/powerpc/include/asm/Kbuild +++ b/arch/powerpc/include/asm/Kbuild | |||
@@ -8,3 +8,4 @@ generic-y += preempt.h | |||
8 | generic-y += rwsem.h | 8 | generic-y += rwsem.h |
9 | generic-y += trace_clock.h | 9 | generic-y += trace_clock.h |
10 | generic-y += vtime.h | 10 | generic-y += vtime.h |
11 | generic-y += word-at-a-time.h | ||
diff --git a/arch/s390/include/asm/Kbuild b/arch/s390/include/asm/Kbuild index dc5385ebb071..9e8089b44f46 100644 --- a/arch/s390/include/asm/Kbuild +++ b/arch/s390/include/asm/Kbuild | |||
@@ -5,3 +5,4 @@ generic-y += irq_work.h | |||
5 | generic-y += mcs_spinlock.h | 5 | generic-y += mcs_spinlock.h |
6 | generic-y += preempt.h | 6 | generic-y += preempt.h |
7 | generic-y += trace_clock.h | 7 | generic-y += trace_clock.h |
8 | generic-y += word-at-a-time.h | ||
diff --git a/arch/score/include/asm/Kbuild b/arch/score/include/asm/Kbuild index 138fb3db45ba..ff19975beb33 100644 --- a/arch/score/include/asm/Kbuild +++ b/arch/score/include/asm/Kbuild | |||
@@ -12,3 +12,4 @@ generic-y += sections.h | |||
12 | generic-y += trace_clock.h | 12 | generic-y += trace_clock.h |
13 | generic-y += xor.h | 13 | generic-y += xor.h |
14 | generic-y += serial.h | 14 | generic-y += serial.h |
15 | generic-y += word-at-a-time.h | ||
diff --git a/arch/tile/include/asm/Kbuild b/arch/tile/include/asm/Kbuild index d53654488c2c..ea59330b4d90 100644 --- a/arch/tile/include/asm/Kbuild +++ b/arch/tile/include/asm/Kbuild | |||
@@ -38,4 +38,5 @@ generic-y += termbits.h | |||
38 | generic-y += termios.h | 38 | generic-y += termios.h |
39 | generic-y += trace_clock.h | 39 | generic-y += trace_clock.h |
40 | generic-y += types.h | 40 | generic-y += types.h |
41 | generic-y += word-at-a-time.h | ||
41 | generic-y += xor.h | 42 | generic-y += xor.h |
diff --git a/arch/um/include/asm/Kbuild b/arch/um/include/asm/Kbuild index 3d63ff6f583f..33c1d3e0caad 100644 --- a/arch/um/include/asm/Kbuild +++ b/arch/um/include/asm/Kbuild | |||
@@ -24,4 +24,5 @@ generic-y += preempt.h | |||
24 | generic-y += switch_to.h | 24 | generic-y += switch_to.h |
25 | generic-y += topology.h | 25 | generic-y += topology.h |
26 | generic-y += trace_clock.h | 26 | generic-y += trace_clock.h |
27 | generic-y += word-at-a-time.h | ||
27 | generic-y += xor.h | 28 | generic-y += xor.h |
diff --git a/arch/unicore32/include/asm/Kbuild b/arch/unicore32/include/asm/Kbuild index d12b377b5a8b..932070cd754a 100644 --- a/arch/unicore32/include/asm/Kbuild +++ b/arch/unicore32/include/asm/Kbuild | |||
@@ -61,4 +61,5 @@ generic-y += ucontext.h | |||
61 | generic-y += unaligned.h | 61 | generic-y += unaligned.h |
62 | generic-y += user.h | 62 | generic-y += user.h |
63 | generic-y += vga.h | 63 | generic-y += vga.h |
64 | generic-y += word-at-a-time.h | ||
64 | generic-y += xor.h | 65 | generic-y += xor.h |
diff --git a/arch/xtensa/include/asm/Kbuild b/arch/xtensa/include/asm/Kbuild index 14d15bf1a95b..85acffd26217 100644 --- a/arch/xtensa/include/asm/Kbuild +++ b/arch/xtensa/include/asm/Kbuild | |||
@@ -28,4 +28,5 @@ generic-y += statfs.h | |||
28 | generic-y += termios.h | 28 | generic-y += termios.h |
29 | generic-y += topology.h | 29 | generic-y += topology.h |
30 | generic-y += trace_clock.h | 30 | generic-y += trace_clock.h |
31 | generic-y += word-at-a-time.h | ||
31 | generic-y += xor.h | 32 | generic-y += xor.h |
diff --git a/include/asm-generic/word-at-a-time.h b/include/asm-generic/word-at-a-time.h index 94f9ea8abcae..011dde083f23 100644 --- a/include/asm-generic/word-at-a-time.h +++ b/include/asm-generic/word-at-a-time.h | |||
@@ -1,15 +1,10 @@ | |||
1 | #ifndef _ASM_WORD_AT_A_TIME_H | 1 | #ifndef _ASM_WORD_AT_A_TIME_H |
2 | #define _ASM_WORD_AT_A_TIME_H | 2 | #define _ASM_WORD_AT_A_TIME_H |
3 | 3 | ||
4 | /* | ||
5 | * This says "generic", but it's actually big-endian only. | ||
6 | * Little-endian can use more efficient versions of these | ||
7 | * interfaces, see for example | ||
8 | * arch/x86/include/asm/word-at-a-time.h | ||
9 | * for those. | ||
10 | */ | ||
11 | |||
12 | #include <linux/kernel.h> | 4 | #include <linux/kernel.h> |
5 | #include <asm/byteorder.h> | ||
6 | |||
7 | #ifdef __BIG_ENDIAN | ||
13 | 8 | ||
14 | struct word_at_a_time { | 9 | struct word_at_a_time { |
15 | const unsigned long high_bits, low_bits; | 10 | const unsigned long high_bits, low_bits; |
@@ -53,4 +48,73 @@ static inline bool has_zero(unsigned long val, unsigned long *data, const struct | |||
53 | #define zero_bytemask(mask) (~1ul << __fls(mask)) | 48 | #define zero_bytemask(mask) (~1ul << __fls(mask)) |
54 | #endif | 49 | #endif |
55 | 50 | ||
51 | #else | ||
52 | |||
53 | /* | ||
54 | * The optimal byte mask counting is probably going to be something | ||
55 | * that is architecture-specific. If you have a reliably fast | ||
56 | * bit count instruction, that might be better than the multiply | ||
57 | * and shift, for example. | ||
58 | */ | ||
59 | struct word_at_a_time { | ||
60 | const unsigned long one_bits, high_bits; | ||
61 | }; | ||
62 | |||
63 | #define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0x01), REPEAT_BYTE(0x80) } | ||
64 | |||
65 | #ifdef CONFIG_64BIT | ||
66 | |||
67 | /* | ||
68 | * Jan Achrenius on G+: microoptimized version of | ||
69 | * the simpler "(mask & ONEBYTES) * ONEBYTES >> 56" | ||
70 | * that works for the bytemasks without having to | ||
71 | * mask them first. | ||
72 | */ | ||
73 | static inline long count_masked_bytes(unsigned long mask) | ||
74 | { | ||
75 | return mask*0x0001020304050608ul >> 56; | ||
76 | } | ||
77 | |||
78 | #else /* 32-bit case */ | ||
79 | |||
80 | /* Carl Chatfield / Jan Achrenius G+ version for 32-bit */ | ||
81 | static inline long count_masked_bytes(long mask) | ||
82 | { | ||
83 | /* (000000 0000ff 00ffff ffffff) -> ( 1 1 2 3 ) */ | ||
84 | long a = (0x0ff0001+mask) >> 23; | ||
85 | /* Fix the 1 for 00 case */ | ||
86 | return a & mask; | ||
87 | } | ||
88 | |||
89 | #endif | ||
90 | |||
91 | /* Return nonzero if it has a zero */ | ||
92 | static inline unsigned long has_zero(unsigned long a, unsigned long *bits, const struct word_at_a_time *c) | ||
93 | { | ||
94 | unsigned long mask = ((a - c->one_bits) & ~a) & c->high_bits; | ||
95 | *bits = mask; | ||
96 | return mask; | ||
97 | } | ||
98 | |||
99 | static inline unsigned long prep_zero_mask(unsigned long a, unsigned long bits, const struct word_at_a_time *c) | ||
100 | { | ||
101 | return bits; | ||
102 | } | ||
103 | |||
104 | static inline unsigned long create_zero_mask(unsigned long bits) | ||
105 | { | ||
106 | bits = (bits - 1) & ~bits; | ||
107 | return bits >> 7; | ||
108 | } | ||
109 | |||
110 | /* The mask we created is directly usable as a bytemask */ | ||
111 | #define zero_bytemask(mask) (mask) | ||
112 | |||
113 | static inline unsigned long find_zero(unsigned long mask) | ||
114 | { | ||
115 | return count_masked_bytes(mask); | ||
116 | } | ||
117 | |||
118 | #endif /* __BIG_ENDIAN */ | ||
119 | |||
56 | #endif /* _ASM_WORD_AT_A_TIME_H */ | 120 | #endif /* _ASM_WORD_AT_A_TIME_H */ |