00db10
From 942cdf02caef0ea4fe257cf5898754b9b1897c4a Mon Sep 17 00:00:00 2001
00db10
From: Rajalakshmi Srinivasaraghavan <raji@linux.vnet.ibm.com>
00db10
Date: Wed, 30 Jul 2014 05:58:14 -0500
00db10
Subject: [PATCH] PowerPC: multiarch strchrnul for PowerPC64
00db10
00db10
commit 9ee2969b057862443b81789b56a61514edf34779
00db10
Author: Adhemerval Zanella <azanella@linux.vnet.ibm.com>
00db10
Date:   Fri Dec 13 14:50:26 2013 -0500
00db10
00db10
Added sysdeps/powerpc/powerpc32/power4/multiarch/strchrnul-ppc32.c and
00db10
string/strchrnul.c apart from original commit.
00db10
---
00db10
 string/strchrnul.c                                 |  6 +++-
00db10
 .../powerpc32/power4/multiarch/strchrnul-ppc32.c   | 28 ++++++++++++++++
00db10
 sysdeps/powerpc/powerpc64/multiarch/Makefile       |  3 +-
00db10
 .../powerpc/powerpc64/multiarch/ifunc-impl-list.c  |  8 +++++
00db10
 .../powerpc/powerpc64/multiarch/strchrnul-power7.S | 38 ++++++++++++++++++++++
00db10
 .../powerpc/powerpc64/multiarch/strchrnul-ppc64.c  | 19 +++++++++++
00db10
 sysdeps/powerpc/powerpc64/multiarch/strchrnul.c    | 37 +++++++++++++++++++++
00db10
 7 files changed, 137 insertions(+), 2 deletions(-)
00db10
 create mode 100644 sysdeps/powerpc/powerpc32/power4/multiarch/strchrnul-ppc32.c
00db10
 create mode 100644 sysdeps/powerpc/powerpc64/multiarch/strchrnul-power7.S
00db10
 create mode 100644 sysdeps/powerpc/powerpc64/multiarch/strchrnul-ppc64.c
00db10
 create mode 100644 sysdeps/powerpc/powerpc64/multiarch/strchrnul.c
00db10
00db10
diff --git glibc-2.17-c758a686/string/strchrnul.c glibc-2.17-c758a686/string/strchrnul.c
00db10
index 0db5e23..39540a3 100644
00db10
--- glibc-2.17-c758a686/string/strchrnul.c
00db10
+++ glibc-2.17-c758a686/string/strchrnul.c
00db10
@@ -27,9 +27,13 @@
00db10
 #undef __strchrnul
00db10
 #undef strchrnul
00db10
 
00db10
+#ifndef STRCHRNUL
00db10
+# define STRCHRNUL __strchrnul
00db10
+#endif
00db10
+
00db10
 /* Find the first occurrence of C in S or the final NUL byte.  */
00db10
 char *
00db10
-__strchrnul (s, c_in)
00db10
+STRCHRNUL (s, c_in)
00db10
      const char *s;
00db10
      int c_in;
