ruby-changes:50063
From: normal <ko1@a...>
Date: Sun, 4 Feb 2018 04:59:16 +0900 (JST)
Subject: [ruby-changes:50063] normal:r62181 (trunk): thread.c: extract timeval_sub from timeval_update_expire
normal 2018-02-04 04:59:11 +0900 (Sun, 04 Feb 2018) New Revision: 62181 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=62181 Log: thread.c: extract timeval_sub from timeval_update_expire It can be useful on its own. Modified files: trunk/thread.c Index: thread.c =================================================================== --- thread.c (revision 62180) +++ thread.c (revision 62181) @@ -1160,6 +1160,16 @@ timeval_add(struct timeval *dst, const s https://github.com/ruby/ruby/blob/trunk/thread.c#L1160 } } +static void +timeval_sub(struct timeval *dst, const struct timeval *tv) +{ + dst->tv_sec -= tv->tv_sec; + if ((dst->tv_usec -= tv->tv_usec) < 0) { + --dst->tv_sec; + dst->tv_usec += 1000000; + } +} + static int timeval_update_expire(struct timeval *tv, const struct timeval *to) { @@ -1172,11 +1182,8 @@ timeval_update_expire(struct timeval *tv https://github.com/ruby/ruby/blob/trunk/thread.c#L1182 "%"PRI_TIMET_PREFIX"d.%.6ld > %"PRI_TIMET_PREFIX"d.%.6ld\n", (time_t)to->tv_sec, (long)to->tv_usec, (time_t)tvn.tv_sec, (long)tvn.tv_usec); - tv->tv_sec = to->tv_sec - tvn.tv_sec; - if ((tv->tv_usec = to->tv_usec - tvn.tv_usec) < 0) { - --tv->tv_sec; - tv->tv_usec += 1000000; - } + *tv = *to; + timeval_sub(tv, &tvn); return 0; } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/