]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
PowerPC: memchr ifunc for PPC32
authorAdhemerval Zanella <azanella@linux.vnet.ibm.com>
Fri, 29 Mar 2013 18:46:30 +0000 (13:46 -0500)
committerAdhemerval Zanella <azanella@linux.vnet.ibm.com>
Fri, 29 Mar 2013 18:46:30 +0000 (13:46 -0500)
string/memchr.c
sysdeps/powerpc/powerpc32/multiarch/Makefile
sysdeps/powerpc/powerpc32/multiarch/ifunc-impl-list.c
sysdeps/powerpc/powerpc32/multiarch/memchr-c.c [new file with mode: 0644]
sysdeps/powerpc/powerpc32/multiarch/memchr-power7.S [moved from sysdeps/powerpc/powerpc32/power7/memchr.S with 98% similarity]
sysdeps/powerpc/powerpc32/multiarch/memchr.c [new file with mode: 0644]

index 2427c4b4b6e985cfbc8f00c58ccfe61bd3d97314..2d53f6bd0e1e759c06c3487325ecfc145a1f45e9 100644 (file)
@@ -50,6 +50,9 @@
 
 #undef memchr
 #undef __memchr
+#ifdef MEMCHR
+# define __memchr MEMCHR
+#endif
 
 /* Search no more than N bytes of S for C.  */
 __ptr_t
@@ -198,6 +201,8 @@ __memchr (s, c_in, n)
   return 0;
 }
 #ifdef weak_alias
+# ifndef MEMCHR
 weak_alias (__memchr, memchr)
+# endif
 #endif
 libc_hidden_builtin_def (memchr)
index c7c0d8c455bc7adaa0104a97f3558f8f7a33a80d..63ef4a6e3744f970b19cd0278f40abaf620b4918 100644 (file)
@@ -5,5 +5,6 @@ sysdep_routines += memcpy-power7 memcpy-a2 memcpy-power6 memcpy-cell \
                   strncmp-power7 strncmp-power4 strlen-power7 \
                    strcasecmp-power7 strcasecmp_l-power7 \
                   strnlen-power7 strnlen-c \
-                  mempcpy-power7 mempcpy-c
+                  mempcpy-power7 mempcpy-c \
+                  memchr-power7 memchr-c
 endif
index c295caf720e852c8e1b045cf077174390aeec8cd..49bdb50f2b4fbb63f964d611c433af08be89fbc1 100644 (file)
@@ -89,6 +89,13 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
              IFUNC_IMPL_ADD (array, i, mempcpy, 1,
                              __mempcpy_ppc32))
 
+  IFUNC_IMPL (i, name, memchr,
+             IFUNC_IMPL_ADD (array, i, memchr,
+                             hwcap & PPC_FEATURE_HAS_VSX,
+                             __memchr_power7)
+             IFUNC_IMPL_ADD (array, i, memchr, 1,
+                             __memchr_ppc32))
+
   IFUNC_IMPL (i, name, strlen,
              IFUNC_IMPL_ADD (array, i, strlen, hwcap & PPC_FEATURE_HAS_VSX,
                                __strlen_power7)
diff --git a/sysdeps/powerpc/powerpc32/multiarch/memchr-c.c b/sysdeps/powerpc/powerpc32/multiarch/memchr-c.c
new file mode 100644 (file)
index 0000000..1468f18
--- /dev/null
@@ -0,0 +1,8 @@
+#define MEMCHR  __memchr_ppc32
+#ifdef SHARED
+# undef libc_hidden_builtin_def
+# define libc_hidden_builtin_def(name)  \
+  __hidden_ver1 (__memchr_ppc32, __GI_memchr, __memchr_ppc32);
+#endif
+
+#include "string/memchr.c"
similarity index 98%
rename from sysdeps/powerpc/powerpc32/power7/memchr.S
rename to sysdeps/powerpc/powerpc32/multiarch/memchr-power7.S
index 369e5e0483f8d72be13546b79a5df57e17b6d4b7..b7aa903c102ad607402ca41ca2375d06a6a4b658 100644 (file)
@@ -21,7 +21,7 @@
 
 /* int [r3] memchr (char *s [r3], int byte [r4], int size [r5])  */
        .machine  power7
-ENTRY (__memchr)
+ENTRY (__memchr_power7)
        CALL_MCOUNT
        dcbt    0,r3
        clrrwi  r8,r3,2
@@ -200,6 +200,4 @@ L(loop_small):                /* loop_small has been unrolled.  */
        li      r3,0
        blr
 
-END (__memchr)
-weak_alias (__memchr, memchr)
-libc_hidden_builtin_def (memchr)
+END (__memchr_power7)
diff --git a/sysdeps/powerpc/powerpc32/multiarch/memchr.c b/sysdeps/powerpc/powerpc32/multiarch/memchr.c
new file mode 100644 (file)
index 0000000..49c8d05
--- /dev/null
@@ -0,0 +1,38 @@
+/* Multiple versions of memchr.
+   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
+   <http://www.gnu.org/licenses/>.  */
+
+#ifndef NOT_IN_libc
+# include <string.h>
+# include <shlib-compat.h>
+# include "init-arch.h"
+
+extern __typeof (__memchr) __memchr_ppc32 attribute_hidden;
+extern __typeof (__memchr) __memchr_power7 attribute_hidden;
+
+/* Avoid DWARF definition DIE on ifunc symbol so that GDB can handle
+   ifunc symbol properly.  */
+libc_ifunc (__memchr,
+           (hwcap & PPC_FEATURE_HAS_VSX)
+            ? __memchr_power7
+            : __memchr_ppc32);
+
+weak_alias (__memchr, memchr)
+libc_hidden_builtin_def (memchr)
+#else
+#include "string/memchr.c"
+#endif