1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

missing.h: explicit_bzero by memset_s

* include/ruby/missing.h (explicit_bzero_by_memset_s): call
  memset_s directly if available.

* missing/explicit_bzero.c: optimization is not a matter if
  memset_s is available.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52824 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2015-12-01 01:24:23 +00:00
parent ff113d52f7
commit 10bb9e6fab
2 changed files with 13 additions and 0 deletions

View file

@ -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

View file

@ -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)