mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
e51a55903e
commit
ed2e8b2e70
2 changed files with 9 additions and 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>
|
Fri Aug 15 20:34:17 2014 Masaki Suketa <masaki.suketa@nifty.ne.jp>
|
||||||
|
|
||||||
* ext/win32ole/win32ole.c: seperate WIN32OLE_EVENT src from
|
* ext/win32ole/win32ole.c: seperate WIN32OLE_EVENT src from
|
||||||
|
|
4
time.c
4
time.c
|
@ -2354,6 +2354,10 @@ time_timespec(VALUE num, int interval)
|
||||||
d = modf(RFLOAT_VALUE(num), &f);
|
d = modf(RFLOAT_VALUE(num), &f);
|
||||||
if (d >= 0) {
|
if (d >= 0) {
|
||||||
t.tv_nsec = (int)(d*1e9+0.5);
|
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) {
|
else if ((t.tv_nsec = (int)(-d*1e9+0.5)) > 0) {
|
||||||
t.tv_nsec = 1000000000 - t.tv_nsec;
|
t.tv_nsec = 1000000000 - t.tv_nsec;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue