ce426f
From 09f1f5cc860480fd09383bca00eb71e0f71aae79 Mon Sep 17 00:00:00 2001
ce426f
From: Rajalakshmi Srinivasaraghavan <raji@linux.vnet.ibm.com>
ce426f
Date: Wed, 30 Jul 2014 05:17:26 -0500
ce426f
Subject: [PATCH] PowerPC: multiarch mempcpy for PowerPC64
ce426f
ce426f
commit f00be62b08c1440800898339f74fb4db20b19eef
ce426f
Author: Adhemerval Zanella <azanella@linux.vnet.ibm.com>
ce426f
Date:   Fri Dec 13 14:34:06 2013 -0500
ce426f
ce426f
Added sysdeps/powerpc/powerpc32/power4/multiarch/mempcpy-ppc32.c  and
ce426f
string/mempcpy.c apart from original commit.
ce426f
---
ce426f
 string/mempcpy.c                                   |  9 ++---
ce426f
 .../powerpc32/power4/multiarch/mempcpy-ppc32.c     | 32 +++++++++++++++++
ce426f
 sysdeps/powerpc/powerpc64/multiarch/Makefile       |  3 +-
ce426f
 .../powerpc/powerpc64/multiarch/ifunc-impl-list.c  |  8 +++++
ce426f
 .../powerpc/powerpc64/multiarch/mempcpy-power7.S   | 41 ++++++++++++++++++++++
ce426f
 .../powerpc/powerpc64/multiarch/mempcpy-ppc64.c    | 19 ++++++++++
ce426f
 sysdeps/powerpc/powerpc64/multiarch/mempcpy.c      | 38 ++++++++++++++++++++
ce426f
 7 files changed, 145 insertions(+), 5 deletions(-)
ce426f
 create mode 100644 sysdeps/powerpc/powerpc32/power4/multiarch/mempcpy-ppc32.c
ce426f
 create mode 100644 sysdeps/powerpc/powerpc64/multiarch/mempcpy-power7.S
ce426f
 create mode 100644 sysdeps/powerpc/powerpc64/multiarch/mempcpy-ppc64.c
ce426f
 create mode 100644 sysdeps/powerpc/powerpc64/multiarch/mempcpy.c
ce426f
ce426f
diff --git glibc-2.17-c758a686/string/mempcpy.c glibc-2.17-c758a686/string/mempcpy.c
ce426f
index 2a542e3..7509c24 100644
ce426f
--- glibc-2.17-c758a686/string/mempcpy.c
ce426f
+++ glibc-2.17-c758a686/string/mempcpy.c
ce426f
@@ -26,11 +26,12 @@
ce426f
 #undef mempcpy
ce426f
 #undef __mempcpy
ce426f
 
ce426f
+#ifndef MEMPCPY
ce426f
+# define MEMPCPY __mempcpy
ce426f
+#endif
ce426f
+
ce426f
 void *
