From 39facb2f8d5e4a5d9ed0ddb45bc4253c518e55a3 Mon Sep 17 00:00:00 2001 From: Adhemerval Zanella Date: Mon, 8 Apr 2013 19:32:56 -0500 Subject: PowerPC: wcschr ifunc for PowerPC32 --- .../powerpc/powerpc32/multiarch/ifunc-impl-list.c | 10 +++ sysdeps/powerpc/powerpc32/multiarch/wcschr-c.c | 14 ++++ .../powerpc/powerpc32/multiarch/wcschr-power6.c | 94 ++++++++++++++++++++++ .../powerpc/powerpc32/multiarch/wcschr-power7.c | 3 + sysdeps/powerpc/powerpc32/multiarch/wcschr.c | 36 +++++++++ sysdeps/powerpc/powerpc32/power6/wcschr.c | 88 -------------------- 6 files changed, 157 insertions(+), 88 deletions(-) create mode 100644 sysdeps/powerpc/powerpc32/multiarch/wcschr-c.c create mode 100644 sysdeps/powerpc/powerpc32/multiarch/wcschr-power6.c create mode 100644 sysdeps/powerpc/powerpc32/multiarch/wcschr-power7.c create mode 100644 sysdeps/powerpc/powerpc32/multiarch/wcschr.c delete mode 100644 sysdeps/powerpc/powerpc32/power6/wcschr.c diff --git a/sysdeps/powerpc/powerpc32/multiarch/ifunc-impl-list.c b/sysdeps/powerpc/powerpc32/multiarch/ifunc-impl-list.c index faeef4a91c..b92152eef4 100644 --- a/sysdeps/powerpc/powerpc32/multiarch/ifunc-impl-list.c +++ b/sysdeps/powerpc/powerpc32/multiarch/ifunc-impl-list.c @@ -155,6 +155,16 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, __strchrnul_power7) IFUNC_IMPL_ADD (array, i, strchrnul, 1, __strchrnul_ppc32)) + + IFUNC_IMPL (i, name, wcschr, + IFUNC_IMPL_ADD (array, i, wcschr, + hwcap & PPC_FEATURE_HAS_VSX, + __wcschr_power7) + IFUNC_IMPL_ADD (array, i, wcschr, + hwcap & PPC_FEATURE_ARCH_2_05, + __wcschr_power6) + IFUNC_IMPL_ADD (array, i, wcschr, 1, + __wcschr_ppc32)) #endif return i; diff --git a/sysdeps/powerpc/powerpc32/multiarch/wcschr-c.c b/sysdeps/powerpc/powerpc32/multiarch/wcschr-c.c new file mode 100644 index 0000000000..19396d5d74 --- /dev/null +++ b/sysdeps/powerpc/powerpc32/multiarch/wcschr-c.c @@ -0,0 +1,14 @@ +#include + +#ifndef NOT_IN_libc +# ifdef SHARED +# undef libc_hidden_def +# define libc_hidden_def(name) \ + __hidden_ver1 (__wcschr_ppc32, __GI_wcschr, __wcschr_ppc32); +# endif +# define WCSCHR __wcschr_ppc32 +#endif + +extern __typeof (wcschr) __wcschr_ppc32; + +#include "wcsmbs/wcschr.c" diff --git a/sysdeps/powerpc/powerpc32/multiarch/wcschr-power6.c b/sysdeps/powerpc/powerpc32/multiarch/wcschr-power6.c new file mode 100644 index 0000000000..e6b81188e4 --- /dev/null +++ b/sysdeps/powerpc/powerpc32/multiarch/wcschr-power6.c @@ -0,0 +1,94 @@ +/* wcschr.c - Wide Character Search for powerpc32/power6. + Copyright (C) 2012-2013 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 . */ + +#include + +#ifdef WCSCHR +# define __wcschr_power6 WCSCHR +#endif +#ifndef WCSCHR_ARCH +# define WCSCHR_ARCH "power6" +#endif + +__typeof (wcschr) __wcschr_power6 + __attribute__ ((__target__ ("cpu=" WCSCHR_ARCH))); + +/* Find the first occurrence of WC in WCS. */ +wchar_t * +__wcschr_power6 (register const wchar_t *wcs, register const wchar_t wc) +{ + register const wchar_t *wcs2 = wcs + 1; + + if (*wcs == wc) + return (wchar_t *) wcs; + if (*wcs == L'\0') + return NULL; + + do + { + wcs += 2; + + if (*wcs2 == wc) + return (wchar_t *) wcs2; + if (*wcs2 == L'\0') + return NULL; + wcs2 += 2; + + if (*wcs == wc) + return (wchar_t *) wcs; + if (*wcs == L'\0') + return NULL; + wcs += 2; + + if (*wcs2 == wc) + return (wchar_t *) wcs2; + if (*wcs2 == L'\0') + return NULL; + wcs2 += 2; + + if (*wcs == wc) + return (wchar_t *) wcs; + if (*wcs == L'\0') + return NULL; + wcs += 2; + + if (*wcs2 == wc) + return (wchar_t *) wcs2; + if (*wcs2 == L'\0') + return NULL; + wcs2 += 2; + + if (*wcs == wc) + return (wchar_t *) wcs; + if (*wcs == L'\0') + return NULL; + wcs += 2; + + if (*wcs2 == wc) + return (wchar_t *) wcs2; + if (*wcs2 == L'\0') + return NULL; + wcs2 += 2; + + if (*wcs == wc) + return (wchar_t *) wcs; + } + while (*wcs != L'\0'); + + return NULL; +} diff --git a/sysdeps/powerpc/powerpc32/multiarch/wcschr-power7.c b/sysdeps/powerpc/powerpc32/multiarch/wcschr-power7.c new file mode 100644 index 0000000000..c573681cce --- /dev/null +++ b/sysdeps/powerpc/powerpc32/multiarch/wcschr-power7.c @@ -0,0 +1,3 @@ +#define WCSCHR __wcschr_power7 +#define WCSCHR_ARCH "power7" +#include diff --git a/sysdeps/powerpc/powerpc32/multiarch/wcschr.c b/sysdeps/powerpc/powerpc32/multiarch/wcschr.c new file mode 100644 index 0000000000..3c3e573798 --- /dev/null +++ b/sysdeps/powerpc/powerpc32/multiarch/wcschr.c @@ -0,0 +1,36 @@ +/* Multiple versions of wcschr + Copyright (C) 2013 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 + . */ + +#ifndef NOT_IN_libc +# include +# include +# include "init-arch.h" + +extern __typeof (wcschr) __wcschr_ppc32 attribute_hidden; +extern __typeof (wcschr) __wcschr_power6 attribute_hidden; +extern __typeof (wcschr) __wcschr_power7 attribute_hidden; + +libc_ifunc (wcschr, + (hwcap & PPC_FEATURE_HAS_VSX) + ? __wcschr_power7 : + (hwcap & PPC_FEATURE_ARCH_2_05) + ? __wcschr_power6 + : __wcschr_ppc32); +#else +#include "wcsmbs/wcschr.c" +#endif diff --git a/sysdeps/powerpc/powerpc32/power6/wcschr.c b/sysdeps/powerpc/powerpc32/power6/wcschr.c deleted file mode 100644 index a989877bb8..0000000000 --- a/sysdeps/powerpc/powerpc32/power6/wcschr.c +++ /dev/null @@ -1,88 +0,0 @@ -/* wcschr.c - Wide Character Search for powerpc32/power6. - Copyright (C) 2012-2013 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 . */ - -#include - - -/* Find the first occurrence of WC in WCS. */ -wchar_t * -wcschr (wcs, wc) - register const wchar_t *wcs; - register const wchar_t wc; -{ - register const wchar_t *wcs2 = wcs + 1; - - if (*wcs == wc) - return (wchar_t *) wcs; - if (*wcs == L'\0') - return NULL; - - do - { - wcs += 2; - - if (*wcs2 == wc) - return (wchar_t *) wcs2; - if (*wcs2 == L'\0') - return NULL; - wcs2 += 2; - - if (*wcs == wc) - return (wchar_t *) wcs; - if (*wcs == L'\0') - return NULL; - wcs += 2; - - if (*wcs2 == wc) - return (wchar_t *) wcs2; - if (*wcs2 == L'\0') - return NULL; - wcs2 += 2; - - if (*wcs == wc) - return (wchar_t *) wcs; - if (*wcs == L'\0') - return NULL; - wcs += 2; - - if (*wcs2 == wc) - return (wchar_t *) wcs2; - if (*wcs2 == L'\0') - return NULL; - wcs2 += 2; - - if (*wcs == wc) - return (wchar_t *) wcs; - if (*wcs == L'\0') - return NULL; - wcs += 2; - - if (*wcs2 == wc) - return (wchar_t *) wcs2; - if (*wcs2 == L'\0') - return NULL; - wcs2 += 2; - - if (*wcs == wc) - return (wchar_t *) wcs; - } - while (*wcs != L'\0'); - - return NULL; -} -libc_hidden_def (wcschr) -- cgit 1.4.1