Patchwork [20/20] libcpu-rt-c/x86-64: Add strrchr

login
register
mail settings
Submitter H.J. Lu
Date June 12, 2018, 10:19 p.m.
Message ID <20180612221939.19545-21-hjl.tools@gmail.com>
Download mbox | patch
Permalink /patch/27777/
State New
Headers show

Comments

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

Patch

diff --git a/sysdeps/x86_64/Makefile b/sysdeps/x86_64/Makefile
index 17d3a07894..267ce17e42 100644
--- a/sysdeps/x86_64/Makefile
+++ b/sysdeps/x86_64/Makefile
@@ -149,7 +149,7 @@  endif
 ifeq ($(subdir),cpu-rt-c)
 cpu-rt-c-routines += memchr memcmp memcpy memmove mempcpy memrchr \
 		     memset strcat strchr strcmp strcpy strlen strncat \
-		     strnlen strncmp strncpy \
+		     strnlen strncmp strncpy strrchr \
 		     wmemset
 
 # For the CPU run-time tests.
diff --git a/sysdeps/x86_64/multiarch/Makefile b/sysdeps/x86_64/multiarch/Makefile
index de4938b3eb..08a578e1a3 100644
--- a/sysdeps/x86_64/multiarch/Makefile
+++ b/sysdeps/x86_64/multiarch/Makefile
@@ -93,5 +93,5 @@  libcpu-rt-c-sysdep_routines += memchr-sse2 memchr-avx2 \
 			       strnlen-sse2 strnlen-avx2 strncmp-sse2 \
 			       strncmp-ssse3 strncmp-sse4_2 strncmp-avx2 \
 			       strncpy-c strncpy-sse2-unaligned \
-			       strncpy-ssse3
+			       strncpy-ssse3 strrchr-sse2 strrchr-avx2
 endif
diff --git a/sysdeps/x86_64/multiarch/strrchr-avx2.S b/sysdeps/x86_64/multiarch/strrchr-avx2.S
index 4381e6ab3e..78347b6bf7 100644
--- a/sysdeps/x86_64/multiarch/strrchr-avx2.S
+++ b/sysdeps/x86_64/multiarch/strrchr-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/strrchr-sse2.S b/sysdeps/x86_64/multiarch/strrchr-sse2.S
index 0ec76fe9cc..0f6678f642 100644
--- a/sysdeps/x86_64/multiarch/strrchr-sse2.S
+++ b/sysdeps/x86_64/multiarch/strrchr-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 strrchr __strrchr_sse2
 
 # undef weak_alias
diff --git a/sysdeps/x86_64/multiarch/strrchr.c b/sysdeps/x86_64/multiarch/strrchr.c
index a719edde10..6c44acb42d 100644
--- a/sysdeps/x86_64/multiarch/strrchr.c
+++ b/sysdeps/x86_64/multiarch/strrchr.c
@@ -17,7 +17,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 strrchr __redirect_strrchr
 # include <string.h>
 # undef strrchr
@@ -27,7 +27,7 @@ 
 
 libc_ifunc_redirected (__redirect_strrchr, strrchr, IFUNC_SELECTOR ());
 weak_alias (strrchr, rindex);
-# ifdef SHARED
+# if defined SHARED && !IS_IN (libcpu_rt_c)
 __hidden_ver1 (strrchr, __GI_strrchr, __redirect_strrchr)
   __attribute__((visibility ("hidden")));
 # endif