#ifndef SHARED
asm ("memcmp = __memcmp_generic");
asm ("memcpy = __memcpy_generic");
+asm ("memmove = __memmove_generic");
asm ("memset = __memset_generic");
asm ("strlen = __strlen_generic");
#endif
--- /dev/null
+/* Re-include the default memmove implementation.
+ Copyright (C) 2026 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
+ <https://www.gnu.org/licenses/>. */
+
+#include <string.h>
+
+#if IS_IN(libc)
+# define MEMMOVE __memmove_generic
+# undef libc_hidden_builtin_def
+# define libc_hidden_builtin_def(x)
+# include <string/memmove.c>
+#endif
--- /dev/null
+/* Re-include the RISC-V RVV based memmove implementation.
+ Copyright (C) 2026 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
+ <https://www.gnu.org/licenses/>. */
+
+#if IS_IN(libc)
+# define MEMMOVE __memmove_vector
+# undef libc_hidden_builtin_def
+# define libc_hidden_builtin_def(name)
+# include <sysdeps/riscv/rvv/memmove.S>
+#endif
--- /dev/null
+/* RISC-V RVV based memmove.
+ Copyright (C) 2026 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
+ <https://www.gnu.org/licenses/>. */
+
+#include <sysdep.h>
+#include <sys/asm.h>
+
+#ifndef MEMMOVE
+# define MEMMOVE memmove
+#endif
+
+#define dst a0
+#define src a1
+#define num a2
+
+#define ivl a3
+#define dst_ptr a4
+#define diff a5
+
+#define ELEM_LMUL_SETTING m8
+#define vdata v0
+
+ENTRY (MEMMOVE)
+.option push
+.option arch, +v
+ /* There is nothing to do if we are copying zero bytes or DST == SRC. */
+ beqz num, L(done)
+ sub diff, dst, src
+ beqz diff, L(done)
+
+ /* If (unsigned)(dst - src) < num, then we have an overlap scenario that
+ requires a backward copy loop. Otherwise, we can use a faster forward
+ copy loop. */
+ bltu diff, num, L(do_backward_loop)
+
+ mv dst_ptr, dst
+
+L(forward_copy_loop):
+ vsetvli ivl, num, e8, ELEM_LMUL_SETTING, ta, ma
+ vle8.v vdata, (src)
+ sub num, num, ivl
+ add src, src, ivl
+ vse8.v vdata, (dst_ptr)
+ add dst_ptr, dst_ptr, ivl
+ bnez num, L(forward_copy_loop)
+L(done):
+ ret
+
+L(do_backward_loop):
+ add src, src, num
+ add dst_ptr, dst, num
+
+L(backward_copy_loop):
+ vsetvli ivl, num, e8, ELEM_LMUL_SETTING, ta, ma
+ sub src, src, ivl
+ sub dst_ptr, dst_ptr, ivl
+ vle8.v vdata, (src)
+ sub num, num, ivl
+ vse8.v vdata, (dst_ptr)
+ bnez num, L(backward_copy_loop)
+ ret
+
+.option pop
+END (MEMMOVE)
+libc_hidden_builtin_def (memmove)
memcpy-generic \
memcpy-vector \
memcpy_noalignment \
+ memmove \
+ memmove-generic \
+ memmove-vector \
memset \
memset-generic \
memset-vector \
__strrchr_vector)
IFUNC_IMPL_ADD (array, i, strrchr, 1, __strrchr_generic))
+ IFUNC_IMPL (i, name, memmove,
+ IFUNC_IMPL_ADD (array, i, memmove, rvv_enabled,
+ __memmove_vector)
+ IFUNC_IMPL_ADD (array, i, memmove, 1, __memmove_generic))
+
return 0;
}
--- /dev/null
+/* Multiple versions of memmove.
+ All versions must be listed in ifunc-impl-list.c.
+ Copyright (C) 2026 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
+ <https://www.gnu.org/licenses/>. */
+
+#if IS_IN (libc)
+/* Redefine memmove so that the compiler won't complain about the type
+ mismatch with the IFUNC selector in strong_alias, below. */
+# undef memmove
+# define memmove __redirect_memmove
+# include <stdint.h>
+# include <string.h>
+# include <ifunc-init.h>
+# include <riscv-ifunc.h>
+# include <sys/hwprobe.h>
+
+extern __typeof (__redirect_memmove) __libc_memmove;
+
+extern __typeof (__redirect_memmove) __memmove_generic attribute_hidden;
+extern __typeof (__redirect_memmove) __memmove_vector attribute_hidden;
+
+static inline __typeof (__redirect_memmove) *
+select_memmove_ifunc (uint64_t dl_hwcap, __riscv_hwprobe_t hwprobe_func)
+{
+ unsigned long long int v;
+ if (__riscv_hwprobe_one (hwprobe_func, RISCV_HWPROBE_KEY_IMA_EXT_0, &v) == 0
+ && (v & RISCV_HWPROBE_IMA_V) == RISCV_HWPROBE_IMA_V)
+ return __memmove_vector;
+ return __memmove_generic;
+}
+
+riscv_libc_ifunc (__libc_memmove, select_memmove_ifunc);
+
+# undef memmove
+strong_alias (__libc_memmove, memmove);
+# ifdef SHARED
+__hidden_ver1 (memmove, __GI_memmove, __redirect_memmove)
+ __attribute__ ((visibility ("hidden"))) __attribute_copy__ (memmove);
+# endif
+#else
+# include <string/memmove.c>
+#endif