5de29b
From fda2d6aca32ad6a4d546ab3a7dd708de78e18c3a Mon Sep 17 00:00:00 2001
5de29b
From: Rajalakshmi Srinivasaraghavan <raji@linux.vnet.ibm.com>
5de29b
Date: Wed, 30 Jul 2014 05:49:36 -0500
5de29b
Subject: [PATCH] PowerPC: multiarch strncmp for PowerPC64
5de29b
5de29b
commit 24c2c3b99699b7cb7cc3c251d9bd504b2cde6a45
5de29b
Author: Adhemerval Zanella <azanella@linux.vnet.ibm.com>
5de29b
Date:   Fri Dec 13 14:48:48 2013 -0500
5de29b
---
5de29b
 sysdeps/powerpc/powerpc64/multiarch/Makefile       |  3 +-
5de29b
 .../powerpc/powerpc64/multiarch/ifunc-impl-list.c  |  9 +++++
5de29b
 .../powerpc/powerpc64/multiarch/strncmp-power4.S   | 38 ++++++++++++++++++++
5de29b
 .../powerpc/powerpc64/multiarch/strncmp-power7.S   | 39 ++++++++++++++++++++
5de29b
 .../powerpc/powerpc64/multiarch/strncmp-ppc64.S    | 41 ++++++++++++++++++++++
5de29b
 sysdeps/powerpc/powerpc64/multiarch/strncmp.c      | 37 +++++++++++++++++++
5de29b
 6 files changed, 166 insertions(+), 1 deletion(-)
5de29b
 create mode 100644 sysdeps/powerpc/powerpc64/multiarch/strncmp-power4.S
5de29b
 create mode 100644 sysdeps/powerpc/powerpc64/multiarch/strncmp-power7.S
5de29b
 create mode 100644 sysdeps/powerpc/powerpc64/multiarch/strncmp-ppc64.S
5de29b
 create mode 100644 sysdeps/powerpc/powerpc64/multiarch/strncmp.c
5de29b
5de29b
diff --git a/sysdeps/powerpc/powerpc64/multiarch/Makefile b/sysdeps/powerpc/powerpc64/multiarch/Makefile
5de29b
index 4dca756..22baf1c 100644
5de29b
--- a/sysdeps/powerpc/powerpc64/multiarch/Makefile
5de29b
+++ b/sysdeps/powerpc/powerpc64/multiarch/Makefile
5de29b
@@ -7,7 +7,8 @@ sysdep_routines += memcpy-power7 memcpy-a2 memcpy-power6 memcpy-cell \
5de29b
                   memrchr-power7 memrchr-ppc64 rawmemchr-power7 \
5de29b
                   rawmemchr-ppc64 strlen-power7 strlen-ppc64 strnlen-power7 \
5de29b
                   strnlen-ppc64 strcasecmp-power7 strcasecmp_l-power7 \
5de29b
-                  strncase-power7 strncase_l-power7
5de29b
+                  strncase-power7 strncase_l-power7 strncmp-power7 \
5de29b
+                  strncmp-power4 strncmp-ppc64
5de29b
 
5de29b
 CFLAGS-strncase-power7.c += -mcpu=power7 -funroll-loops
5de29b
 CFLAGS-strncase_l-power7.c += -mcpu=power7 -funroll-loops
5de29b
diff --git a/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c b/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
5de29b
index 4b8fb22..67f75a5 100644
5de29b
--- a/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
5de29b
+++ b/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
5de29b
@@ -77,6 +77,15 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
5de29b
                              __strlen_power7)
5de29b
              IFUNC_IMPL_ADD (array, i, strlen, 1,
5de29b
                              __strlen_ppc))
5de29b
+
5de29b
+  /* Support sysdeps/powerpc/powerpc64/multiarch/strncmp.c.  */
5de29b
+  IFUNC_IMPL (i, name, strncmp,
5de29b
+             IFUNC_IMPL_ADD (array, i, strncmp, hwcap & PPC_FEATURE_HAS_VSX,
5de29b
+                             __strncmp_power7)
5de29b
+             IFUNC_IMPL_ADD (array, i, strncmp, hwcap & PPC_FEATURE_POWER4,
5de29b
+                             __strncmp_power4)
5de29b
+             IFUNC_IMPL_ADD (array, i, strncmp, 1,
5de29b
+                             __strncmp_ppc))
5de29b
 #endif
5de29b
 
5de29b
   /* Support sysdeps/powerpc/powerpc64/multiarch/memcmp.c.  */
