ce426f
From 1a5121cbdc34d9f56bb1bbb3f3ce3a90ddc1ff6b Mon Sep 17 00:00:00 2001
ce426f
From: Rajalakshmi Srinivasaraghavan <raji@linux.vnet.ibm.com>
ce426f
Date: Wed, 30 Jul 2014 05:55:13 -0500
ce426f
Subject: [PATCH] PowerPC: multiarch strchr for PowerPC64
ce426f
ce426f
commit 372dc060e0a25044ba5a797c71fb0ee53921fe47
ce426f
Author: Adhemerval Zanella <azanella@linux.vnet.ibm.com>
ce426f
Date:   Fri Dec 13 14:49:54 2013 -0500
ce426f
---
ce426f
 sysdeps/powerpc/powerpc64/multiarch/Makefile       |  2 +-
ce426f
 .../powerpc/powerpc64/multiarch/ifunc-impl-list.c  |  8 +++++
ce426f
 sysdeps/powerpc/powerpc64/multiarch/rtld-strchr.S  | 18 ++++++++++
ce426f
 .../powerpc/powerpc64/multiarch/strchr-power7.S    | 38 ++++++++++++++++++++
ce426f
 sysdeps/powerpc/powerpc64/multiarch/strchr-ppc64.S | 41 ++++++++++++++++++++++
ce426f
 sysdeps/powerpc/powerpc64/multiarch/strchr.c       | 35 ++++++++++++++++++
ce426f
 6 files changed, 141 insertions(+), 1 deletion(-)
ce426f
 create mode 100644 sysdeps/powerpc/powerpc64/multiarch/rtld-strchr.S
ce426f
 create mode 100644 sysdeps/powerpc/powerpc64/multiarch/strchr-power7.S
ce426f
 create mode 100644 sysdeps/powerpc/powerpc64/multiarch/strchr-ppc64.S
ce426f
 create mode 100644 sysdeps/powerpc/powerpc64/multiarch/strchr.c
ce426f
ce426f
diff --git glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/Makefile glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/Makefile
ce426f
index 22baf1c..f7c5853 100644
ce426f
--- glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/Makefile
ce426f
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/Makefile
ce426f
@@ -8,7 +8,7 @@ sysdep_routines += memcpy-power7 memcpy-a2 memcpy-power6 memcpy-cell \
ce426f
                   rawmemchr-ppc64 strlen-power7 strlen-ppc64 strnlen-power7 \
ce426f
                   strnlen-ppc64 strcasecmp-power7 strcasecmp_l-power7 \
ce426f
                   strncase-power7 strncase_l-power7 strncmp-power7 \
ce426f
-                  strncmp-power4 strncmp-ppc64
ce426f
+                  strncmp-power4 strncmp-ppc64 strchr-power7 strchr-ppc64
ce426f
 
ce426f
 CFLAGS-strncase-power7.c += -mcpu=power7 -funroll-loops
ce426f
 CFLAGS-strncase_l-power7.c += -mcpu=power7 -funroll-loops
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 67f75a5..3b005ea 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
@@ -86,6 +86,14 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
ce426f
                              __strncmp_power4)
ce426f
              IFUNC_IMPL_ADD (array, i, strncmp, 1,
ce426f
                              __strncmp_ppc))
ce426f
+
ce426f
+  /* Support sysdeps/powerpc/powerpc64/multiarch/strchr.c.  */
ce426f
+  IFUNC_IMPL (i, name, strchr,
ce426f
+             IFUNC_IMPL_ADD (array, i, strchr,
ce426f
+                             hwcap & PPC_FEATURE_HAS_VSX,
ce426f
+                             __strchr_power7)
ce426f
+             IFUNC_IMPL_ADD (array, i, strchr, 1,
ce426f
+                             __strchr_ppc))
ce426f
 #endif
ce426f
 
ce426f
   /* Support sysdeps/powerpc/powerpc64/multiarch/memcmp.c.  */
