riscv64: add bionic assembler and string functions.
Pull the portable C string functions from FreeBSD, and do fairly literal
translations of our existing .S files for the bionic-specific stuff.
Test: treehugger
Change-Id: Id42e5b8a51ed73155be020d74edd7011a2103574
diff --git a/libc/arch-riscv64/string/memset_chk.c b/libc/arch-riscv64/string/memset_chk.c
new file mode 100644
index 0000000..bdd15a5
--- /dev/null
+++ b/libc/arch-riscv64/string/memset_chk.c
@@ -0,0 +1,9 @@
+#include <stdint.h>
+
+extern void* memset(void*, int, size_t);
+extern void* __memset_chk_fail(void*, int, size_t, size_t);
+
+void* __memset_chk(void* dst, int c, size_t n, size_t dst_len) {
+ if (dst_len < n) __memset_chk_fail(dst, c, n, dst_len);
+ return memset(dst, c, n);
+}