5de29b
From c59b219a7fb36564572a864bd61a5cdc7e37f25b Mon Sep 17 00:00:00 2001
5de29b
From: Rajalakshmi Srinivasaraghavan <raji@linux.vnet.ibm.com>
5de29b
Date: Wed, 30 Jul 2014 05:35:32 -0500
5de29b
Subject: [PATCH] PowerPC: multiarch rawmemchr for PowerPC64
5de29b
5de29b
commit 1fd005ad2f8ca30d44d5bfa036422b4ec281ea4a
5de29b
Author: Adhemerval Zanella <azanella@linux.vnet.ibm.com>
5de29b
Date:   Fri Dec 13 14:37:26 2013 -0500
5de29b
5de29b
Added sysdeps/powerpc/powerpc32/power4/multiarch/rawmemchr-ppc32.c and
5de29b
string/rawmemchr.c apart from original commit.
5de29b
---
5de29b
 string/rawmemchr.c                                 |  5 ++-
5de29b
 .../powerpc32/power4/multiarch/rawmemchr-ppc32.c   | 32 +++++++++++++++++++
5de29b
 sysdeps/powerpc/powerpc64/multiarch/Makefile       |  3 +-
5de29b
 .../powerpc/powerpc64/multiarch/ifunc-impl-list.c  |  8 +++++
5de29b
 .../powerpc/powerpc64/multiarch/rawmemchr-power7.S | 35 ++++++++++++++++++++
5de29b
 .../powerpc/powerpc64/multiarch/rawmemchr-ppc64.c  | 19 +++++++++++
5de29b
 sysdeps/powerpc/powerpc64/multiarch/rawmemchr.c    | 37 ++++++++++++++++++++++
5de29b
 7 files changed, 137 insertions(+), 2 deletions(-)
5de29b
 create mode 100644 sysdeps/powerpc/powerpc32/power4/multiarch/rawmemchr-ppc32.c
5de29b
 create mode 100644 sysdeps/powerpc/powerpc64/multiarch/rawmemchr-power7.S
5de29b
 create mode 100644 sysdeps/powerpc/powerpc64/multiarch/rawmemchr-ppc64.c
5de29b
 create mode 100644 sysdeps/powerpc/powerpc64/multiarch/rawmemchr.c
5de29b
12745e
diff --git glibc-2.17-c758a686/string/rawmemchr.c glibc-2.17-c758a686/string/rawmemchr.c
5de29b
index 90e8c7c..0e4f192 100644
12745e
--- glibc-2.17-c758a686/string/rawmemchr.c
12745e
+++ glibc-2.17-c758a686/string/rawmemchr.c
5de29b
@@ -47,10 +47,13 @@
5de29b
 
5de29b
 #undef memchr
5de29b
 
5de29b
+#ifndef RAWMEMCHR
5de29b
+# define RAWMEMCHR __rawmemchr
5de29b
+#endif
5de29b
 
5de29b
 /* Find the first occurrence of C in S.  */
5de29b
 __ptr_t
5de29b
-__rawmemchr (s, c_in)
5de29b
+RAWMEMCHR (s, c_in)
5de29b
      const __ptr_t s;
5de29b
      int c_in;
