mirror of
https://github.com/ruby/ruby.git
synced 2025-09-17 01:23:57 +02:00
merge revision(s) 40208: [Backport #8380]
* internal.h (MUL_OVERFLOW_SIGNED_INTEGER_P): New macro. (MUL_OVERFLOW_FIXNUM_P): Ditto. (MUL_OVERFLOW_LONG_P): Ditto. * array.c (rb_ary_product): Don't overflow on signed integer multiplication. * numeric.c (fix_mul): Ditto. (int_pow): Ditto. * rational.c (f_imul): Ditto. * insns.def (opt_mult): Ditto. * thread.c (sleep_timeval): Don't overflow on signed integer addition. * bignum.c (rb_int2big): Don't overflow on signed integer negation. (rb_big2ulong): Ditto. (rb_big2long): Ditto. (rb_big2ull): Ditto. (rb_big2ll): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@40602 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
b6f0a306a6
commit
555035a349
9 changed files with 108 additions and 56 deletions
13
thread.c
13
thread.c
|
@ -981,10 +981,17 @@ sleep_timeval(rb_thread_t *th, struct timeval tv, int spurious_check)
|
|||
enum rb_thread_status prev_status = th->status;
|
||||
|
||||
getclockofday(&to);
|
||||
to.tv_sec += tv.tv_sec;
|
||||
if (TIMET_MAX - tv.tv_sec < to.tv_sec)
|
||||
to.tv_sec = TIMET_MAX;
|
||||
else
|
||||
to.tv_sec += tv.tv_sec;
|
||||
if ((to.tv_usec += tv.tv_usec) >= 1000000) {
|
||||
to.tv_sec++;
|
||||
to.tv_usec -= 1000000;
|
||||
if (to.tv_sec == TIMET_MAX)
|
||||
to.tv_usec = 999999;
|
||||
else {
|
||||
to.tv_sec++;
|
||||
to.tv_usec -= 1000000;
|
||||
}
|
||||
}
|
||||
|
||||
th->status = THREAD_STOPPED;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue