diff options
Diffstat (limited to 'arch')
-rw-r--r-- | arch/openrisc/include/asm/Kbuild | 1 | ||||
-rw-r--r-- | arch/sparc/include/asm/Kbuild | 1 | ||||
-rw-r--r-- | arch/x86/include/asm/word-at-a-time.h | 32 |
3 files changed, 31 insertions, 3 deletions
diff --git a/arch/openrisc/include/asm/Kbuild b/arch/openrisc/include/asm/Kbuild index c936483bc8e2..3f35c38d7b64 100644 --- a/arch/openrisc/include/asm/Kbuild +++ b/arch/openrisc/include/asm/Kbuild | |||
@@ -66,3 +66,4 @@ generic-y += topology.h | |||
66 | generic-y += types.h | 66 | generic-y += types.h |
67 | generic-y += ucontext.h | 67 | generic-y += ucontext.h |
68 | generic-y += user.h | 68 | generic-y += user.h |
69 | generic-y += word-at-a-time.h | ||
diff --git a/arch/sparc/include/asm/Kbuild b/arch/sparc/include/asm/Kbuild index 2c2e38821f60..67f83e0a0d68 100644 --- a/arch/sparc/include/asm/Kbuild +++ b/arch/sparc/include/asm/Kbuild | |||
@@ -21,3 +21,4 @@ generic-y += div64.h | |||
21 | generic-y += local64.h | 21 | generic-y += local64.h |
22 | generic-y += irq_regs.h | 22 | generic-y += irq_regs.h |
23 | generic-y += local.h | 23 | generic-y += local.h |
24 | generic-y += word-at-a-time.h | ||
diff --git a/arch/x86/include/asm/word-at-a-time.h b/arch/x86/include/asm/word-at-a-time.h index ae03facfadd6..5b238981542a 100644 --- a/arch/x86/include/asm/word-at-a-time.h +++ b/arch/x86/include/asm/word-at-a-time.h | |||
@@ -10,6 +10,11 @@ | |||
10 | * bit count instruction, that might be better than the multiply | 10 | * bit count instruction, that might be better than the multiply |
11 | * and shift, for example. | 11 | * and shift, for example. |
12 | */ | 12 | */ |
13 | struct word_at_a_time { | ||
14 | const unsigned long one_bits, high_bits; | ||
15 | }; | ||
16 | |||
17 | #define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0x01), REPEAT_BYTE(0x80) } | ||
13 | 18 | ||
14 | #ifdef CONFIG_64BIT | 19 | #ifdef CONFIG_64BIT |
15 | 20 | ||
@@ -37,10 +42,31 @@ static inline long count_masked_bytes(long mask) | |||
37 | 42 | ||
38 | #endif | 43 | #endif |
39 | 44 | ||
40 | /* Return the high bit set in the first byte that is a zero */ | 45 | /* Return nonzero if it has a zero */ |
41 | static inline unsigned long has_zero(unsigned long a) | 46 | static inline unsigned long has_zero(unsigned long a, unsigned long *bits, const struct word_at_a_time *c) |
47 | { | ||
48 | unsigned long mask = ((a - c->one_bits) & ~a) & c->high_bits; | ||
49 | *bits = mask; | ||
50 | return mask; | ||
51 | } | ||
52 | |||
53 | static inline unsigned long prep_zero_mask(unsigned long a, unsigned long bits, const struct word_at_a_time *c) | ||
54 | { | ||
55 | return bits; | ||
56 | } | ||
57 | |||
58 | static inline unsigned long create_zero_mask(unsigned long bits) | ||
59 | { | ||
60 | bits = (bits - 1) & ~bits; | ||
61 | return bits >> 7; | ||
62 | } | ||
63 | |||
64 | /* The mask we created is directly usable as a bytemask */ | ||
65 | #define zero_bytemask(mask) (mask) | ||
66 | |||
67 | static inline unsigned long find_zero(unsigned long mask) | ||
42 | { | 68 | { |
43 | return ((a - REPEAT_BYTE(0x01)) & ~a) & REPEAT_BYTE(0x80); | 69 | return count_masked_bytes(mask); |
44 | } | 70 | } |
45 | 71 | ||
46 | /* | 72 | /* |