5de29b
 {
12745e
diff --git glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/power4/multiarch/rawmemchr-ppc32.c glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/power4/multiarch/rawmemchr-ppc32.c
5de29b
new file mode 100644
5de29b
index 0000000..2e8abaa
5de29b
--- /dev/null
12745e
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/power4/multiarch/rawmemchr-ppc32.c
5de29b
@@ -0,0 +1,32 @@
5de29b
+/* PowerPC32 default implementation of rawmemchr.
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 <string.h>
5de29b
+
5de29b
+#define RAWMEMCHR  __rawmemchr_ppc
5de29b
+#undef weak_alias
5de29b
+#define weak_alias(a, b)
5de29b
+#ifdef SHARED
5de29b
+# undef libc_hidden_def
5de29b
+# define libc_hidden_def(name)  \
5de29b
+  __hidden_ver1 (__rawmemchr_ppc, __GI___rawmemchr, __rawmemchr_ppc);
5de29b
+#endif
5de29b
+
5de29b
+extern __typeof (rawmemchr) __rawmemchr_ppc attribute_hidden;
5de29b
+
5de29b
+#include <string/rawmemchr.c>
12745e
diff --git glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/Makefile glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/Makefile
5de29b
index db765f2..695112c 100644
12745e
--- glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/Makefile
12745e
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/Makefile
5de29b
@@ -4,5 +4,6 @@ sysdep_routines += memcpy-power7 memcpy-a2 memcpy-power6 memcpy-cell \
5de29b
                   memcmp-ppc64 memset-power7 memset-power6 memset-power4 \
5de29b
                   memset-ppc64 bzero-power4 bzero-power6 bzero-power7 \
5de29b
                   mempcpy-power7 mempcpy-ppc64 memchr-power7 memchr-ppc64 \
5de29b
-                  memrchr-power7 memrchr-ppc64
5de29b
+                  memrchr-power7 memrchr-ppc64 rawmemchr-power7 \
5de29b
+                  rawmemchr-ppc64
5de29b
 endif
12745e
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
5de29b
index a0700dc..5b15c3f 100644
12745e
--- glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
12745e
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
5de29b
@@ -114,5 +114,13 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
5de29b
              IFUNC_IMPL_ADD (array, i, memrchr, 1,
5de29b
                              __memrchr_ppc))
5de29b
 
5de29b
+  /* Support sysdeps/powerpc/powerpc64/multiarch/rawmemchr.c.  */
5de29b
+  IFUNC_IMPL (i, name, rawmemchr,
5de29b
+             IFUNC_IMPL_ADD (array, i, rawmemchr,
5de29b
+                             hwcap & PPC_FEATURE_HAS_VSX,
5de29b
+                             __rawmemchr_power7)
5de29b
+             IFUNC_IMPL_ADD (array, i, rawmemchr, 1,
5de29b
+                             __rawmemchr_ppc))
5de29b
+
5de29b
   return i;
5de29b
 }
12745e
diff --git glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/rawmemchr-power7.S glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/rawmemchr-power7.S
5de29b
new file mode 100644
5de29b
index 0000000..24ae3bf
5de29b
--- /dev/null
12745e
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/rawmemchr-power7.S
5de29b
@@ -0,0 +1,35 @@
5de29b
+/* Optimized rawmemchr implementation for PowerPC64/POWER7.
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 ENTRY
5de29b
+#define ENTRY(name)						\
5de29b
+  .section ".text";						\
5de29b
+  ENTRY_2(__rawmemchr_power7)					\
5de29b
+  .align ALIGNARG(2);						\
5de29b
+  BODY_LABEL(__rawmemchr_power7):				\
5de29b
+  cfi_startproc;
5de29b
+
5de29b
+#undef END
5de29b
+#define END(name)						\
5de29b
+  cfi_endproc;							\
5de29b
+  TRACEBACK(__rawmemchr_power7)					\
5de29b
+  END_2(__rawmemchr_power7)
5de29b
+
5de29b
+#include <sysdeps/powerpc/powerpc64/power7/rawmemchr.S>
12745e
diff --git glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/rawmemchr-ppc64.c glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/rawmemchr-ppc64.c
5de29b
new file mode 100644
5de29b
index 0000000..0f2f202
5de29b
--- /dev/null
12745e
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/rawmemchr-ppc64.c
5de29b
@@ -0,0 +1,19 @@
5de29b
+/* PowerPC64 default implementation of rawmemchr.
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 <sysdeps/powerpc/powerpc32/power4/multiarch/rawmemchr-ppc32.c>
12745e
diff --git glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/rawmemchr.c glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/rawmemchr.c
5de29b
new file mode 100644
5de29b
index 0000000..3f53cd5
5de29b
--- /dev/null
12745e
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/rawmemchr.c
5de29b
@@ -0,0 +1,37 @@
5de29b
+/* Multiple versions of rawmemchr.
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
+#ifndef NOT_IN_libc
5de29b
+# include <string.h>
5de29b
+# include <shlib-compat.h>
5de29b
+# include "init-arch.h"
5de29b
+
5de29b
+extern __typeof (__rawmemchr) __rawmemchr_ppc attribute_hidden;
5de29b
+extern __typeof (__rawmemchr) __rawmemchr_power7 attribute_hidden;
5de29b
+
5de29b
+/* Avoid DWARF definition DIE on ifunc symbol so that GDB can handle
5de29b
+   ifunc symbol properly.  */
5de29b
+libc_ifunc (__rawmemchr,
5de29b
+	    (hwcap & PPC_FEATURE_HAS_VSX)
5de29b
+            ? __rawmemchr_power7
5de29b
+            : __rawmemchr_ppc);
5de29b
+
5de29b
+weak_alias (__rawmemchr, rawmemchr)
5de29b
+#else
5de29b
+#include <string/rawmemchr.c>
5de29b
+#endif
5de29b
-- 
5de29b
1.8.3.1
5de29b