ce426f
-__mempcpy (dstpp, srcpp, len)
ce426f
-     void *dstpp;
ce426f
-     const void *srcpp;
ce426f
-     size_t len;
ce426f
+MEMPCPY (void *dstpp, const void *srcpp, size_t len)
ce426f
 {
ce426f
   unsigned long int dstp = (long int) dstpp;
ce426f
   unsigned long int srcp = (long int) srcpp;
ce426f
diff --git glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/power4/multiarch/mempcpy-ppc32.c glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/power4/multiarch/mempcpy-ppc32.c
ce426f
new file mode 100644
ce426f
index 0000000..8dc77e9
ce426f
--- /dev/null
ce426f
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/power4/multiarch/mempcpy-ppc32.c
ce426f
@@ -0,0 +1,32 @@
ce426f
+/* PowerPC32 default implementation of mempcpy.
ce426f
+   Copyright (C) 2013-2014 Free Software Foundation, Inc.
ce426f
+   This file is part of the GNU C Library.
ce426f
+
ce426f
+   The GNU C Library is free software; you can redistribute it and/or
ce426f
+   modify it under the terms of the GNU Lesser General Public
ce426f
+   License as published by the Free Software Foundation; either
ce426f
+   version 2.1 of the License, or (at your option) any later version.
ce426f
+
ce426f
+   The GNU C Library is distributed in the hope that it will be useful,
ce426f
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
ce426f
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
ce426f
+   Lesser General Public License for more details.
ce426f
+
ce426f
+   You should have received a copy of the GNU Lesser General Public
ce426f
+   License along with the GNU C Library; if not, see
ce426f
+   <http://www.gnu.org/licenses/>.  */
ce426f
+
ce426f
+#define MEMPCPY  __mempcpy_ppc
ce426f
+
ce426f
+#undef libc_hidden_def
ce426f
+#define libc_hidden_def(name)
ce426f
+#undef weak_alias
ce426f
+#define weak_alias(a, b)
ce426f
+
ce426f
+#if defined SHARED
ce426f
+# undef libc_hidden_builtin_def
ce426f
+# define libc_hidden_builtin_def(name)  \
ce426f
+  __hidden_ver1 (__mempcpy_ppc, __GI_mempcpy, __mempcpy_ppc);
ce426f
+#endif
ce426f
+
ce426f
+#include <string/mempcpy.c>
ce426f
diff --git glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/Makefile glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/Makefile
ce426f
index 424d2cd..22560e8 100644
ce426f
--- glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/Makefile
ce426f
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/Makefile
ce426f
@@ -2,5 +2,6 @@ ifeq ($(subdir),string)
ce426f
 sysdep_routines += memcpy-power7 memcpy-a2 memcpy-power6 memcpy-cell \
ce426f
                   memcpy-power4 memcpy-ppc64 memcmp-power7 memcmp-power4 \
ce426f
                   memcmp-ppc64 memset-power7 memset-power6 memset-power4 \
ce426f
-                  memset-ppc64 bzero-power4 bzero-power6 bzero-power7
ce426f
+                  memset-ppc64 bzero-power4 bzero-power6 bzero-power7 \
ce426f
+                  mempcpy-power7 mempcpy-ppc64
ce426f
 endif
ce426f
diff --git glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
ce426f
index 11e7063..c72c229 100644
ce426f
--- glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
ce426f
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
ce426f
@@ -90,5 +90,13 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
ce426f
                              __bzero_power4)
ce426f
              IFUNC_IMPL_ADD (array, i, bzero, 1, __bzero_ppc))
ce426f
 
ce426f
+  /* Support sysdeps/powerpc/powerpc64/multiarch/mempcpy.c.  */
ce426f
+  IFUNC_IMPL (i, name, mempcpy,
ce426f
+             IFUNC_IMPL_ADD (array, i, mempcpy,
ce426f
+                             hwcap & PPC_FEATURE_HAS_VSX,
ce426f
+                             __mempcpy_power7)
ce426f
+             IFUNC_IMPL_ADD (array, i, mempcpy, 1,
ce426f
+                             __mempcpy_ppc))
ce426f
+
ce426f
   return i;
ce426f
 }
