summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/ruby/missing.h9
-rw-r--r--missing/explicit_bzero.c4
2 files changed, 13 insertions, 0 deletions
diff --git a/include/ruby/missing.h b/include/ruby/missing.h
index 24156bf343..a06cea2ba4 100644
--- a/include/ruby/missing.h
+++ b/include/ruby/missing.h
@@ -244,6 +244,15 @@ RUBY_EXTERN void setproctitle(const char *fmt, ...);
#ifndef HAVE_EXPLICIT_BZERO
RUBY_EXTERN void explicit_bzero(void *b, size_t len);
+# ifdef HAVE_MEMSET_S
+# include <string.h>
+static inline void
+explicit_bzero_by_memset_s(void *b, size_t len)
+{
+ memset_s(b, len, 0, len);
+}
+# define explicit_bzero(b, len) explicit_bzero_by_memset_s(b, len)
+# endif
#endif
RUBY_SYMBOL_EXPORT_END
diff --git a/missing/explicit_bzero.c b/missing/explicit_bzero.c
index e7bb11e69f..c1933bf1ff 100644
--- a/missing/explicit_bzero.c
+++ b/missing/explicit_bzero.c
@@ -19,7 +19,11 @@
#ifndef HAVE_EXPLICIT_BZERO
/* Similar to bzero(), but have a guarantee not to be eliminated from compiler
optimization. */
+
+#ifndef HAVE_MEMSET_S
FUNC_UNOPTIMIZED(void explicit_bzero(void *b, size_t len));
+#endif
+#undef explicit_bzero
void
explicit_bzero(void *b, size_t len)