ruby-changes:6839
From: nobu <ko1@a...>
Date: Mon, 4 Aug 2008 15:05:11 +0900 (JST)
Subject: [ruby-changes:6839] Ruby:r18355 (ruby_1_8): * eval.c (timeofday): use monotonic clock. based on a patch
nobu 2008-08-04 15:04:57 +0900 (Mon, 04 Aug 2008) New Revision: 18355 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=18355 Log: * eval.c (timeofday): use monotonic clock. based on a patch from zimbatm <zimbatm@o...> in [ruby-core:16627]. Modified files: branches/ruby_1_8/ChangeLog branches/ruby_1_8/configure.in branches/ruby_1_8/eval.c Index: ruby_1_8/configure.in =================================================================== --- ruby_1_8/configure.in (revision 18354) +++ ruby_1_8/configure.in (revision 18355) @@ -541,6 +541,7 @@ AC_CHECK_LIB(crypt, crypt) AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX +AC_CHECK_LIB(rt, clock_gettime) # GNU/Linux case "$target_cpu" in alpha*) case "$target_os"::"$GCC" in Index: ruby_1_8/ChangeLog =================================================================== --- ruby_1_8/ChangeLog (revision 18354) +++ ruby_1_8/ChangeLog (revision 18355) @@ -1,3 +1,8 @@ +Mon Aug 4 15:04:36 2008 Nobuyoshi Nakada <nobu@r...> + + * eval.c (timeofday): use monotonic clock. based on a patch + from zimbatm <zimbatm@o...> in [ruby-core:16627]. + Mon Aug 4 14:39:06 2008 URABE Shyouhei <shyouhei@r...> * lib/net/smtp.rb (Net::SMTP::rcptto): fix a typo. a patch from Index: ruby_1_8/eval.c =================================================================== --- ruby_1_8/eval.c (revision 18354) +++ ruby_1_8/eval.c (revision 18355) @@ -72,6 +72,8 @@ #include <unistd.h> #endif +#include <time.h> + #ifdef __BEOS__ #include <net/socket.h> #endif @@ -10363,6 +10365,13 @@ timeofday() { struct timeval tv; +#ifdef CLOCK_MONOTONIC + struct timespec tp; + + if (clock_gettime(CLOCK_MONOTONIC, &tp) == 0) { + return (double)tp.tv_sec + (double)tp.tv_nsec * 1e-9; + } +#endif gettimeofday(&tv, NULL); return (double)tv.tv_sec + (double)tv.tv_usec * 1e-6; } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/