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

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

Comments

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

Patch

diff --git a/sysdeps/x86_64/Makefile b/sysdeps/x86_64/Makefile
index d8f6d83d88..1eb13d01da 100644
--- a/sysdeps/x86_64/Makefile
+++ b/sysdeps/x86_64/Makefile
@@ -147,7 +147,7 @@  endif
 endif
 
 ifeq ($(subdir),cpu-rt-c)
-cpu-rt-c-routines += memchr
+cpu-rt-c-routines += memchr memcmp
 
 # For the CPU run-time tests.
 vpath %.c $(..)string
diff --git a/sysdeps/x86_64/multiarch/Makefile b/sysdeps/x86_64/multiarch/Makefile
index 2c43179b0f..9bb6c8c3cd 100644
--- a/sysdeps/x86_64/multiarch/Makefile
+++ b/sysdeps/x86_64/multiarch/Makefile
@@ -67,5 +67,7 @@  sysdep_routines += memcpy_chk-nonshared mempcpy_chk-nonshared \
 endif
 
 ifeq ($(subdir),cpu-rt-c)
-libcpu-rt-c-sysdep_routines += memchr-sse2 memchr-avx2
+libcpu-rt-c-sysdep_routines += memchr-sse2 memchr-avx2 \
+			       memcmp-sse2 memcmp-ssse3 memcmp-sse4 \
+			       memcmp-avx2-movbe
 endif
diff --git a/sysdeps/x86_64/multiarch/memcmp-avx2-movbe.S b/sysdeps/x86_64/multiarch/memcmp-avx2-movbe.S
index 30f764c393..614fe23392 100644
--- a/sysdeps/x86_64/multiarch/memcmp-avx2-movbe.S
+++ b/sysdeps/x86_64/multiarch/memcmp-avx2-movbe.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)
 
 /* memcmp/wmemcmp is implemented as:
    1. For size from 2 to 7 bytes, load as big endian with movbe and bswap
diff --git a/sysdeps/x86_64/multiarch/memcmp-sse2.S b/sysdeps/x86_64/multiarch/memcmp-sse2.S
index 6058aa751e..5811cccc15 100644
--- a/sysdeps/x86_64/multiarch/memcmp-sse2.S
+++ b/sysdeps/x86_64/multiarch/memcmp-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 memcmp __memcmp_sse2
 
 # ifdef SHARED
diff --git a/sysdeps/x86_64/multiarch/memcmp-sse4.S b/sysdeps/x86_64/multiarch/memcmp-sse4.S
index 0d96d6b775..89dfb7f04a 100644
--- a/sysdeps/x86_64/multiarch/memcmp-sse4.S
+++ b/sysdeps/x86_64/multiarch/memcmp-sse4.S
@@ -17,7 +17,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/memcmp-ssse3.S b/sysdeps/x86_64/multiarch/memcmp-ssse3.S
index 6f76c64123..2990c3dd2b 100644
--- a/sysdeps/x86_64/multiarch/memcmp-ssse3.S
+++ b/sysdeps/x86_64/multiarch/memcmp-ssse3.S
@@ -17,7 +17,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/memcmp.c b/sysdeps/x86_64/multiarch/memcmp.c
index 6f3ca43128..53d604b883 100644
--- a/sysdeps/x86_64/multiarch/memcmp.c
+++ b/sysdeps/x86_64/multiarch/memcmp.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 memcmp __redirect_memcmp
 # include <string.h>
 # undef memcmp
@@ -30,7 +30,7 @@  libc_ifunc_redirected (__redirect_memcmp, memcmp, IFUNC_SELECTOR ());
 # undef bcmp
 weak_alias (memcmp, bcmp)
 
-# ifdef SHARED
+# if defined SHARED && !IS_IN (libcpu_rt_c)
 __hidden_ver1 (memcmp, __GI_memcmp, __redirect_memcmp)
   __attribute__ ((visibility ("hidden")));
 # endif