diff options
author | Chris Metcalf <cmetcalf@tilera.com> | 2012-03-29 13:30:31 -0400 |
---|---|---|
committer | Chris Metcalf <cmetcalf@tilera.com> | 2012-05-25 12:48:22 -0400 |
commit | 1efea40d4172a2a475ccb29b59d6221e9d0c174b (patch) | |
tree | 8152b61bb3fa83eb3403bca5cb05731c1063e999 /arch/tile/lib/strlen_64.c | |
parent | 73636b1aacb1a07e6fbe0d25e560e69b024a8e25 (diff) |
arch/tile: support building big-endian kernel
The toolchain supports big-endian mode now, so add support for building
the kernel to run big-endian as well.
Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>
Diffstat (limited to 'arch/tile/lib/strlen_64.c')
-rw-r--r-- | arch/tile/lib/strlen_64.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/arch/tile/lib/strlen_64.c b/arch/tile/lib/strlen_64.c index 1c92d46202a8..9583fc3361fa 100644 --- a/arch/tile/lib/strlen_64.c +++ b/arch/tile/lib/strlen_64.c | |||
@@ -15,8 +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 | 18 | #include "string-endian.h" | |
19 | #undef strlen | ||
20 | 19 | ||
21 | size_t strlen(const char *s) | 20 | size_t strlen(const char *s) |
22 | { | 21 | { |
@@ -24,15 +23,13 @@ size_t strlen(const char *s) | |||
24 | const uintptr_t s_int = (uintptr_t) s; | 23 | const uintptr_t s_int = (uintptr_t) s; |
25 | const uint64_t *p = (const uint64_t *)(s_int & -8); | 24 | const uint64_t *p = (const uint64_t *)(s_int & -8); |
26 | 25 | ||
27 | /* Read the first word, but force bytes before the string to be nonzero. | 26 | /* Read and MASK the first word. */ |
28 | * This expression works because we know shift counts are taken mod 64. | 27 | uint64_t v = *p | MASK(s_int); |
29 | */ | ||
30 | uint64_t v = *p | ((1ULL << (s_int << 3)) - 1); | ||
31 | 28 | ||
32 | uint64_t bits; | 29 | uint64_t bits; |
33 | while ((bits = __insn_v1cmpeqi(v, 0)) == 0) | 30 | while ((bits = __insn_v1cmpeqi(v, 0)) == 0) |
34 | v = *++p; | 31 | v = *++p; |
35 | 32 | ||
36 | return ((const char *)p) + (__insn_ctz(bits) >> 3) - s; | 33 | return ((const char *)p) + (CFZ(bits) >> 3) - s; |
37 | } | 34 | } |
38 | EXPORT_SYMBOL(strlen); | 35 | EXPORT_SYMBOL(strlen); |