You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

403 lines
16 KiB

From 62edac04130e7d91b0d4872376bdaa976065fd25 Mon Sep 17 00:00:00 2001
From: Rajalakshmi Srinivasaraghavan <raji@linux.vnet.ibm.com>
Date: Wed, 30 Jul 2014 07:40:10 -0500
Subject: [PATCH] PowerPC: multiarch wcsrchr for PowerPC64
commit 7b714620a7146104aaf863ba1dbe386beedbcc0a
Author: Adhemerval Zanella <azanella@linux.vnet.ibm.com>
Date: Fri Dec 13 14:52:48 2013 -0500
Added the following files apart from original commit.
sysdeps/powerpc/powerpc32/power4/multiarch/wcsrchr-power6.c
sysdeps/powerpc/powerpc32/power4/multiarch/wcsrchr-power7.c
sysdeps/powerpc/powerpc32/power4/multiarch/wcsrchr-ppc32.c
sysdeps/powerpc/powerpc64/power6/wcsrchr.c
wcsmbs/wcsrchr.c
---
sysdeps/powerpc/power6/wcsrchr.c | 89 ++++++++++++++++++++++
.../powerpc32/power4/multiarch/wcsrchr-power6.c | 20 +++++
.../powerpc32/power4/multiarch/wcsrchr-power7.c | 20 +++++
.../powerpc32/power4/multiarch/wcsrchr-ppc32.c | 26 +++++++
sysdeps/powerpc/powerpc64/multiarch/Makefile | 5 +-
.../powerpc/powerpc64/multiarch/ifunc-impl-list.c | 11 +++
.../powerpc/powerpc64/multiarch/wcsrchr-power6.c | 19 +++++
.../powerpc/powerpc64/multiarch/wcsrchr-power7.c | 19 +++++
.../powerpc/powerpc64/multiarch/wcsrchr-ppc64.c | 18 +++++
sysdeps/powerpc/powerpc64/multiarch/wcsrchr.c | 36 +++++++++
sysdeps/powerpc/powerpc64/power6/wcsrchr.c | 2 +-
wcsmbs/wcsrchr.c | 5 +-
12 files changed, 267 insertions(+), 3 deletions(-)
create mode 100644 sysdeps/powerpc/power6/wcsrchr.c
create mode 100644 sysdeps/powerpc/powerpc32/power4/multiarch/wcsrchr-power6.c
create mode 100644 sysdeps/powerpc/powerpc32/power4/multiarch/wcsrchr-power7.c
create mode 100644 sysdeps/powerpc/powerpc32/power4/multiarch/wcsrchr-ppc32.c
create mode 100644 sysdeps/powerpc/powerpc64/multiarch/wcsrchr-power6.c
create mode 100644 sysdeps/powerpc/powerpc64/multiarch/wcsrchr-power7.c
create mode 100644 sysdeps/powerpc/powerpc64/multiarch/wcsrchr-ppc64.c
create mode 100644 sysdeps/powerpc/powerpc64/multiarch/wcsrchr.c
diff --git glibc-2.17-c758a686/sysdeps/powerpc/power6/wcsrchr.c glibc-2.17-c758a686/sysdeps/powerpc/power6/wcsrchr.c
new file mode 100644
index 0000000..278d98d
--- /dev/null
+++ glibc-2.17-c758a686/sysdeps/powerpc/power6/wcsrchr.c
@@ -0,0 +1,89 @@
+/* wcsrchr.c - Wide Character Reverse Search for POWER6+.
+ Copyright (C) 2012-2014 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+#include <wchar.h>
+
+#ifndef WCSRCHR
+# define WCSRCHR wcsrchr
+#endif
+
+/* Find the last occurrence of WC in WCS. */
+wchar_t *
+WCSRCHR (const wchar_t *wcs, const wchar_t wc)
+{
+ const wchar_t *wcs2 = wcs + 1;
+ const wchar_t *retval = NULL;
+
+ if (*wcs == wc)
+ retval = wcs;
+
+ if (*wcs == L'\0') return (wchar_t *) retval;
+
+ do
+ {
+ wcs+=2;
+
+ if (*wcs2 == wc)
+ retval = wcs2;
+ if (*wcs2 == L'\0')
+ return (wchar_t *) retval;
+ wcs2+=2;
+
+ if (*wcs == wc)
+ retval = wcs;
+ if (*wcs == L'\0')
+ return (wchar_t *) retval;
+ wcs+=2;
+
+ if (*wcs2 == wc)
+ retval = wcs2;
+ if (*wcs2 == L'\0')
+ return (wchar_t *) retval;
+ wcs2+=2;
+
+ if (*wcs == wc)
+ retval = wcs;
+ if (*wcs == L'\0')
+ return (wchar_t *) retval;
+ wcs+=2;
+
+ if (*wcs2 == wc)
+ retval = wcs2;
+ if (*wcs2 == L'\0')
+ return (wchar_t *) retval;
+ wcs2+=2;
+
+ if (*wcs == wc)
+ retval = wcs;
+ if (*wcs == L'\0')
+ return (wchar_t *) retval;
+ wcs+=2;
+
+ if (*wcs2 == wc)
+ retval = wcs2;
+ if (*wcs2 == L'\0')
+ return (wchar_t *) retval;
+ wcs2+=2;
+
+ if (*wcs == wc)
+ retval = wcs;
+ }
+ while (*wcs != L'\0');
+
+ return (wchar_t *) retval;
+}
diff --git glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/power4/multiarch/wcsrchr-power6.c glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/power4/multiarch/wcsrchr-power6.c
new file mode 100644
index 0000000..bd77eb3
--- /dev/null
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/power4/multiarch/wcsrchr-power6.c
@@ -0,0 +1,20 @@
+/* Copyright (C) 2013-2014 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#define WCSRCHR __wcsrchr_power6
+
+#include <sysdeps/powerpc/power6/wcsrchr.c>
diff --git glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/power4/multiarch/wcsrchr-power7.c glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/power4/multiarch/wcsrchr-power7.c
new file mode 100644
index 0000000..829a434
--- /dev/null
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/power4/multiarch/wcsrchr-power7.c
@@ -0,0 +1,20 @@
+/* Copyright (C) 2013-2014 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#define WCSRCHR __wcsrchr_power7
+
+#include <sysdeps/powerpc/power6/wcsrchr.c>
diff --git glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/power4/multiarch/wcsrchr-ppc32.c glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/power4/multiarch/wcsrchr-ppc32.c
new file mode 100644
index 0000000..9c7fe2d
--- /dev/null
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/power4/multiarch/wcsrchr-ppc32.c
@@ -0,0 +1,26 @@
+/* Copyright (C) 2013-2014 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <wchar.h>
+
+#ifndef NOT_IN_libc
+# define WCSRCHR __wcsrchr_ppc
+#endif
+
+extern __typeof (wcsrchr) __wcsrchr_ppc;
+
+#include <wcsmbs/wcsrchr.c>
diff --git glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/Makefile glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/Makefile
index ff3b8cf..b4504b7 100644
--- glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/Makefile
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/Makefile
@@ -10,10 +10,13 @@ sysdep_routines += memcpy-power7 memcpy-a2 memcpy-power6 memcpy-cell \
strncase-power7 strncase_l-power7 strncmp-power7 \
strncmp-power4 strncmp-ppc64 strchr-power7 strchr-ppc64 \
strchrnul-power7 strchrnul-ppc64 wcschr-power7 \
- wcschr-power6 wcschr-ppc64
+ wcschr-power6 wcschr-ppc64 wcsrchr-power7 wcsrchr-power6 \
+ wcsrchr-ppc64
CFLAGS-strncase-power7.c += -mcpu=power7 -funroll-loops
CFLAGS-strncase_l-power7.c += -mcpu=power7 -funroll-loops
CFLAGS-wcschr-power7.c += -mcpu=power7
CFLAGS-wcschr-power6.c += -mcpu=power6
+CFLAGS-wcsrchr-power7.c += -mcpu=power7
+CFLAGS-wcsrchr-power6.c += -mcpu=power6
endif
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
index cc932c9..6c7422c 100644
--- glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/ifunc-impl-list.c
@@ -202,5 +202,16 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
IFUNC_IMPL_ADD (array, i, wcschr, 1,
__wcschr_ppc))
+ /* Support sysdeps/powerpc/powerpc64/multiarch/wcschr.c. */
+ IFUNC_IMPL (i, name, wcsrchr,
+ IFUNC_IMPL_ADD (array, i, wcsrchr,
+ hwcap & PPC_FEATURE_HAS_VSX,
+ __wcsrchr_power7)
+ IFUNC_IMPL_ADD (array, i, wcsrchr,
+ hwcap & PPC_FEATURE_ARCH_2_05,
+ __wcsrchr_power6)
+ IFUNC_IMPL_ADD (array, i, wcsrchr, 1,
+ __wcsrchr_ppc))
+
return i;
}
diff --git glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/wcsrchr-power6.c glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/wcsrchr-power6.c
new file mode 100644
index 0000000..da6f27b
--- /dev/null
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/wcsrchr-power6.c
@@ -0,0 +1,19 @@
+/* wcsrchr.c - Wide Character Search for powerpc64/power6.
+ Copyright (C) 2013-2014 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+#include <sysdeps/powerpc/powerpc32/power4/multiarch/wcsrchr-power6.c>
diff --git glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/wcsrchr-power7.c glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/wcsrchr-power7.c
new file mode 100644
index 0000000..60f07a8
--- /dev/null
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/wcsrchr-power7.c
@@ -0,0 +1,19 @@
+/* wcsrchr.c - Wide Character Search for powerpc64/power7.
+ Copyright (C) 2013-2014 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If
+ not, see <http://www.gnu.org/licenses/>. */
+
+#include <sysdeps/powerpc/powerpc32/power4/multiarch/wcsrchr-power7.c>
diff --git glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/wcsrchr-ppc64.c glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/wcsrchr-ppc64.c
new file mode 100644
index 0000000..1fff510
--- /dev/null
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/wcsrchr-ppc64.c
@@ -0,0 +1,18 @@
+/* Copyright (C) 2013-2014 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#include <sysdeps/powerpc/powerpc32/power4/multiarch/wcsrchr-ppc32.c>
diff --git glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/wcsrchr.c glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/wcsrchr.c
new file mode 100644
index 0000000..3d0ab42
--- /dev/null
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/multiarch/wcsrchr.c
@@ -0,0 +1,36 @@
+/* Multiple versions of wcsrchr.
+ Copyright (C) 2013-2014 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef NOT_IN_libc
+# include <wchar.h>
+# include <shlib-compat.h>
+# include "init-arch.h"
+
+extern __typeof (wcsrchr) __wcsrchr_ppc attribute_hidden;
+extern __typeof (wcsrchr) __wcsrchr_power6 attribute_hidden;
+extern __typeof (wcsrchr) __wcsrchr_power7 attribute_hidden;
+
+libc_ifunc (wcsrchr,
+ (hwcap & PPC_FEATURE_HAS_VSX)
+ ? __wcsrchr_power7 :
+ (hwcap & PPC_FEATURE_ARCH_2_05)
+ ? __wcsrchr_power6
+ : __wcsrchr_ppc);
+#else
+#include <wcsmbs/wcsrchr.c>
+#endif
diff --git glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/power6/wcsrchr.c glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/power6/wcsrchr.c
index 2327c05..b86472d 100644
--- glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/power6/wcsrchr.c
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/power6/wcsrchr.c
@@ -1 +1 @@
-#include "../../powerpc32/power6/wcsrchr.c"
+#include <sysdeps/powerpc/power6/wcsrchr.c>
diff --git glibc-2.17-c758a686/wcsmbs/wcsrchr.c glibc-2.17-c758a686/wcsmbs/wcsrchr.c
index c1b5a59..27c94c5 100644
--- glibc-2.17-c758a686/wcsmbs/wcsrchr.c
+++ glibc-2.17-c758a686/wcsmbs/wcsrchr.c
@@ -18,10 +18,13 @@
#include <wchar.h>
+#ifndef WCSRCHR
+# define WCSRCHR wcsrchr
+#endif
/* Find the last occurrence of WC in WCS. */
wchar_t *
-wcsrchr (wcs, wc)
+WCSRCHR (wcs, wc)
register const wchar_t *wcs;
register const wchar_t wc;
{
--
1.8.3.1