mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* thread.c (timeofday): use monotonic clock. based on a patch
from zimbatm <zimbatm@oree.ch> in [ruby-core:16627]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16338 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
1165304a5d
commit
0f1baad5a3
2 changed files with 17 additions and 3 deletions
|
@ -1,3 +1,8 @@
|
|||
Fri May 9 19:16:00 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* thread.c (timeofday): use monotonic clock. based on a patch
|
||||
from zimbatm <zimbatm@oree.ch> in [ruby-core:16627].
|
||||
|
||||
Fri May 9 07:47:07 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* cont.c (cont_restore_0): dynamic stack direction code should be
|
||||
|
|
15
thread.c
15
thread.c
|
@ -674,9 +674,18 @@ rb_thread_sleep_forever()
|
|||
static double
|
||||
timeofday(void)
|
||||
{
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, NULL);
|
||||
return (double)tv.tv_sec + (double)tv.tv_usec * 1e-6;
|
||||
#if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_MONOTONIC)
|
||||
struct timespec tp;
|
||||
|
||||
if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0) {
|
||||
return (double)tp.tv_sec + (double)tp.tv_nsec * 1e-9;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, NULL);
|
||||
return (double)tv.tv_sec + (double)tv.tv_usec * 1e-6;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
Loading…
Add table
Reference in a new issue