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

ruby-changes:35114

From: normal <ko1@a...>
Date: Sat, 16 Aug 2014 10:27:26 +0900 (JST)
Subject: [ruby-changes:35114] normal:r47196 (trunk): time.c (time_timespec): fix tv_nsec overflow

normal	2014-08-16 10:27:19 +0900 (Sat, 16 Aug 2014)

  New Revision: 47196

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

  Log:
    time.c (time_timespec): fix tv_nsec overflow
    
    test/ruby/test_float.rb (test_sleep_with_Float) causes tv_nsec
    to hit 1000000000 exactly.  This bug is currently hidden from
    our test by the platform-dependent native_cond_timeout
    functions, but a future native_cond_timedwait implementation may
    prefer relative timeouts to match ConditionVariable#wait
    semantics more closely.
    [Bug #10144]

  Modified files:
    trunk/ChangeLog
    trunk/time.c
Index: time.c
===================================================================
--- time.c	(revision 47195)
+++ time.c	(revision 47196)
@@ -2354,6 +2354,10 @@ time_timespec(VALUE num, int interval) https://github.com/ruby/ruby/blob/trunk/time.c#L2354
 	    d = modf(RFLOAT_VALUE(num), &f);
 	    if (d >= 0) {
 		t.tv_nsec = (int)(d*1e9+0.5);
+		if (t.tv_nsec >= 1000000000) {
+		    t.tv_nsec -= 1000000000;
+		    f += 1;
+		}
 	    }
 	    else if ((t.tv_nsec = (int)(-d*1e9+0.5)) > 0) {
 		t.tv_nsec = 1000000000 - t.tv_nsec;
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 47195)
+++ ChangeLog	(revision 47196)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat Aug 16 10:20:17 2014  Eric Wong  <e@8...>
+
+	* time.c (time_timespec): fix tv_nsec overflow
+	  [Bug #10144]
+
 Fri Aug 15 20:34:17 2014  Masaki Suketa <masaki.suketa@n...>
 
 	* ext/win32ole/win32ole.c: seperate WIN32OLE_EVENT src from

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

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