]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
Make asm/word-at-a-time.h available on all architectures
authorChris Metcalf <cmetcalf@ezchip.com>
Wed, 29 Apr 2015 16:48:40 +0000 (12:48 -0400)
committerChris Metcalf <cmetcalf@ezchip.com>
Wed, 8 Jul 2015 20:41:55 +0000 (16:41 -0400)
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>
22 files changed:
arch/arc/include/asm/Kbuild
arch/avr32/include/asm/Kbuild
arch/blackfin/include/asm/Kbuild
arch/c6x/include/asm/Kbuild
arch/cris/include/asm/Kbuild
arch/frv/include/asm/Kbuild
arch/hexagon/include/asm/Kbuild
arch/ia64/include/asm/Kbuild
arch/m32r/include/asm/Kbuild
arch/metag/include/asm/Kbuild
arch/microblaze/include/asm/Kbuild
arch/mips/include/asm/Kbuild
arch/mn10300/include/asm/Kbuild
arch/nios2/include/asm/Kbuild
arch/powerpc/include/asm/Kbuild
arch/s390/include/asm/Kbuild
arch/score/include/asm/Kbuild
arch/tile/include/asm/Kbuild
arch/um/include/asm/Kbuild
arch/unicore32/include/asm/Kbuild
arch/xtensa/include/asm/Kbuild
include/asm-generic/word-at-a-time.h

index 1a80cc91a03ba323f8418dfb705098a00f031671..c8f07ce1c757be14ac45bd7483bc2ec6a570f504 100644 (file)
@@ -47,4 +47,5 @@ generic-y += types.h
 generic-y += ucontext.h
 generic-y += user.h
 generic-y += vga.h
+generic-y += word-at-a-time.h
 generic-y += xor.h
index 1d66afdfac079bcf78a8dc230ed326a9d2fbfa12..519810d0d5e1b779290191bc35e70be7133e723e 100644 (file)
@@ -19,4 +19,5 @@ generic-y += sections.h
 generic-y += topology.h
 generic-y += trace_clock.h
 generic-y += vga.h
+generic-y += word-at-a-time.h
 generic-y += xor.h
index 07051a63415d712bcd17469d6db5460c1353030e..c80181e4454fc68ab35640287cd1cfa73d7f8298 100644 (file)
@@ -45,4 +45,5 @@ generic-y += types.h
 generic-y += ucontext.h
 generic-y += unaligned.h
 generic-y += user.h
+generic-y += word-at-a-time.h
 generic-y += xor.h
index 7aeb322729754f25a991a6358e1e5b4a9ad39118..2f697020a8fd8d00044076ef30547685e76dcdfd 100644 (file)
@@ -58,4 +58,5 @@ generic-y += types.h
 generic-y += ucontext.h
 generic-y += user.h
 generic-y += vga.h
+generic-y += word-at-a-time.h
 generic-y += xor.h
index d294f6aaff1d1631dc085e1e174bc8515e59b5cb..09916c8073ac1b0627050441de49965dddd3c599 100644 (file)
@@ -25,4 +25,5 @@ generic-y += sections.h
 generic-y += topology.h
 generic-y += trace_clock.h
 generic-y += vga.h
+generic-y += word-at-a-time.h
 generic-y += xor.h
index 30edce31e5c21e1e7cba707833f10a49d12eb42c..2c987dc05af4935fb25ac0d849e3d356d9c8f1e2 100644 (file)
@@ -6,3 +6,4 @@ generic-y += irq_work.h
 generic-y += mcs_spinlock.h
 generic-y += preempt.h
 generic-y += trace_clock.h
+generic-y += word-at-a-time.h
index 5ade4a163558f924d85dfa5ec058bd4ba8ab1379..0988816dded04d0d586fd7f706f18fa5ec8acfae 100644 (file)
@@ -57,4 +57,5 @@ generic-y += types.h
 generic-y += ucontext.h
 generic-y += unaligned.h
 generic-y += vga.h
+generic-y += word-at-a-time.h
 generic-y += xor.h
