mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
explicit_bzero.c: fix comments
* missing/explicit_bzero.c: fix comments. Microsoft Visual Studio does not provide memset_s() in 12.0 at least. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52845 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
0167fc15fb
commit
9849555a3e
1 changed files with 8 additions and 7 deletions
|
@ -5,17 +5,18 @@
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Similar to bzero(), but have a guarantee not to be eliminated from compiler
|
/* Similar to bzero(), but has a guarantee not to be eliminated from compiler
|
||||||
optimization. */
|
optimization. */
|
||||||
|
|
||||||
/* OS support note:
|
/* OS support note:
|
||||||
* BSD have explicit_bzero().
|
* BSDs have explicit_bzero().
|
||||||
* Windows, OS-X have memset_s().
|
* OS-X has memset_s().
|
||||||
|
* Windows has SecureZeroMemory() since XP.
|
||||||
* Linux has none. *Sigh*
|
* Linux has none. *Sigh*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Following URL explain why memset_s is added to the standard.
|
* Following URL explains why memset_s is added to the standard.
|
||||||
* http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1381.pdf
|
* http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1381.pdf
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -40,7 +41,7 @@ explicit_bzero(void *b, size_t len)
|
||||||
|
|
||||||
#elif defined HAVE_FUNC_WEAK
|
#elif defined HAVE_FUNC_WEAK
|
||||||
|
|
||||||
/* A weak function never be optimization away. Even if nobody use it. */
|
/* A weak function never be optimized away. Even if nobody uses it. */
|
||||||
WEAK(void ruby_explicit_bzero_hook_unused(void *buf, size_t len));
|
WEAK(void ruby_explicit_bzero_hook_unused(void *buf, size_t len));
|
||||||
void
|
void
|
||||||
ruby_explicit_bzero_hook_unused(void *buf, size_t len)
|
ruby_explicit_bzero_hook_unused(void *buf, size_t len)
|
||||||
|
@ -64,8 +65,8 @@ explicit_bzero(void *b, size_t len)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* volatile is not enough if compiler have a LTO (link time
|
* volatile is not enough if compiler have a LTO (link time
|
||||||
* optimization). At least, the standard provide no guarantee.
|
* optimization). At least, the standard provides no guarantee.
|
||||||
* However, gcc and major other compiler never optimization a volatile
|
* However, gcc and major other compiler never optimize a volatile
|
||||||
* variable away. So, using volatile is practically ok.
|
* variable away. So, using volatile is practically ok.
|
||||||
*/
|
*/
|
||||||
volatile char* p = (volatile char*)b;
|
volatile char* p = (volatile char*)b;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue