[04/20] libcpu-rt-c/x86-64: Add memchr
Commit Message
* sysdeps/x86_64/Makefile (cpu-rt-c-routines): Add memchr.
(vpath %.c $(..)string): New.
* sysdeps/x86_64/memchr.S: Don't define alias __memchr in
libcpu-rt-c.
* sysdeps/x86_64/multiarch/Makefile
(libcpu-rt-c-sysdep_routines): Add memchr-sse2 and memchr-avx2.
* sysdeps/x86_64/multiarch/memchr-avx2.S: Support libcpu-rt-c.
* sysdeps/x86_64/multiarch/memchr-sse2.S: Likewise.
* sysdeps/x86_64/multiarch/memchr.c: Likewise.
---
sysdeps/x86_64/Makefile | 7 +++++++
sysdeps/x86_64/memchr.S | 2 +-
sysdeps/x86_64/multiarch/Makefile | 4 ++++
sysdeps/x86_64/multiarch/memchr-avx2.S | 2 +-
sysdeps/x86_64/multiarch/memchr-sse2.S | 2 +-
sysdeps/x86_64/multiarch/memchr.c | 6 ++++--
6 files changed, 18 insertions(+), 5 deletions(-)
@@ -146,6 +146,13 @@ CFLAGS-tst-avx512mod.c += $(AVX512-CFLAGS)
endif
endif
+ifeq ($(subdir),cpu-rt-c)
+cpu-rt-c-routines += memchr
+
+# For the CPU run-time tests.
+vpath %.c $(..)string
+endif
+
ifeq ($(subdir),csu)
gen-as-const-headers += tlsdesc.sym rtld-offsets.sym
endif
@@ -324,7 +324,7 @@ L(return_null):
ret
END(MEMCHR)
-#ifndef USE_AS_WMEMCHR
+#if !defined USE_AS_WMEMCHR && !IS_IN (libcpu_rt_c)
strong_alias (memchr, __memchr)
libc_hidden_builtin_def(memchr)
#endif
@@ -65,3 +65,7 @@ sysdep_routines += memcpy_chk-nonshared mempcpy_chk-nonshared \
memmove_chk-nonshared memset_chk-nonshared \
wmemset_chk-nonshared
endif
+
+ifeq ($(subdir),cpu-rt-c)
+libcpu-rt-c-sysdep_routines += memchr-sse2 memchr-avx2
+endif
@@ -16,7 +16,7 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
-#if IS_IN (libc)
+#if IS_IN (libc) || IS_IN (libcpu_rt_c)
# include <sysdep.h>
@@ -16,7 +16,7 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
-#if IS_IN (libc)
+#if IS_IN (libc) || IS_IN (libcpu_rt_c)
# define memchr __memchr_sse2
# undef strong_alias
@@ -18,7 +18,7 @@
<http://www.gnu.org/licenses/>. */
/* Define multiple versions only for the definition in libc. */
-#if IS_IN (libc)
+#if IS_IN (libc) || IS_IN (libcpu_rt_c)
# define memchr __redirect_memchr
# include <string.h>
# undef memchr
@@ -27,9 +27,11 @@
# include "ifunc-avx2.h"
libc_ifunc_redirected (__redirect_memchr, memchr, IFUNC_SELECTOR ());
+# if !IS_IN (libcpu_rt_c)
strong_alias (memchr, __memchr)
-# ifdef SHARED
+# ifdef SHARED
__hidden_ver1 (memchr, __GI_memchr, __redirect_memchr)
__attribute__((visibility ("hidden")));
+# endif
# endif
#endif