index ccff13d33fa21e89e31570a35b33f36c2ec11ad7..dc05773e1f1128802d3a5e58ece01f0ce7f57c83 100644 (file)
@@ -7,3 +7,4 @@ generic-y += mcs_spinlock.h
 generic-y += preempt.h
 generic-y += trace_clock.h
 generic-y += vtime.h
+generic-y += word-at-a-time.h
index ba1cdc0187315113e5a79850ea8b6dc08038800c..219e54b3368515f1f60f62765834a44ed19ab7ae 100644 (file)
@@ -8,3 +8,4 @@ generic-y += module.h
 generic-y += preempt.h
 generic-y += sections.h
 generic-y += trace_clock.h
+generic-y += word-at-a-time.h
index 199320f3c34528c09b392c391e2bcc0874d1f1d5..611c0df2be39c5453cf8a44ac3bf3be81f9a1dcd 100644 (file)
@@ -53,4 +53,5 @@ generic-y += ucontext.h
 generic-y += unaligned.h
 generic-y += user.h
 generic-y += vga.h
+generic-y += word-at-a-time.h
 generic-y += xor.h
index 9989ddb169cab99c25433f2586f184015568a1ef..cefeabae24ccfdd62be07f940cff1c8c911275d4 100644 (file)
@@ -9,3 +9,4 @@ generic-y += mcs_spinlock.h
 generic-y += preempt.h
 generic-y += syscalls.h
 generic-y += trace_clock.h
+generic-y += word-at-a-time.h
index 7fe5c61a3cb83a0399bcd5e2745641f45eb08763..dee810fa973e2df250414e172f7fd87ebce46651 100644 (file)
@@ -17,4 +17,5 @@ generic-y += serial.h
 generic-y += trace_clock.h
 generic-y += ucontext.h
 generic-y += user.h
+generic-y += word-at-a-time.h
 generic-y += xor.h
index de30b0c887968c4b985c3c3ab4f9facd082905f0..27cbc0267b9c183ee66ab1cf6e68305afa4a7581 100644 (file)
@@ -8,3 +8,4 @@ generic-y += mcs_spinlock.h
 generic-y += preempt.h
 generic-y += sections.h
 generic-y += trace_clock.h
+generic-y += word-at-a-time.h
index 434639d510b3cba669461ca75303eab66782a15d..e22478929719115397efca5600af7e95e458b6a6 100644 (file)
@@ -60,4 +60,5 @@ generic-y += types.h
 generic-y += unaligned.h
 generic-y += user.h
 generic-y += vga.h
+generic-y += word-at-a-time.h
 generic-y += xor.h
index 050712e1ce41266ce274bdcdd8b6ab1722cb64fb..d9c0b44191b0ffd3831c4e32ab9394b70a1420ff 100644 (file)
@@ -8,3 +8,4 @@ generic-y += preempt.h
 generic-y += rwsem.h
 generic-y += trace_clock.h
 generic-y += vtime.h
+generic-y += word-at-a-time.h
index dc5385ebb071ac79c08b50c7a4c85b2b0e66f32a..9e8089b44f4622b4f971f71da51e1e089f4ea5be 100644 (file)
@@ -5,3 +5,4 @@ generic-y += irq_work.h
 generic-y += mcs_spinlock.h
 generic-y += preempt.h
 generic-y += trace_clock.h
+generic-y += word-at-a-time.h
index 138fb3db45ba66ee03b7471025b4881af80cc874..ff19975beb33b32581dfdc27b4c648b6807640fb 100644 (file)
@@ -12,3 +12,4 @@ generic-y += sections.h
 generic-y += trace_clock.h
 generic-y += xor.h
 generic-y += serial.h
+generic-y += word-at-a-time.h
index d53654488c2c1529d0a3aede5836eeb11b3bcde5..ea59330b4d904823fae529ccf434ba167197981d 100644 (file)
@@ -38,4 +38,5 @@ generic-y += termbits.h
 generic-y += termios.h
 generic-y += trace_clock.h
 generic-y += types.h
+generic-y += word-at-a-time.h
 generic-y += xor.h
index 3d63ff6f583ff406c98bce4014900669cec513bf..33c1d3e0caad2ac18d06674f8dac1b7562724508 100644 (file)
@@ -24,4 +24,5 @@ generic-y += preempt.h
 generic-y += switch_to.h
 generic-y += topology.h
 generic-y += trace_clock.h