ce426f
diff --git glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/rtld-strchr.S glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/rtld-strchr.S
ce426f
new file mode 100644
ce426f
index 0000000..5c62657
ce426f
--- /dev/null
ce426f
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/rtld-strchr.S
ce426f
@@ -0,0 +1,18 @@
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/powerpc64/strchr.S>
ce426f
diff --git glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/strchr-power7.S glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/strchr-power7.S
ce426f
new file mode 100644
ce426f
index 0000000..0b2ca42
ce426f
--- /dev/null
ce426f
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/strchr-power7.S
ce426f
@@ -0,0 +1,38 @@
ce426f
+/* Optimized strchr implementation for 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 ENTRY
ce426f
+#define ENTRY(name)						\
ce426f
+  .section ".text";						\
ce426f
+  ENTRY_2(__strchr_power7)					\
ce426f
+  .align ALIGNARG(2);						\
ce426f
+  BODY_LABEL(__strchr_power7):					\
ce426f
+  cfi_startproc;
ce426f
+
ce426f
+#undef END
ce426f
+#define END(name)						\
ce426f
+  cfi_endproc;							\
ce426f
+  TRACEBACK(__strchr_power7)					\
ce426f
+  END_2(__strchr_power7)
ce426f
+
ce426f
+#undef libc_hidden_builtin_def
ce426f
+#define libc_hidden_builtin_def(name)
ce426f
+
ce426f
+#include <sysdeps/powerpc/powerpc64/power7/strchr.S>
ce426f
diff --git glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/strchr-ppc64.S glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/strchr-ppc64.S
ce426f
new file mode 100644
ce426f
index 0000000..ded9284
ce426f
--- /dev/null
ce426f
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/strchr-ppc64.S
ce426f
@@ -0,0 +1,41 @@
ce426f
+/* PowerPC64 default implementation of strchr.
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
+#ifdef SHARED
ce426f
+# undef ENTRY
ce426f
+# define ENTRY(name)						\
ce426f
+  .section ".text";						\
ce426f
+  ENTRY_2(__strchr_ppc)						\
ce426f
+  .align ALIGNARG(2);						\
ce426f
+  BODY_LABEL(__strchr_ppc):					\
ce426f
+  cfi_startproc;
ce426f
+
ce426f
+# undef END
ce426f
+# define END(name)						\
ce426f
+  cfi_endproc;							\
ce426f
+  TRACEBACK(__strchr_ppc)					\
ce426f
+  END_2(__strchr_ppc)
ce426f
+
ce426f
+# undef libc_hidden_builtin_def
ce426f
+# define libc_hidden_builtin_def(name)				\
ce426f
+    .globl __GI_strchr; __GI_strchr = __strchr_ppc
ce426f
+#endif
ce426f
+
ce426f
+#include <sysdeps/powerpc/powerpc64/strchr.S>
ce426f
diff --git glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/strchr.c glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/strchr.c
ce426f
new file mode 100644
ce426f
index 0000000..74a9d54
ce426f
--- /dev/null
ce426f
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/strchr.c
ce426f
@@ -0,0 +1,35 @@
ce426f
+/* Multiple versions of strchr.
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 multiple versions only for definition in libc.  */
ce426f
+#if defined SHARED && !defined NOT_IN_libc
ce426f
+# include <string.h>
ce426f
+# include <shlib-compat.h>
ce426f
+# include "init-arch.h"
ce426f
+
ce426f
+extern __typeof (strchr) __strchr_ppc attribute_hidden;
ce426f
+extern __typeof (strchr) __strchr_power7 attribute_hidden;
ce426f
+
ce426f
+/* Avoid DWARF definition DIE on ifunc symbol so that GDB can handle
ce426f
+   ifunc symbol properly.  */
ce426f
+libc_ifunc (strchr,
ce426f
+	    (hwcap & PPC_FEATURE_HAS_VSX)
ce426f
+            ? __strchr_power7
ce426f
+            : __strchr_ppc);
ce426f
+weak_alias (strchr, index)
ce426f
+#endif
ce426f
-- 
ce426f
1.8.3.1
ce426f