diff options
author | normal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-08-16 01:27:19 +0000 |
---|---|---|
committer | normal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-08-16 01:27:19 +0000 |
commit | ed2e8b2e705c30fc4343d697daff9a08ff58502c (patch) | |
tree | 4ba9d0d7b7883467add1d347886e9617cbdffafd | |
parent | e51a55903e5b113e29fff2ccd2f696a09745b57c (diff) |
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]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47196 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | time.c | 4 |
2 files changed, 9 insertions, 0 deletions
@@ -1,3 +1,8 @@ +Sat Aug 16 10:20:17 2014 Eric Wong <e@80x24.org> + + * time.c (time_timespec): fix tv_nsec overflow + [Bug #10144] + Fri Aug 15 20:34:17 2014 Masaki Suketa <masaki.suketa@nifty.ne.jp> * ext/win32ole/win32ole.c: seperate WIN32OLE_EVENT src from @@ -2354,6 +2354,10 @@ time_timespec(VALUE num, int interval) 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; |