Patchwork [09/20] libcpu-rt-c/i386: Add memcmp

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

Comments

H.J. Lu - June 12, 2018, 10:19 p.m.
Add memcmp to i386 libcpu-rt-c so that libcpu-rt-c with tunables can be
built for i386.

	* sysdeps/i386/Makefile (cpu-rt-c-routines): Add memcmp.
	(vpath %.c $(..)string): New.
	* sysdeps/i386/i686/multiarch/Makefile
	(libcpu-rt-c-sysdep_routines): Add memcmp-ia32, memcmp-ssse3
	and memcmp-sse4.
	* sysdeps/i386/i686/multiarch/memcmp-ia32.S: Support libcpu-rt-c.
	* sysdeps/i386/i686/multiarch/memcmp-sse4.S: Likewise.
	* sysdeps/i386/i686/multiarch/memcmp-ssse3.S: Likewise.
	* sysdeps/i386/i686/multiarch/memcmp.c: Likewise.
---
 sysdeps/i386/Makefile                      | 7 +++++++
 sysdeps/i386/i686/multiarch/Makefile       | 4 ++++
 sysdeps/i386/i686/multiarch/memcmp-ia32.S  | 8 ++++++--
 sysdeps/i386/i686/multiarch/memcmp-sse4.S  | 2 +-
 sysdeps/i386/i686/multiarch/memcmp-ssse3.S | 2 +-
 sysdeps/i386/i686/multiarch/memcmp.c       | 2 +-
 6 files changed, 20 insertions(+), 5 deletions(-)

Patch

diff --git a/sysdeps/i386/Makefile b/sysdeps/i386/Makefile
index 1682394e76..313c88d164 100644
--- a/sysdeps/i386/Makefile
+++ b/sysdeps/i386/Makefile
@@ -40,6 +40,13 @@  $(objpfx)tst-audit3.out: $(objpfx)tst-auditmod3b.so
 tst-audit3-ENV = LD_AUDIT=$(objpfx)tst-auditmod3b.so
 endif
 
+ifeq ($(subdir),cpu-rt-c)
+cpu-rt-c-routines += memcmp
+
+# For the CPU run-time tests.
+vpath %.c $(..)string
+endif
+
 ifeq ($(subdir),csu)
 gen-as-const-headers += tlsdesc.sym
 endif
diff --git a/sysdeps/i386/i686/multiarch/Makefile b/sysdeps/i386/i686/multiarch/Makefile
index bf75a9947f..7cc686a8a2 100644
--- a/sysdeps/i386/i686/multiarch/Makefile
+++ b/sysdeps/i386/i686/multiarch/Makefile
@@ -53,3 +53,7 @@  ifeq ($(subdir),debug)
 sysdep_routines += memcpy_chk-nonshared mempcpy_chk-nonshared \
 		   memmove_chk-nonshared memset_chk-nonshared
 endif
+
+ifeq ($(subdir),cpu-rt-c)
+libcpu-rt-c-sysdep_routines += memcmp-ia32 memcmp-ssse3 memcmp-sse4
+endif
diff --git a/sysdeps/i386/i686/multiarch/memcmp-ia32.S b/sysdeps/i386/i686/multiarch/memcmp-ia32.S
index b468350474..8dbf6ac640 100644
--- a/sysdeps/i386/i686/multiarch/memcmp-ia32.S
+++ b/sysdeps/i386/i686/multiarch/memcmp-ia32.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_ia32
 
 # ifdef SHARED
@@ -24,8 +24,12 @@ 
 /* IFUNC doesn't work with the hidden functions in shared library since
    they will be called without setting up EBX needed for PLT which is
    used by IFUNC.  */
-#  define libc_hidden_builtin_def(name) \
+#  if IS_IN (libcpu_rt_c)
+#   define libc_hidden_builtin_def(name)
+#  else
+#   define libc_hidden_builtin_def(name) \
 	.globl __GI_memcmp; __GI_memcmp = memcmp
+#  endif
 # endif
 
 # undef weak_alias
diff --git a/sysdeps/i386/i686/multiarch/memcmp-sse4.S b/sysdeps/i386/i686/multiarch/memcmp-sse4.S
index be37108987..55c37e5717 100644
--- a/sysdeps/i386/i686/multiarch/memcmp-sse4.S
+++ b/sysdeps/i386/i686/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/i386/i686/multiarch/memcmp-ssse3.S b/sysdeps/i386/i686/multiarch/memcmp-ssse3.S
index 31a0b2908e..088eb2b4ff 100644
--- a/sysdeps/i386/i686/multiarch/memcmp-ssse3.S
+++ b/sysdeps/i386/i686/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/i386/i686/multiarch/memcmp.c b/sysdeps/i386/i686/multiarch/memcmp.c
index dd5a93a26c..58687e7603 100644
--- a/sysdeps/i386/i686/multiarch/memcmp.c
+++ b/sysdeps/i386/i686/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