00db10
 {
00db10
diff --git glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/power4/multiarch/strchrnul-ppc32.c glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/power4/multiarch/strchrnul-ppc32.c
00db10
new file mode 100644
00db10
index 0000000..950643a
00db10
--- /dev/null
00db10
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/power4/multiarch/strchrnul-ppc32.c
00db10
@@ -0,0 +1,28 @@
00db10
+/* PowerPC32 default implementation of strchrnul.
00db10
+   Copyright (C) 2013-2014 Free Software Foundation, Inc.
00db10
+   This file is part of the GNU C Library.
00db10
+
00db10
+   The GNU C Library is free software; you can redistribute it and/or
00db10
+   modify it under the terms of the GNU Lesser General Public
00db10
+   License as published by the Free Software Foundation; either
00db10
+   version 2.1 of the License, or (at your option) any later version.
00db10
+
00db10
+   The GNU C Library is distributed in the hope that it will be useful,
00db10
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
00db10
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00db10
+   Lesser General Public License for more details.
00db10
+
00db10
+   You should have received a copy of the GNU Lesser General Public
00db10
+   License along with the GNU C Library; if not, see
00db10
+   <http://www.gnu.org/licenses/>.  */
00db10
+
00db10
+#include <string.h>
00db10
+
00db10
+#define STRCHRNUL  __strchrnul_ppc
00db10
+
00db10
+#undef weak_alias
00db10
+#define weak_alias(a,b )
00db10
+
00db10
+extern __typeof (strchrnul) __strchrnul_ppc attribute_hidden;
00db10
+
00db10
+#include <string/strchrnul.c>
00db10
diff --git glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/Makefile glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/Makefile
00db10
index f7c5853..15b86bd 100644
00db10
--- glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/Makefile
00db10
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/Makefile
00db10
@@ -8,7 +8,8 @@ sysdep_routines += memcpy-power7 memcpy-a2 memcpy-power6 memcpy-cell \
00db10
                   rawmemchr-ppc64 strlen-power7 strlen-ppc64 strnlen-power7 \
00db10
                   strnlen-ppc64 strcasecmp-power7 strcasecmp_l-power7 \
00db10
                   strncase-power7 strncase_l-power7 strncmp-power7 \
00db10
-                  strncmp-power4 strncmp-ppc64 strchr-power7 strchr-ppc64
00db10
+                  strncmp-power4 strncmp-ppc64 strchr-power7 strchr-ppc64 \
00db10
+                  strchrnul-power7 strchrnul-ppc64
00db10
 
00db10
 CFLAGS-strncase-power7.c += -mcpu=power7 -funroll-loops
00db10
 CFLAGS-strncase_l-power7.c += -mcpu=power7 -funroll-loops
00db10
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
00db10
index 3b005ea..9e3b89d 100644
00db10
--- glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
00db10
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
00db10
@@ -94,6 +94,14 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
00db10
                              __strchr_power7)
00db10
              IFUNC_IMPL_ADD (array, i, strchr, 1,
00db10
                              __strchr_ppc))
00db10
+
00db10
+  /* Support sysdeps/powerpc/powerpc64/multiarch/strchrnul.c.  */
00db10
+  IFUNC_IMPL (i, name, strchrnul,
00db10
+             IFUNC_IMPL_ADD (array, i, strchrnul,
00db10
+                             hwcap & PPC_FEATURE_HAS_VSX,
00db10
+                             __strchrnul_power7)
00db10
+             IFUNC_IMPL_ADD (array, i, strchrnul, 1,
00db10
+                             __strchrnul_ppc))
00db10
 #endif
00db10
 
00db10
   /* Support sysdeps/powerpc/powerpc64/multiarch/memcmp.c.  */