5de29b
diff --git a/sysdeps/powerpc/powerpc64/multiarch/strncmp-power4.S b/sysdeps/powerpc/powerpc64/multiarch/strncmp-power4.S
5de29b
new file mode 100644
5de29b
index 0000000..62cebbc
5de29b
--- /dev/null
5de29b
+++ b/sysdeps/powerpc/powerpc64/multiarch/strncmp-power4.S
5de29b
@@ -0,0 +1,38 @@
5de29b
+/* Copyright (C) 2013-2014 Free Software Foundation, Inc.
5de29b
+   This file is part of the GNU C Library.
5de29b
+
5de29b
+   The GNU C Library is free software; you can redistribute it and/or
5de29b
+   modify it under the terms of the GNU Lesser General Public
5de29b
+   License as published by the Free Software Foundation; either
5de29b
+   version 2.1 of the License, or (at your option) any later version.
5de29b
+
5de29b
+   The GNU C Library is distributed in the hope that it will be useful,
5de29b
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
5de29b
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
5de29b
+   Lesser General Public License for more details.
5de29b
+
5de29b
+   You should have received a copy of the GNU Lesser General Public
5de29b
+   License along with the GNU C Library; if not, see
5de29b
+   <http://www.gnu.org/licenses/>.  */
5de29b
+
5de29b
+#include <sysdep.h>
5de29b
+
5de29b
+#undef EALIGN
5de29b
+#define EALIGN(name,alignt,words)				\
5de29b
+  .section ".text";						\
5de29b
+  ENTRY_2(__strncmp_power4)					\
5de29b
+  .align ALIGNARG(alignt);					\
5de29b
+  EALIGN_W_##words;						\
5de29b
+  BODY_LABEL(__strncmp_power4):					\
5de29b
+  cfi_startproc;
5de29b
+
5de29b
+#undef END
5de29b
+#define END(name)						\
5de29b
+  cfi_endproc;							\
5de29b
+  TRACEBACK(__strncmp_power4)					\
5de29b
+  END_2(__strncmp_power4)
5de29b
+
5de29b
+#undef libc_hidden_builtin_def
5de29b
+#define libc_hidden_builtin_def(name)
5de29b
+
5de29b
+#include <sysdeps/powerpc/powerpc64/power4/strncmp.S>
5de29b
diff --git a/sysdeps/powerpc/powerpc64/multiarch/strncmp-power7.S b/sysdeps/powerpc/powerpc64/multiarch/strncmp-power7.S
5de29b
new file mode 100644
5de29b
index 0000000..b0d607a
5de29b
--- /dev/null
5de29b
+++ b/sysdeps/powerpc/powerpc64/multiarch/strncmp-power7.S
5de29b
@@ -0,0 +1,39 @@
5de29b
+/* Copyright (C) 2013-2014 Free Software Foundation, Inc.
5de29b
+   This file is part of the GNU C Library.
5de29b
+
5de29b
+   The GNU C Library is free software; you can redistribute it and/or
5de29b
+   modify it under the terms of the GNU Lesser General Public
5de29b
+   License as published by the Free Software Foundation; either
5de29b
+   version 2.1 of the License, or (at your option) any later version.
5de29b
+
5de29b
+   The GNU C Library is distributed in the hope that it will be useful,
5de29b
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
5de29b
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
5de29b
+   Lesser General Public License for more details.
5de29b
+
5de29b
+   You should have received a copy of the GNU Lesser General Public
5de29b
+   License along with the GNU C Library; if not, see
5de29b
+   <http://www.gnu.org/licenses/>.  */
5de29b
+
5de29b
+#include <sysdep.h>
5de29b
+
5de29b
+#undef EALIGN
5de29b
+#define EALIGN(name,alignt,words)				\
5de29b
+  .section ".text";						\
5de29b
+  ENTRY_2(__strncmp_power7)					\
5de29b
+  .align ALIGNARG(alignt);					\
5de29b
+  EALIGN_W_##words;						\
5de29b
+  BODY_LABEL(__strncmp_power7):					\
5de29b
+  cfi_startproc;
5de29b
+
5de29b
+#undef END
5de29b
+#define END(name)						\
5de29b
+  cfi_endproc;							\
5de29b
+  TRACEBACK(__strncmp_power7)					\
5de29b
+  END_2(__strncmp_power7)
5de29b
+
5de29b
+
5de29b
+#undef libc_hidden_builtin_def
5de29b
+#define libc_hidden_builtin_def(name)
5de29b
+
5de29b
+#include <sysdeps/powerpc/powerpc64/power7/strncmp.S>
5de29b
diff --git a/sysdeps/powerpc/powerpc64/multiarch/strncmp-ppc64.S b/sysdeps/powerpc/powerpc64/multiarch/strncmp-ppc64.S
5de29b
new file mode 100644
5de29b
index 0000000..25b7f26
5de29b
--- /dev/null
5de29b
+++ b/sysdeps/powerpc/powerpc64/multiarch/strncmp-ppc64.S
5de29b
@@ -0,0 +1,41 @@
5de29b
+/* Copyright (C) 2013-2014 Free Software Foundation, Inc.
5de29b
+   This file is part of the GNU C Library.
5de29b
+
5de29b
+   The GNU C Library is free software; you can redistribute it and/or
5de29b
+   modify it under the terms of the GNU Lesser General Public
5de29b
+   License as published by the Free Software Foundation; either
5de29b
+   version 2.1 of the License, or (at your option) any later version.
5de29b
+
5de29b
+   The GNU C Library is distributed in the hope that it will be useful,
5de29b
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
5de29b
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
5de29b
+   Lesser General Public License for more details.
5de29b
+
5de29b
+   You should have received a copy of the GNU Lesser General Public
5de29b
+   License along with the GNU C Library; if not, see
5de29b
+   <http://www.gnu.org/licenses/>.  */
5de29b
+
5de29b
+#include <sysdep.h>
5de29b
+
5de29b
+#if defined SHARED && !defined NOT_IN_libc
5de29b
+#undef EALIGN
5de29b
+#define EALIGN(name,alignt,words)				\
5de29b
+  .section ".text";						\
5de29b
+  ENTRY_2(__strncmp_ppc)					\
5de29b
+  .align ALIGNARG(alignt);					\
5de29b
+  EALIGN_W_##words;						\
5de29b
+  BODY_LABEL(__strncmp_ppc):					\
5de29b
+  cfi_startproc;
5de29b
+
5de29b
+#undef END
5de29b
+#define END(name)						\
5de29b
+  cfi_endproc;							\
5de29b
+  TRACEBACK(__strncmp_ppc)					\
5de29b
+  END_2(__strncmp_ppc)
5de29b
+
5de29b
+# undef libc_hidden_builtin_def
5de29b
+# define libc_hidden_builtin_def(name)				\
5de29b
+    .globl __GI_strncmp; __GI_strncmp = __strncmp_ppc
5de29b
+#endif
5de29b
+
5de29b
+#include <sysdeps/powerpc/powerpc64/strncmp.S>
5de29b
diff --git a/sysdeps/powerpc/powerpc64/multiarch/strncmp.c b/sysdeps/powerpc/powerpc64/multiarch/strncmp.c
5de29b
new file mode 100644
5de29b
index 0000000..9829d69
5de29b
--- /dev/null
5de29b
+++ b/sysdeps/powerpc/powerpc64/multiarch/strncmp.c
5de29b
@@ -0,0 +1,37 @@
5de29b
+/* Multiple versions of strncmp.
5de29b
+   Copyright (C) 2013-2014 Free Software Foundation, Inc.
5de29b
+   This file is part of the GNU C Library.
5de29b
+
5de29b
+   The GNU C Library is free software; you can redistribute it and/or
5de29b
+   modify it under the terms of the GNU Lesser General Public
5de29b
+   License as published by the Free Software Foundation; either
5de29b
+   version 2.1 of the License, or (at your option) any later version.
5de29b
+
5de29b
+   The GNU C Library is distributed in the hope that it will be useful,
5de29b
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
5de29b
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
5de29b
+   Lesser General Public License for more details.
5de29b
+
5de29b
+   You should have received a copy of the GNU Lesser General Public
5de29b
+   License along with the GNU C Library; if not, see
5de29b
+   <http://www.gnu.org/licenses/>.  */
5de29b
+
5de29b
+/* Define multiple versions only for definition in libc.  */
5de29b
+#if defined SHARED && !defined NOT_IN_libc
5de29b
+# include <string.h>
5de29b
+# include <shlib-compat.h>
5de29b
+# include "init-arch.h"
5de29b
+
5de29b
+extern __typeof (strncmp) __strncmp_ppc attribute_hidden;
5de29b
+extern __typeof (strncmp) __strncmp_power4 attribute_hidden;
5de29b
+extern __typeof (strncmp) __strncmp_power7 attribute_hidden;
5de29b
+
5de29b
+/* Avoid DWARF definition DIE on ifunc symbol so that GDB can handle
5de29b
+   ifunc symbol properly.  */
5de29b
+libc_ifunc (strncmp,
5de29b
+            (hwcap & PPC_FEATURE_HAS_VSX)
5de29b
+            ? __strncmp_power7 :
5de29b
+	      (hwcap & PPC_FEATURE_POWER4)
5de29b
+		? __strncmp_power4
5de29b
+            : __strncmp_ppc);
5de29b
+#endif
5de29b
-- 
5de29b
1.8.3.1
5de29b