summaryrefslogtreecommitdiff
path: root/lib/string/explicit_bzero.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/string/explicit_bzero.c')
-rw-r--r--lib/string/explicit_bzero.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/string/explicit_bzero.c b/lib/string/explicit_bzero.c
new file mode 100644
index 0000000..c94f25f
--- /dev/null
+++ b/lib/string/explicit_bzero.c
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: MIT */
+/* Derived from musl libc (Copyright © 2005-2020 Rich Felker, et al.) */
+
+#define _BSD_SOURCE
+#include <string.h>
+
+void explicit_bzero(void *d, size_t n)
+{
+ d = memset(d, 0, n);
+ __asm__ __volatile__ ("" : : "r"(d) : "memory");
+}