5de29b
From 942cdf02caef0ea4fe257cf5898754b9b1897c4a Mon Sep 17 00:00:00 2001
5de29b
From: Rajalakshmi Srinivasaraghavan <raji@linux.vnet.ibm.com>
5de29b
Date: Wed, 30 Jul 2014 05:58:14 -0500
5de29b
Subject: [PATCH] PowerPC: multiarch strchrnul for PowerPC64
5de29b
5de29b
commit 9ee2969b057862443b81789b56a61514edf34779
5de29b
Author: Adhemerval Zanella <azanella@linux.vnet.ibm.com>
5de29b
Date:   Fri Dec 13 14:50:26 2013 -0500
5de29b
5de29b
Added sysdeps/powerpc/powerpc32/power4/multiarch/strchrnul-ppc32.c and
5de29b
string/strchrnul.c apart from original commit.
5de29b
---
5de29b
 string/strchrnul.c                                 |  6 +++-
5de29b
 .../powerpc32/power4/multiarch/strchrnul-ppc32.c   | 28 ++++++++++++++++
5de29b
 sysdeps/powerpc/powerpc64/multiarch/Makefile       |  3 +-
5de29b
 .../powerpc/powerpc64/multiarch/ifunc-impl-list.c  |  8 +++++
5de29b
 .../powerpc/powerpc64/multiarch/strchrnul-power7.S | 38 ++++++++++++++++++++++
5de29b
 .../powerpc/powerpc64/multiarch/strchrnul-ppc64.c  | 19 +++++++++++
5de29b
 sysdeps/powerpc/powerpc64/multiarch/strchrnul.c    | 37 +++++++++++++++++++++
5de29b
 7 files changed, 137 insertions(+), 2 deletions(-)
5de29b
 create mode 100644 sysdeps/powerpc/powerpc32/power4/multiarch/strchrnul-ppc32.c
5de29b
 create mode 100644 sysdeps/powerpc/powerpc64/multiarch/strchrnul-power7.S
5de29b
 create mode 100644 sysdeps/powerpc/powerpc64/multiarch/strchrnul-ppc64.c
5de29b
 create mode 100644 sysdeps/powerpc/powerpc64/multiarch/strchrnul.c
5de29b
12745e
diff --git glibc-2.17-c758a686/string/strchrnul.c glibc-2.17-c758a686/string/strchrnul.c
5de29b
index 0db5e23..39540a3 100644
12745e
--- glibc-2.17-c758a686/string/strchrnul.c
12745e
+++ glibc-2.17-c758a686/string/strchrnul.c
5de29b
@@ -27,9 +27,13 @@
5de29b
 #undef __strchrnul
5de29b
 #undef strchrnul
5de29b
 
5de29b
+#ifndef STRCHRNUL
5de29b
+# define STRCHRNUL __strchrnul
5de29b
+#endif
5de29b
+
5de29b
 /* Find the first occurrence of C in S or the final NUL byte.  */
5de29b
 char *
5de29b
-__strchrnul (s, c_in)
5de29b
+STRCHRNUL (s, c_in)
5de29b
      const char *s;
5de29b
      int c_in;
