@@ -1,7 +1,8 @@
ifeq ($(subdir),string)
-sysdep_routines += memcpy_generic memcpy_thunderx memcpy_falkor
+sysdep_routines += memcpy_generic memcpy_thunderx memcpy_falkor \
+ mempcpy_generic mempcpy_thunderx mempcpy_falkor
endif
ifeq ($(subdir),debug)
-sysdep_routines += memcpy_chk-nonshared
+sysdep_routines += memcpy_chk-nonshared mempcpy_chk-nonshared
endif
@@ -46,6 +46,14 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
IFUNC_IMPL_ADD (array, i, __memcpy_chk, 1, __memcpy_chk_thunderx)
IFUNC_IMPL_ADD (array, i, __memcpy_chk, 1, __memcpy_chk_falkor)
IFUNC_IMPL_ADD (array, i, __memcpy_chk, 1, __memcpy_chk_generic))
+ IFUNC_IMPL (i, name, mempcpy,
+ IFUNC_IMPL_ADD (array, i, mempcpy, 1, __mempcpy_thunderx)
+ IFUNC_IMPL_ADD (array, i, mempcpy, 1, __mempcpy_falkor)
+ IFUNC_IMPL_ADD (array, i, mempcpy, 1, __mempcpy_generic))
+ IFUNC_IMPL (i, name, __mempcpy_chk,
+ IFUNC_IMPL_ADD (array, i, __mempcpy_chk, 1, __mempcpy_chk_thunderx)
+ IFUNC_IMPL_ADD (array, i, __mempcpy_chk, 1, __mempcpy_chk_falkor)
+ IFUNC_IMPL_ADD (array, i, __mempcpy_chk, 1, __mempcpy_chk_generic))
IFUNC_IMPL (i, name, memmove,
IFUNC_IMPL_ADD (array, i, memmove, 1, __memmove_thunderx)
IFUNC_IMPL_ADD (array, i, memmove, 1, __memmove_generic))
new file mode 100644
@@ -0,0 +1,47 @@
+/* Multiple versions of mempcpy. AARCH64 version.
+ Copyright (C) 2017 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 multiple versions only for the definition in libc. */
+
+#if IS_IN (libc)
+/* Redefine mempcpy so that the compiler won't complain about the type
+ mismatch with the IFUNC selector in strong_alias, below. */
+# undef mempcpy
+# undef __mempcpy
+# define mempcpy __redirect_mempcpy
+# include <string.h>
+# include <init-arch.h>
+
+extern __typeof (__redirect_mempcpy) __mempcpy;
+
+extern __typeof (__redirect_mempcpy) __mempcpy_generic attribute_hidden;
+extern __typeof (__redirect_mempcpy) __mempcpy_thunderx attribute_hidden;
+extern __typeof (__redirect_mempcpy) __mempcpy_falkor attribute_hidden;
+
+libc_ifunc (__mempcpy,
+ (IS_THUNDERX (midr)
+ ? __mempcpy_thunderx
+ : (IS_FALKOR (midr)
+ ? __mempcpy_falkor
+ : __mempcpy_generic)));
+
+# undef mempcpy
+strong_alias (__mempcpy, mempcpy);
+#else
+# include <string/mempcpy.c>
+#endif
new file mode 100644
@@ -0,0 +1,28 @@
+/* Non-shared version of mempcpy_chk.
+ Copyright (C) 2017 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 <sysdep.h>
+
+#if IS_IN (libc) && !defined SHARED
+ENTRY_ALIGN (__mempcpy_chk, 6)
+ cmp x3, x2
+ b.lo __chk_fail
+ b mempcpy
+ nop
+END (__mempcpy_chk)
+#endif
new file mode 100644
@@ -0,0 +1,35 @@
+/* Multiple versions of mempcpy. AARCH64 version.
+ Copyright (C) 2017 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 multiple versions only for the definition in libc. */
+
+#if IS_IN (libc) && defined SHARED
+# include <string.h>
+# include <init-arch.h>
+
+extern __typeof (__mempcpy_chk) __mempcpy_chk_generic attribute_hidden;
+extern __typeof (__mempcpy_chk) __mempcpy_chk_thunderx attribute_hidden;
+extern __typeof (__mempcpy_chk) __mempcpy_chk_falkor attribute_hidden;
+
+libc_ifunc (__mempcpy_chk,
+ (IS_THUNDERX (midr)
+ ? __mempcpy_chk_thunderx
+ : (IS_FALKOR (midr)
+ ? __mempcpy_chk_falkor
+ : __mempcpy_chk_generic)));
+#endif
new file mode 100644
@@ -0,0 +1,23 @@
+/* Optimized mempcpy for Qualcomm Falkor processor.
+ Copyright (C) 2017 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 MEMPCPY __mempcpy_falkor
+# define MEMPCPY_CHK __mempcpy_chk_falkor
+#define MEMCPY __memcpy_falkor
+#include <sysdeps/aarch64/multiarch/mempcpy_generic.S>
new file mode 100644
@@ -0,0 +1,55 @@
+/* Generic mempcpy to select via IFUNC.
+ Copyright (C) 2017 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 <sysdep.h>
+
+#if IS_IN (libc) && !defined MEMPCPY
+# define MEMPCPY __mempcpy_generic
+# define MEMPCPY_CHK __mempcpy_chk_generic
+# define MEMCPY __memcpy_generic
+
+# undef libc_hidden_builtin_def
+# define libc_hidden_builtin_def(name)
+
+# ifdef SHARED
+ .globl __GI_mempcpy; __GI_mempcpy = __mempcpy_generic
+# endif
+
+#endif
+
+/* Push the sum of the destination and count on to stack and return it after
+ memcpy is done. We could avoid the register spill by ensuring that the
+ memcpy does not use one of the scratch registers, but that could get
+ increasingly error-prone when we add new implementations for memcpy. */
+
+#ifdef SHARED
+ENTRY_ALIGN (MEMPCPY_CHK, 4)
+ cmp x3, x2
+ b.lo __chk_fail
+END (MEMPCPY_CHK)
+#endif
+
+ENTRY_ALIGN (MEMPCPY, 4)
+ add x15, x0, x2
+ stp x15, x30, [sp, -16]
+ bl MEMCPY
+ ldp x0, x30, [sp, -16]
+ ret
+END (MEMPCPY)
+libc_hidden_builtin_def (MEMPCPY)
new file mode 100644
@@ -0,0 +1,23 @@
+/* A Thunderx Optimized mempcpy implementation for AARCH64.
+ Copyright (C) 2017 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 MEMPCPY __mempcpy_thunderx
+# define MEMPCPY_CHK __mempcpy_chk_thunderx
+#define MEMCPY __memcpy_thunderx
+#include <sysdeps/aarch64/multiarch/mempcpy_generic.S>