diff options
Diffstat (limited to 'arch/tile/lib/memchr_64.c')
-rw-r--r-- | arch/tile/lib/memchr_64.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/arch/tile/lib/memchr_64.c b/arch/tile/lib/memchr_64.c index 84fdc8d8e735..6f867dbf7c56 100644 --- a/arch/tile/lib/memchr_64.c +++ b/arch/tile/lib/memchr_64.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/types.h> | 15 | #include <linux/types.h> |
16 | #include <linux/string.h> | 16 | #include <linux/string.h> |
17 | #include <linux/module.h> | 17 | #include <linux/module.h> |
18 | #include "string-endian.h" | ||
18 | 19 | ||
19 | void *memchr(const void *s, int c, size_t n) | 20 | void *memchr(const void *s, int c, size_t n) |
20 | { | 21 | { |
@@ -39,11 +40,8 @@ void *memchr(const void *s, int c, size_t n) | |||
39 | 40 | ||
40 | /* Read the first word, but munge it so that bytes before the array | 41 | /* Read the first word, but munge it so that bytes before the array |
41 | * will not match goal. | 42 | * will not match goal. |
42 | * | ||
43 | * Note that this shift count expression works because we know | ||
44 | * shift counts are taken mod 64. | ||
45 | */ | 43 | */ |
46 | before_mask = (1ULL << (s_int << 3)) - 1; | 44 | before_mask = MASK(s_int); |
47 | v = (*p | before_mask) ^ (goal & before_mask); | 45 | v = (*p | before_mask) ^ (goal & before_mask); |
48 | 46 | ||
49 | /* Compute the address of the last byte. */ | 47 | /* Compute the address of the last byte. */ |
@@ -65,7 +63,7 @@ void *memchr(const void *s, int c, size_t n) | |||
65 | /* We found a match, but it might be in a byte past the end | 63 | /* We found a match, but it might be in a byte past the end |
66 | * of the array. | 64 | * of the array. |
67 | */ | 65 | */ |
68 | ret = ((char *)p) + (__insn_ctz(bits) >> 3); | 66 | ret = ((char *)p) + (CFZ(bits) >> 3); |
69 | return (ret <= last_byte_ptr) ? ret : NULL; | 67 | return (ret <= last_byte_ptr) ? ret : NULL; |
70 | } | 68 | } |
71 | EXPORT_SYMBOL(memchr); | 69 | EXPORT_SYMBOL(memchr); |