From b5dbf3de561189140c73f915bd50c28ea69a1e19 Mon Sep 17 00:00:00 2001 From: Robert Clausecker Date: Tue, 21 Oct 2025 20:55:41 +0200 Subject: [PATCH] libc/riscv64: implement bcopy() and bzero() through memcpy() and memset() This picks up the accelerated string functions written by strajabot@. Event: Google Summer of Code 2024 MFC after: 1 month MFC to: stable/15 See also: 79e01e7e643c9337d8d6046b6db7df674475a099 Approved by: markj (mentor) Differential Revision: https://reviews.freebsd.org/D53248 --- lib/libc/riscv/string/Makefile.inc | 2 ++ lib/libc/riscv/string/bcopy.c | 14 ++++++++++++++ lib/libc/riscv/string/bzero.c | 14 ++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 lib/libc/riscv/string/bcopy.c create mode 100644 lib/libc/riscv/string/bzero.c diff --git a/lib/libc/riscv/string/Makefile.inc b/lib/libc/riscv/string/Makefile.inc index 719f22f6077..6dae6b2cb62 100644 --- a/lib/libc/riscv/string/Makefile.inc +++ b/lib/libc/riscv/string/Makefile.inc @@ -1,4 +1,6 @@ MDSRCS+= \ + bcopy.c \ + bzero.c \ memchr.S \ memcpy.S \ memset.S \ diff --git a/lib/libc/riscv/string/bcopy.c b/lib/libc/riscv/string/bcopy.c new file mode 100644 index 00000000000..0dee529fb9d --- /dev/null +++ b/lib/libc/riscv/string/bcopy.c @@ -0,0 +1,14 @@ +/*- + * Public domain. + */ + +#include + +#undef bcopy /* _FORTIFY_SOURCE */ + +void +bcopy(const void *src, void *dst, size_t len) +{ + + memmove(dst, src, len); +} diff --git a/lib/libc/riscv/string/bzero.c b/lib/libc/riscv/string/bzero.c new file mode 100644 index 00000000000..d82f3061865 --- /dev/null +++ b/lib/libc/riscv/string/bzero.c @@ -0,0 +1,14 @@ +/*- + * Public domain. + */ + +#include + +#undef bzero /* _FORTIFY_SOURCE */ + +void +bzero(void *b, size_t len) +{ + + memset(b, 0, len); +}