diff options
Diffstat (limited to 'missing/explicit_bzero.c')
| -rw-r--r-- | missing/explicit_bzero.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/missing/explicit_bzero.c b/missing/explicit_bzero.c index 2409deca20..59417e158e 100644 --- a/missing/explicit_bzero.c +++ b/missing/explicit_bzero.c @@ -1,3 +1,7 @@ +#ifndef __STDC_WANT_LIB_EXT1__ +#define __STDC_WANT_LIB_EXT1__ 1 /* for memset_s() */ +#endif + #include "ruby/missing.h" #include <string.h> @@ -10,9 +14,9 @@ /* OS support note: * BSDs have explicit_bzero(). - * OS-X has memset_s(). + * macOS has memset_s(). * Windows has SecureZeroMemory() since XP. - * Linux has none. *Sigh* + * Linux has explicit_bzero() since glibc 2.25, musl libc 1.1.20. */ /* @@ -26,7 +30,13 @@ #undef explicit_bzero #ifndef HAVE_EXPLICIT_BZERO - #ifdef HAVE_MEMSET_S + #ifdef HAVE_EXPLICIT_MEMSET +void +explicit_bzero(void *b, size_t len) +{ + (void)explicit_memset(b, 0, len); +} + #elif defined HAVE_MEMSET_S void explicit_bzero(void *b, size_t len) { |
