[14/20] libcpu-rt-c/x86-64: Add strlen

Message ID 20180612221939.19545-15-hjl.tools@gmail.com
State New
Headers show
Series
  • RFC: Add the CPU run-time library for C
Related show

Commit Message

H.J. Lu June 12, 2018, 10:19 p.m.
* sysdeps/x86_64/Makefile (cpu-rt-c-routines): Add strlen.
	* sysdeps/x86_64/multiarch/Makefile
	(libcpu-rt-c-sysdep_routines): Add strlen-sse2 and strlen-avx2.
	* sysdeps/x86_64/multiarch/strlen-avx2.S: Support libcpu-rt-c.
	* sysdeps/x86_64/multiarch/strlen-sse2.S: Likewise.
	* sysdeps/x86_64/multiarch/strlen.c: Likewise.
---
 sysdeps/x86_64/Makefile                | 2 +-
 sysdeps/x86_64/multiarch/Makefile      | 3 ++-
 sysdeps/x86_64/multiarch/strlen-avx2.S | 2 +-
 sysdeps/x86_64/multiarch/strlen-sse2.S | 2 +-
 sysdeps/x86_64/multiarch/strlen.c      | 4 ++--
 5 files changed, 7 insertions(+), 6 deletions(-)

Patch

diff --git a/sysdeps/x86_64/Makefile b/sysdeps/x86_64/Makefile
index b793d067f2..947cb48086 100644
--- a/sysdeps/x86_64/Makefile
+++ b/sysdeps/x86_64/Makefile
@@ -148,7 +148,7 @@  endif
 
 ifeq ($(subdir),cpu-rt-c)
 cpu-rt-c-routines += memchr memcmp memcpy memmove mempcpy memrchr \
-		     memset strchr strcmp strcpy \
+		     memset strchr strcmp strcpy strlen \
 		     wmemset
 
 # For the CPU run-time tests.
diff --git a/sysdeps/x86_64/multiarch/Makefile b/sysdeps/x86_64/multiarch/Makefile
index c6040a0170..b2f0e9f8da 100644
--- a/sysdeps/x86_64/multiarch/Makefile
+++ b/sysdeps/x86_64/multiarch/Makefile
@@ -85,5 +85,6 @@  libcpu-rt-c-sysdep_routines += memchr-sse2 memchr-avx2 \
 			       strchr-avx2 strcmp-sse2 \
 			       strcmp-sse2-unaligned strcmp-ssse3 \
 			       strcmp-sse4_2 strcmp-avx2 strcpy-sse2 \
-			       strcpy-sse2-unaligned strcpy-ssse3
+			       strcpy-sse2-unaligned strcpy-ssse3 \
+			       strlen-sse2 strlen-avx2
 endif
diff --git a/sysdeps/x86_64/multiarch/strlen-avx2.S b/sysdeps/x86_64/multiarch/strlen-avx2.S
index fb2418cddc..6e390e1ddf 100644
--- a/sysdeps/x86_64/multiarch/strlen-avx2.S
+++ b/sysdeps/x86_64/multiarch/strlen-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/strlen-sse2.S b/sysdeps/x86_64/multiarch/strlen-sse2.S
index 7bc57b8d0f..c0d80a3779 100644
--- a/sysdeps/x86_64/multiarch/strlen-sse2.S
+++ b/sysdeps/x86_64/multiarch/strlen-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 strlen __strlen_sse2
 #endif
 
diff --git a/sysdeps/x86_64/multiarch/strlen.c b/sysdeps/x86_64/multiarch/strlen.c
index 1758d22b8f..04d4c04b15 100644
--- a/sysdeps/x86_64/multiarch/strlen.c
+++ b/sysdeps/x86_64/multiarch/strlen.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 strlen __redirect_strlen
 # include <string.h>
 # undef strlen
@@ -27,7 +27,7 @@ 
 # include "ifunc-avx2.h"
 
 libc_ifunc_redirected (__redirect_strlen, strlen, IFUNC_SELECTOR ());
-# ifdef SHARED
+# if defined SHARED && !IS_IN (libcpu_rt_c)
 __hidden_ver1 (strlen, __GI_strlen, __redirect_strlen)
   __attribute__((visibility ("hidden")));
 # endif