This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH 04/20] libcpu-rt-c/x86-64: Add memchr
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: libc-alpha at sourceware dot org
- Date: Tue, 12 Jun 2018 15:19:23 -0700
- Subject: [PATCH 04/20] libcpu-rt-c/x86-64: Add memchr
- References: <20180612221939.19545-1-hjl.tools@gmail.com>
* 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(-)
diff --git a/sysdeps/x86_64/Makefile b/sysdeps/x86_64/Makefile
index 9f1562f1b2..d8f6d83d88 100644
--- a/sysdeps/x86_64/Makefile
+++ b/sysdeps/x86_64/Makefile
@@ -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
diff --git a/sysdeps/x86_64/memchr.S b/sysdeps/x86_64/memchr.S
index feef5d4f24..2a17b01733 100644
--- a/sysdeps/x86_64/memchr.S
+++ b/sysdeps/x86_64/memchr.S
@@ -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
diff --git a/sysdeps/x86_64/multiarch/Makefile b/sysdeps/x86_64/multiarch/Makefile
index bb5e970735..2c43179b0f 100644
--- a/sysdeps/x86_64/multiarch/Makefile
+++ b/sysdeps/x86_64/multiarch/Makefile
@@ -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
diff --git a/sysdeps/x86_64/multiarch/memchr-avx2.S b/sysdeps/x86_64/multiarch/memchr-avx2.S
index 5f5e772554..15710b69f6 100644
--- a/sysdeps/x86_64/multiarch/memchr-avx2.S
+++ b/sysdeps/x86_64/multiarch/memchr-avx2.S
@@ -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>
diff --git a/sysdeps/x86_64/multiarch/memchr-sse2.S b/sysdeps/x86_64/multiarch/memchr-sse2.S
index 8a5e7fd1c5..6f299d5119 100644
--- a/sysdeps/x86_64/multiarch/memchr-sse2.S
+++ b/sysdeps/x86_64/multiarch/memchr-sse2.S
@@ -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
diff --git a/sysdeps/x86_64/multiarch/memchr.c b/sysdeps/x86_64/multiarch/memchr.c
index 016f57846a..25927f72ed 100644
--- a/sysdeps/x86_64/multiarch/memchr.c
+++ b/sysdeps/x86_64/multiarch/memchr.c
@@ -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
--
2.17.1