5de29b
 {
12745e
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
5de29b
new file mode 100644
5de29b
index 0000000..950643a
5de29b
--- /dev/null
12745e
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/power4/multiarch/strchrnul-ppc32.c
5de29b
@@ -0,0 +1,28 @@
5de29b
+/* PowerPC32 default implementation of strchrnul.
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 STRCHRNUL  __strchrnul_ppc
5de29b
+
5de29b
+#undef weak_alias
5de29b
+#define weak_alias(a,b )
5de29b
+
5de29b
+extern __typeof (strchrnul) __strchrnul_ppc attribute_hidden;
5de29b
+
5de29b
+#include <string/strchrnul.c>
12745e
diff --git glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/Makefile glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/Makefile
5de29b
index f7c5853..15b86bd 100644
12745e
--- glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/Makefile
12745e
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/Makefile
5de29b
@@ -8,7 +8,8 @@ sysdep_routines += memcpy-power7 memcpy-a2 memcpy-power6 memcpy-cell \
5de29b
                   rawmemchr-ppc64 strlen-power7 strlen-ppc64 strnlen-power7 \
5de29b
                   strnlen-ppc64 strcasecmp-power7 strcasecmp_l-power7 \
5de29b
                   strncase-power7 strncase_l-power7 strncmp-power7 \
5de29b
-                  strncmp-power4 strncmp-ppc64 strchr-power7 strchr-ppc64
5de29b
+                  strncmp-power4 strncmp-ppc64 strchr-power7 strchr-ppc64 \
5de29b
+                  strchrnul-power7 strchrnul-ppc64
5de29b
 
5de29b
 CFLAGS-strncase-power7.c += -mcpu=power7 -funroll-loops
5de29b
 CFLAGS-strncase_l-power7.c += -mcpu=power7 -funroll-loops
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 3b005ea..9e3b89d 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
@@ -94,6 +94,14 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
5de29b
                              __strchr_power7)
5de29b
              IFUNC_IMPL_ADD (array, i, strchr, 1,
5de29b
                              __strchr_ppc))
5de29b
+
5de29b
+  /* Support sysdeps/powerpc/powerpc64/multiarch/strchrnul.c.  */
5de29b
+  IFUNC_IMPL (i, name, strchrnul,
5de29b
+             IFUNC_IMPL_ADD (array, i, strchrnul,
5de29b
+                             hwcap & PPC_FEATURE_HAS_VSX,
5de29b
+                             __strchrnul_power7)
5de29b
+             IFUNC_IMPL_ADD (array, i, strchrnul, 1,
5de29b
+                             __strchrnul_ppc))
5de29b
 #endif
5de29b
 
5de29b
   /* Support sysdeps/powerpc/powerpc64/multiarch/memcmp.c.  */
12745e
diff --git glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/strchrnul-power7.S glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/strchrnul-power7.S
5de29b
new file mode 100644
5de29b
index 0000000..87d7c03
5de29b
--- /dev/null
12745e
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/strchrnul-power7.S
5de29b
@@ -0,0 +1,38 @@
5de29b
+/* Optimized strchrnul implementation for 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(__strchrnul_power7)					\
5de29b
+  .align ALIGNARG(2);						\
5de29b
+  BODY_LABEL(__strchrnul_power7):				\
5de29b
+  cfi_startproc;
5de29b
+
5de29b
+#undef END
5de29b
+#define END(name)						\
5de29b
+  cfi_endproc;							\
5de29b
+  TRACEBACK(__strchrnul_power7)					\
5de29b
+  END_2(__strchrnul_power7)
5de29b
+
5de29b
+#undef libc_hidden_builtin_def
5de29b
+#define libc_hidden_builtin_def(name)
5de29b
+
5de29b
+#include <sysdeps/powerpc/powerpc64/power7/strchrnul.S>
12745e
diff --git glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/strchrnul-ppc64.c glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/strchrnul-ppc64.c
5de29b
new file mode 100644
5de29b
index 0000000..a76b335
5de29b
--- /dev/null
12745e
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/strchrnul-ppc64.c
5de29b
@@ -0,0 +1,19 @@
5de29b
+/* PowerPC64 default implementation of strchrnul.
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/strchrnul-ppc32.c>
12745e
diff --git glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/strchrnul.c glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/strchrnul.c
5de29b
new file mode 100644
5de29b
index 0000000..dab1cbf
5de29b
--- /dev/null
12745e
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/strchrnul.c
5de29b
@@ -0,0 +1,37 @@
5de29b
+/* Multiple versions of strchrnul.
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 (__strchrnul) __strchrnul_ppc attribute_hidden;
5de29b
+extern __typeof (__strchrnul) __strchrnul_power7 attribute_hidden;
5de29b
+
5de29b
+/* Avoid DWARF definition DIE on ifunc symbol so that GDB can handle
5de29b
+   ifunc symbol properly.  */
5de29b
+libc_ifunc (__strchrnul,
5de29b
+	    (hwcap & PPC_FEATURE_HAS_VSX)
5de29b
+            ? __strchrnul_power7
5de29b
+            : __strchrnul_ppc);
5de29b
+
5de29b
+weak_alias (__strchrnul, strchrnul)
5de29b
+#else
5de29b
+#include <string/strchrnul.c>
5de29b
+#endif
5de29b
-- 
5de29b
1.8.3.1
5de29b