ce426f
diff --git glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/mempcpy-power7.S glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/mempcpy-power7.S
ce426f
new file mode 100644
ce426f
index 0000000..6a79847
ce426f
--- /dev/null
ce426f
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/mempcpy-power7.S
ce426f
@@ -0,0 +1,41 @@
ce426f
+/* Optimized mempcpy implementation for PowerPC/POWER7.
ce426f
+   Copyright (C) 2013-2014 Free Software Foundation, Inc.
ce426f
+   This file is part of the GNU C Library.
ce426f
+
ce426f
+   The GNU C Library is free software; you can redistribute it and/or
ce426f
+   modify it under the terms of the GNU Lesser General Public
ce426f
+   License as published by the Free Software Foundation; either
ce426f
+   version 2.1 of the License, or (at your option) any later version.
ce426f
+
ce426f
+   The GNU C Library is distributed in the hope that it will be useful,
ce426f
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
ce426f
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
ce426f
+   Lesser General Public License for more details.
ce426f
+
ce426f
+   You should have received a copy of the GNU Lesser General Public
ce426f
+   License along with the GNU C Library; if not, see
ce426f
+   <http://www.gnu.org/licenses/>.  */
ce426f
+
ce426f
+#include <sysdep.h>
ce426f
+
ce426f
+#undef EALIGN
ce426f
+#define EALIGN(name, alignt, words)				\
ce426f
+  .section ".text";						\
ce426f
+  ENTRY_2(__mempcpy_power7)					\
ce426f
+  .align ALIGNARG(alignt);					\
ce426f
+  EALIGN_W_##words;						\
ce426f
+  BODY_LABEL(__mempcpy_power7):					\
ce426f
+  cfi_startproc;
ce426f
+
ce426f
+#undef END_GEN_TB
ce426f
+#define END_GEN_TB(name, mask)					\
ce426f
+  cfi_endproc;							\
ce426f
+  TRACEBACK_MASK(__mempcpy_power7,mask)				\
ce426f
+  END_2(__mempcpy_power7)
ce426f
+
ce426f
+#undef libc_hidden_builtin_def
ce426f
+#define libc_hidden_builtin_def(name)
ce426f
+#undef weak_alias
ce426f
+#define weak_alias(name, alias)
ce426f
+
ce426f
+#include <sysdeps/powerpc/powerpc64/power7/mempcpy.S>
ce426f
diff --git glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/mempcpy-ppc64.c glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/mempcpy-ppc64.c
ce426f
new file mode 100644
ce426f
index 0000000..78260bb
ce426f
--- /dev/null
ce426f
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/mempcpy-ppc64.c
ce426f
@@ -0,0 +1,19 @@
ce426f
+/* PowerPC64 default implementation of mempcpy.
ce426f
+   Copyright (C) 2013-2014 Free Software Foundation, Inc.
ce426f
+   This file is part of the GNU C Library.
ce426f
+
ce426f
+   The GNU C Library is free software; you can redistribute it and/or
ce426f
+   modify it under the terms of the GNU Lesser General Public
ce426f
+   License as published by the Free Software Foundation; either
ce426f
+   version 2.1 of the License, or (at your option) any later version.
ce426f
+
ce426f
+   The GNU C Library is distributed in the hope that it will be useful,
ce426f
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
ce426f
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
ce426f
+   Lesser General Public License for more details.
ce426f
+
ce426f
+   You should have received a copy of the GNU Lesser General Public
ce426f
+   License along with the GNU C Library; if not, see
ce426f
+   <http://www.gnu.org/licenses/>.  */
ce426f
+
ce426f
+#include <sysdeps/powerpc/powerpc32/power4/multiarch/mempcpy-ppc32.c>
ce426f
diff --git glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/mempcpy.c glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/mempcpy.c
ce426f
new file mode 100644
ce426f
index 0000000..38fbcc3
ce426f
--- /dev/null
ce426f
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/mempcpy.c
ce426f
@@ -0,0 +1,38 @@
ce426f
+/* Multiple versions of mempcpy.
ce426f
+   Copyright (C) 2013-2014 Free Software Foundation, Inc.
ce426f
+   This file is part of the GNU C Library.
ce426f
+
ce426f
+   The GNU C Library is free software; you can redistribute it and/or
ce426f
+   modify it under the terms of the GNU Lesser General Public
ce426f
+   License as published by the Free Software Foundation; either
ce426f
+   version 2.1 of the License, or (at your option) any later version.
ce426f
+
ce426f
+   The GNU C Library is distributed in the hope that it will be useful,
ce426f
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
ce426f
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
ce426f
+   Lesser General Public License for more details.
ce426f
+
ce426f
+   You should have received a copy of the GNU Lesser General Public
ce426f
+   License along with the GNU C Library; if not, see
ce426f
+   <http://www.gnu.org/licenses/>.  */
ce426f
+
ce426f
+#ifndef NOT_IN_libc
ce426f
+# include <string.h>
ce426f
+# include <shlib-compat.h>
ce426f
+# include "init-arch.h"
ce426f
+
ce426f
+extern __typeof (__mempcpy) __mempcpy_ppc attribute_hidden;
ce426f
+extern __typeof (__mempcpy) __mempcpy_power7 attribute_hidden;
ce426f
+
ce426f
+/* Avoid DWARF definition DIE on ifunc symbol so that GDB can handle
ce426f
+   ifunc symbol properly.  */
ce426f
+libc_ifunc (__mempcpy,
ce426f
+	    (hwcap & PPC_FEATURE_HAS_VSX)
ce426f
+            ? __mempcpy_power7
ce426f
+            : __mempcpy_ppc);
ce426f
+
ce426f
+weak_alias (__mempcpy, mempcpy)
ce426f
+libc_hidden_def (mempcpy)
ce426f
+#else
ce426f
+# include <string/mempcpy.c>
ce426f
+#endif
ce426f
-- 
ce426f
1.8.3.1
ce426f