+generic-y += word-at-a-time.h
 generic-y += xor.h
index d12b377b5a8b6b8e8cea9c9df92eef250ed3bf49..932070cd754a9063ce1dff4a3158811e86b7901e 100644 (file)
@@ -61,4 +61,5 @@ generic-y += ucontext.h
 generic-y += unaligned.h
 generic-y += user.h
 generic-y += vga.h
+generic-y += word-at-a-time.h
 generic-y += xor.h
index 14d15bf1a95bfb408bc6ac56f41ad51545228e6b..85acffd262174a009bd4e3e3d129925bb4a9b79a 100644 (file)
@@ -28,4 +28,5 @@ generic-y += statfs.h
 generic-y += termios.h
 generic-y += topology.h
 generic-y += trace_clock.h
+generic-y += word-at-a-time.h
 generic-y += xor.h
index 94f9ea8abcae35af8ca36560403fbd25facb7c65..011dde083f231e763e4c96fcc7fb3cb9b6ce23c7 100644 (file)
@@ -1,15 +1,10 @@
 #ifndef _ASM_WORD_AT_A_TIME_H
 #define _ASM_WORD_AT_A_TIME_H
 
-/*
- * This says "generic", but it's actually big-endian only.
- * Little-endian can use more efficient versions of these
- * interfaces, see for example
- *      arch/x86/include/asm/word-at-a-time.h
- * for those.
- */
-
 #include <linux/kernel.h>
+#include <asm/byteorder.h>
+
+#ifdef __BIG_ENDIAN
 
 struct word_at_a_time {
        const unsigned long high_bits, low_bits;
@@ -53,4 +48,73 @@ static inline bool has_zero(unsigned long val, unsigned long *data, const struct
 #define zero_bytemask(mask) (~1ul << __fls(mask))
 #endif
 
+#else
+
+/*
+ * The optimal byte mask counting is probably going to be something
+ * that is architecture-specific. If you have a reliably fast
+ * bit count instruction, that might be better than the multiply
+ * and shift, for example.
+ */
+struct word_at_a_time {
+       const unsigned long one_bits, high_bits;
+};
+
+#define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0x01), REPEAT_BYTE(0x80) }
+
+#ifdef CONFIG_64BIT
+
+/*
+ * Jan Achrenius on G+: microoptimized version of
+ * the simpler "(mask & ONEBYTES) * ONEBYTES >> 56"
+ * that works for the bytemasks without having to
+ * mask them first.
+ */
+static inline long count_masked_bytes(unsigned long mask)
+{
+       return mask*0x0001020304050608ul >> 56;
+}
+
+#else  /* 32-bit case */
+
+/* Carl Chatfield / Jan Achrenius G+ version for 32-bit */
+static inline long count_masked_bytes(long mask)
+{
+       /* (000000 0000ff 00ffff ffffff) -> ( 1 1 2 3 ) */
+       long a = (0x0ff0001+mask) >> 23;
+       /* Fix the 1 for 00 case */
+       return a & mask;
+}
+
+#endif
+
+/* Return nonzero if it has a zero */
+static inline unsigned long has_zero(unsigned long a, unsigned long *bits, const struct word_at_a_time *c)
+{
+       unsigned long mask = ((a - c->one_bits) & ~a) & c->high_bits;
+       *bits = mask;
+       return mask;
+}
+
+static inline unsigned long prep_zero_mask(unsigned long a, unsigned long bits, const struct word_at_a_time *c)
+{
+       return bits;
+}
+
+static inline unsigned long create_zero_mask(unsigned long bits)
+{
+       bits = (bits - 1) & ~bits;
+       return bits >> 7;
+}
+
+/* The mask we created is directly usable as a bytemask */
+#define zero_bytemask(mask) (mask)
+
+static inline unsigned long find_zero(unsigned long mask)
+{
+       return count_masked_bytes(mask);
+}
+
+#endif /* __BIG_ENDIAN */
+
 #endif /* _ASM_WORD_AT_A_TIME_H */