ruby-changes:40745
From: nobu <ko1@a...>
Date: Tue, 1 Dec 2015 10:24:30 +0900 (JST)
Subject: [ruby-changes:40745] nobu:r52824 (trunk): missing.h: explicit_bzero by memset_s
nobu 2015-12-01 10:24:23 +0900 (Tue, 01 Dec 2015) New Revision: 52824 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=52824 Log: 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. Modified files: trunk/include/ruby/missing.h trunk/missing/explicit_bzero.c Index: include/ruby/missing.h =================================================================== --- include/ruby/missing.h (revision 52823) +++ include/ruby/missing.h (revision 52824) @@ -244,6 +244,15 @@ RUBY_EXTERN void setproctitle(const char https://github.com/ruby/ruby/blob/trunk/include/ruby/missing.h#L244 #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 Index: missing/explicit_bzero.c =================================================================== --- missing/explicit_bzero.c (revision 52823) +++ missing/explicit_bzero.c (revision 52824) @@ -19,7 +19,11 @@ https://github.com/ruby/ruby/blob/trunk/missing/explicit_bzero.c#L19 #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) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/