summaryrefslogtreecommitdiff
path: root/sysdeps
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2023-01-10 18:00:59 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2023-02-06 16:19:35 -0300
commit2a8867a17ffe5c5a4251fd40bf6c73a3fd426062 (patch)
tree2b533dae74065199f0d1eaa8be5b385685dfce5e /sysdeps
parent3709ed904770b440d68385f3da259008cdf642a6 (diff)
downloadglibc-2a8867a17ffe5c5a4251fd40bf6c73a3fd426062.tar.gz
string: Improve generic memchr
New algorithm read the first aligned address and mask off the unwanted bytes (this strategy is similar to arch-specific implementations used on powerpc, sparc, and sh). The loop now read word-aligned address and check using the has_eq macro. Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc-linux-gnu, and powerpc64-linux-gnu by removing the arch-specific assembly implementation and disabling multi-arch (it covers both LE and BE for 64 and 32 bits). Co-authored-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Noah Goldstein <goldstein.w.n@gmail.com>
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/powerpc/powerpc32/power4/multiarch/memchr-ppc32.c14
-rw-r--r--sysdeps/powerpc/powerpc64/multiarch/memchr-ppc64.c9
2 files changed, 5 insertions, 18 deletions
diff --git a/sysdeps/powerpc/powerpc32/power4/multiarch/memchr-ppc32.c b/sysdeps/powerpc/powerpc32/power4/multiarch/memchr-ppc32.c
index 39ff84f3f3..a78585650f 100644
--- a/sysdeps/powerpc/powerpc32/power4/multiarch/memchr-ppc32.c
+++ b/sysdeps/powerpc/powerpc32/power4/multiarch/memchr-ppc32.c
@@ -18,17 +18,11 @@
#include <string.h>
-#define MEMCHR __memchr_ppc
+extern __typeof (memchr) __memchr_ppc attribute_hidden;
-#undef weak_alias
-#define weak_alias(a, b)
+#define MEMCHR __memchr_ppc
+#include <string/memchr.c>
#ifdef SHARED
-# undef libc_hidden_builtin_def
-# define libc_hidden_builtin_def(name) \
- __hidden_ver1(__memchr_ppc, __GI_memchr, __memchr_ppc);
+__hidden_ver1(__memchr_ppc, __GI_memchr, __memchr_ppc);
#endif
-
-extern __typeof (memchr) __memchr_ppc attribute_hidden;
-
-#include <string/memchr.c>
diff --git a/sysdeps/powerpc/powerpc64/multiarch/memchr-ppc64.c b/sysdeps/powerpc/powerpc64/multiarch/memchr-ppc64.c
index 8097df709c..49ba5521fe 100644
--- a/sysdeps/powerpc/powerpc64/multiarch/memchr-ppc64.c
+++ b/sysdeps/powerpc/powerpc64/multiarch/memchr-ppc64.c
@@ -18,14 +18,7 @@
#include <string.h>
-#define MEMCHR __memchr_ppc
-
-#undef weak_alias
-#define weak_alias(a, b)
-
-# undef libc_hidden_builtin_def
-# define libc_hidden_builtin_def(name)
-
extern __typeof (memchr) __memchr_ppc attribute_hidden;
+#define MEMCHR __memchr_ppc
#include <string/memchr.c>