[前][次][番号順一覧][スレッド一覧]

ruby-changes:40727

From: kosaki <ko1@a...>
Date: Tue, 1 Dec 2015 05:26:39 +0900 (JST)
Subject: [ruby-changes:40727] kosaki:r52806 (trunk): * missing/explicit_bzero.c: new file. define explicit_bzero.

kosaki	2015-12-01 05:26:13 +0900 (Tue, 01 Dec 2015)

  New Revision: 52806

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=52806

  Log:
    * missing/explicit_bzero.c: new file. define explicit_bzero.
    * common.mk: add a rule for explicit.o.
    * configure.in: detect explicit_bzero and memset_s.
    * include/ruby/missing.h: add explicit_bzero.
    * random.c (init_randomseed): use explicit_bzero() instead of
      memset(). memset could be eliminated by compiler optimization.

  Modified files:
    trunk/ChangeLog
    trunk/common.mk
    trunk/configure.in
    trunk/include/ruby/missing.h
    trunk/random.c
Index: include/ruby/missing.h
===================================================================
--- include/ruby/missing.h	(revision 52805)
+++ include/ruby/missing.h	(revision 52806)
@@ -242,6 +242,10 @@ RUBY_EXTERN int ruby_close(int); https://github.com/ruby/ruby/blob/trunk/include/ruby/missing.h#L242
 RUBY_EXTERN void setproctitle(const char *fmt, ...);
 #endif
 
+#ifndef HAVE_EXPLICIT_BZERO
+RUBY_EXTERN void explicit_bzero(void *b, size_t len);
+#endif
+
 RUBY_SYMBOL_EXPORT_END
 
 #if defined(__cplusplus)
Index: configure.in
===================================================================
--- configure.in	(revision 52805)
+++ configure.in	(revision 52806)
@@ -2127,6 +2127,7 @@ AC_REPLACE_FUNCS(cbrt) https://github.com/ruby/ruby/blob/trunk/configure.in#L2127
 AC_REPLACE_FUNCS(crypt)
 AC_REPLACE_FUNCS(dup2)
 AC_REPLACE_FUNCS(erf)
+AC_REPLACE_FUNCS(explicit_bzero)
 AC_REPLACE_FUNCS(ffs)
 AC_REPLACE_FUNCS(finite)
 AC_REPLACE_FUNCS(flock)
@@ -2255,6 +2256,7 @@ AC_CHECK_FUNCS(malloc_usable_size) https://github.com/ruby/ruby/blob/trunk/configure.in#L2256
 AC_CHECK_FUNCS(malloc_size)
 AC_CHECK_FUNCS(mblen)
 AC_CHECK_FUNCS(memalign)
+AC_CHECK_FUNCS(memset_s)
 AC_CHECK_FUNCS(writev)
 AC_CHECK_FUNCS(memrchr)
 AC_CHECK_FUNCS(memmem)
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 52805)
+++ ChangeLog	(revision 52806)
@@ -1,3 +1,12 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sun Oct 18 17:26:53 2015  KOSAKI Motohiro  <kosaki.motohiro@g...>
+
+	* missing/explicit_bzero.c: new file. define explicit_bzero.
+	* common.mk: add a rule for explicit.o.
+	* configure.in: detect explicit_bzero and memset_s.
+	* include/ruby/missing.h: add explicit_bzero.
+	* random.c (init_randomseed): use explicit_bzero() instead of
+	  memset(). memset could be eliminated by compiler optimization.
+
 Mon Nov 30 18:46:44 2015  NARUSE, Yui  <naruse@r...>
 
 	* ext/readline/extconf.rb: call dir_config("libedit")
Index: common.mk
===================================================================
--- common.mk	(revision 52805)
+++ common.mk	(revision 52806)
@@ -705,6 +705,7 @@ alloca.$(OBJEXT): {$(VPATH)}alloca.c {$( https://github.com/ruby/ruby/blob/trunk/common.mk#L705
 crypt.$(OBJEXT): {$(VPATH)}crypt.c
 dup2.$(OBJEXT): {$(VPATH)}dup2.c
 erf.$(OBJEXT): {$(VPATH)}erf.c
+explicit_bzero.$(OBJEXT): {$(VPATH)}explicit_bzero.c
 finite.$(OBJEXT): {$(VPATH)}finite.c
 flock.$(OBJEXT): {$(VPATH)}flock.c
 memcmp.$(OBJEXT): {$(VPATH)}memcmp.c
Index: random.c
===================================================================
--- random.c	(revision 52805)
+++ random.c	(revision 52806)
@@ -1456,7 +1456,7 @@ init_randomseed(struct MT *mt, uint32_t https://github.com/ruby/ruby/blob/trunk/random.c#L1456
     fill_random_seed(initial);
     init_by_array(mt, initial, DEFAULT_SEED_CNT);
     seed = make_seed_value(initial);
-    memset(initial, 0, DEFAULT_SEED_LEN);
+    explicit_bzero(initial, DEFAULT_SEED_LEN);
     return seed;
 }
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]