00db10
diff --git glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/strchrnul-power7.S glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/strchrnul-power7.S
00db10
new file mode 100644
00db10
index 0000000..87d7c03
00db10
--- /dev/null
00db10
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/strchrnul-power7.S
00db10
@@ -0,0 +1,38 @@
00db10
+/* Optimized strchrnul implementation for POWER7.
00db10
+   Copyright (C) 2013-2014 Free Software Foundation, Inc.
00db10
+   This file is part of the GNU C Library.
00db10
+
00db10
+   The GNU C Library is free software; you can redistribute it and/or
00db10
+   modify it under the terms of the GNU Lesser General Public
00db10
+   License as published by the Free Software Foundation; either
00db10
+   version 2.1 of the License, or (at your option) any later version.
00db10
+
00db10
+   The GNU C Library is distributed in the hope that it will be useful,
00db10
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
00db10
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00db10
+   Lesser General Public License for more details.
00db10
+
00db10
+   You should have received a copy of the GNU Lesser General Public
00db10
+   License along with the GNU C Library; if not, see
00db10
+   <http://www.gnu.org/licenses/>.  */
00db10
+
00db10
+#include <sysdep.h>
00db10
+
00db10
+#undef ENTRY
00db10
+#define ENTRY(name)						\
00db10
+  .section ".text";						\
00db10
+  ENTRY_2(__strchrnul_power7)					\
00db10
+  .align ALIGNARG(2);						\
00db10
+  BODY_LABEL(__strchrnul_power7):				\
00db10
+  cfi_startproc;
00db10
+
00db10
+#undef END
00db10
+#define END(name)						\
00db10
+  cfi_endproc;							\
00db10
+  TRACEBACK(__strchrnul_power7)					\
00db10
+  END_2(__strchrnul_power7)
00db10
+
00db10
+#undef libc_hidden_builtin_def
00db10
+#define libc_hidden_builtin_def(name)
00db10
+
00db10
+#include <sysdeps/powerpc/powerpc64/power7/strchrnul.S>
00db10
diff --git glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/strchrnul-ppc64.c glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/strchrnul-ppc64.c
00db10
new file mode 100644
00db10
index 0000000..a76b335
00db10
--- /dev/null
00db10
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/strchrnul-ppc64.c
00db10
@@ -0,0 +1,19 @@
00db10
+/* PowerPC64 default implementation of strchrnul.
00db10
+   Copyright (C) 2013-2014 Free Software Foundation, Inc.
00db10
+   This file is part of the GNU C Library.
00db10
+
00db10
+   The GNU C Library is free software; you can redistribute it and/or
00db10
+   modify it under the terms of the GNU Lesser General Public
00db10
+   License as published by the Free Software Foundation; either
00db10
+   version 2.1 of the License, or (at your option) any later version.
00db10
+
00db10
+   The GNU C Library is distributed in the hope that it will be useful,
00db10
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
00db10
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00db10
+   Lesser General Public License for more details.
00db10
+
00db10
+   You should have received a copy of the GNU Lesser General Public
00db10
+   License along with the GNU C Library; if not, see
00db10
+   <http://www.gnu.org/licenses/>.  */
00db10
+
00db10
+#include <sysdeps/powerpc/powerpc32/power4/multiarch/strchrnul-ppc32.c>
00db10
diff --git glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/strchrnul.c glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/strchrnul.c
00db10
new file mode 100644
00db10
index 0000000..dab1cbf
00db10
--- /dev/null
00db10
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/strchrnul.c
00db10
@@ -0,0 +1,37 @@
00db10
+/* Multiple versions of strchrnul.
00db10
+   Copyright (C) 2013-2014 Free Software Foundation, Inc.
00db10
+   This file is part of the GNU C Library.
00db10
+
00db10
+   The GNU C Library is free software; you can redistribute it and/or
00db10
+   modify it under the terms of the GNU Lesser General Public
00db10
+   License as published by the Free Software Foundation; either
00db10
+   version 2.1 of the License, or (at your option) any later version.
00db10
+
00db10
+   The GNU C Library is distributed in the hope that it will be useful,
00db10
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
00db10
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00db10
+   Lesser General Public License for more details.
00db10
+
00db10
+   You should have received a copy of the GNU Lesser General Public
00db10
+   License along with the GNU C Library; if not, see
00db10
+   <http://www.gnu.org/licenses/>.  */
00db10
+
00db10
+#ifndef NOT_IN_libc
00db10
+# include <string.h>
00db10
+# include <shlib-compat.h>
00db10
+# include "init-arch.h"
00db10
+
00db10
+extern __typeof (__strchrnul) __strchrnul_ppc attribute_hidden;
00db10
+extern __typeof (__strchrnul) __strchrnul_power7 attribute_hidden;
00db10
+
00db10
+/* Avoid DWARF definition DIE on ifunc symbol so that GDB can handle
00db10
+   ifunc symbol properly.  */
00db10
+libc_ifunc (__strchrnul,
00db10
+	    (hwcap & PPC_FEATURE_HAS_VSX)
00db10
+            ? __strchrnul_power7
00db10
+            : __strchrnul_ppc);
00db10
+
00db10
+weak_alias (__strchrnul, strchrnul)
00db10
+#else
00db10
+#include <string/strchrnul.c>
00db10
+#endif
00db10
-- 
00db10
1.8.3.1
00db10