ruby-changes:50342
From: normal <ko1@a...>
Date: Sun, 18 Feb 2018 11:12:18 +0900 (JST)
Subject: [ruby-changes:50342] normal:r62457 (trunk): thread.c (update_timespec): use timespec_update_expire
normal 2018-02-18 11:12:13 +0900 (Sun, 18 Feb 2018) New Revision: 62457 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=62457 Log: thread.c (update_timespec): use timespec_update_expire Rename "end" as a appropriate for readability. Modified files: trunk/thread.c Index: thread.c =================================================================== --- thread.c (revision 62456) +++ thread.c (revision 62457) @@ -3784,17 +3784,10 @@ retryable(int e) https://github.com/ruby/ruby/blob/trunk/thread.c#L3784 ((fds1) ? rb_fd_dup(fds1, fds2) : (void)0) static inline int -update_timespec(struct timespec *timeout, const struct timespec *to) +update_timespec(struct timespec *timeout, const struct timespec *end) { if (timeout) { - struct timespec now; - - getclockofday(&now); - *timeout = *to; - timespec_sub(timeout, &now); - - if (timeout->tv_sec < 0) timeout->tv_sec = 0; - if (timeout->tv_nsec < 0) timeout->tv_nsec = 0; + return !timespec_update_expire(timeout, end); } return TRUE; } @@ -3808,7 +3801,7 @@ do_select(int n, rb_fdset_t *const readf https://github.com/ruby/ruby/blob/trunk/thread.c#L3801 rb_fdset_t MAYBE_UNUSED(orig_read); rb_fdset_t MAYBE_UNUSED(orig_write); rb_fdset_t MAYBE_UNUSED(orig_except); - struct timespec to; + struct timespec end; struct timespec ts #if defined(__GNUC__) && (__GNUC__ == 7 || __GNUC__ == 8) = {0, 0} @@ -3820,11 +3813,11 @@ do_select(int n, rb_fdset_t *const readf https://github.com/ruby/ruby/blob/trunk/thread.c#L3813 (restore_fdset(readfds, &orig_read), \ restore_fdset(writefds, &orig_write), \ restore_fdset(exceptfds, &orig_except), \ - update_timespec(&ts, &to)) + update_timespec(&ts, &end)) if (timeout) { - getclockofday(&to); - timespec_add(&to, timespec_for(&ts, timeout)); + getclockofday(&end); + timespec_add(&end, timespec_for(&ts, timeout)); } #define fd_init_copy(f) \ @@ -3958,13 +3951,13 @@ rb_wait_for_single_fd(int fd, int events https://github.com/ruby/ruby/blob/trunk/thread.c#L3951 struct pollfd fds; int result = 0, lerrno; struct timespec ts; - struct timespec to; + struct timespec end; struct timespec *tsp = 0; rb_thread_t *th = GET_THREAD(); if (timeout) { - getclockofday(&to); - timespec_add(&to, timespec_for(&ts, timeout)); + getclockofday(&end); + timespec_add(&end, timespec_for(&ts, timeout)); tsp = &ts; } @@ -3981,7 +3974,7 @@ rb_wait_for_single_fd(int fd, int events https://github.com/ruby/ruby/blob/trunk/thread.c#L3974 RUBY_VM_CHECK_INTS_BLOCKING(th->ec); } while (result < 0 && retryable(errno = lerrno) && - update_timespec(&ts, &to)); + update_timespec(&ts, &end)); if (result < 0) return -1; if (fds.revents & POLLNVAL) { -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/