fix up r62272

* thread.c (timeval_for): tv_usec is suseconds_t which may be
  smaller than long.

* thread_pthread.c (native_cond_timeout): ret is now used in
  CLOCK_MONOTONIC case only.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62275 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2018-02-07 06:14:56 +00:00
parent 714836c152
commit b0cf1c234c
2 changed files with 2 additions and 3 deletions

View File

@ -225,7 +225,7 @@ timeval_for(struct timeval *tv, const struct timespec *ts)
{ {
if (tv && ts) { if (tv && ts) {
tv->tv_sec = ts->tv_sec; tv->tv_sec = ts->tv_sec;
tv->tv_usec = ts->tv_nsec / 1000; tv->tv_usec = (suseconds_t)(ts->tv_nsec / 1000);
return tv; return tv;
} }
return 0; return 0;

View File

@ -365,13 +365,12 @@ native_cond_timedwait(rb_nativethread_cond_t *cond, pthread_mutex_t *mutex, cons
static struct timespec static struct timespec
native_cond_timeout(rb_nativethread_cond_t *cond, struct timespec timeout_rel) native_cond_timeout(rb_nativethread_cond_t *cond, struct timespec timeout_rel)
{ {
int ret;
struct timespec timeout; struct timespec timeout;
struct timespec now; struct timespec now;
#if USE_MONOTONIC_COND #if USE_MONOTONIC_COND
if (cond->clockid == CLOCK_MONOTONIC) { if (cond->clockid == CLOCK_MONOTONIC) {
ret = clock_gettime(cond->clockid, &now); int ret = clock_gettime(cond->clockid, &now);
if (ret != 0) if (ret != 0)
rb_sys_fail("clock_gettime()"); rb_sys_fail("clock_gettime()");
goto out; goto out;