ruby-changes:30574
From: nagachika <ko1@a...>
Date: Fri, 23 Aug 2013 01:15:05 +0900 (JST)
Subject: [ruby-changes:30574] nagachika:r42653 (ruby_2_0_0): merge revision(s) 42639: [Backport #8805]
nagachika 2013-08-23 01:14:58 +0900 (Fri, 23 Aug 2013) New Revision: 42653 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=42653 Log: merge revision(s) 42639: [Backport #8805] * gc.c (getrusage_time): Fallback clock_gettime to getrusage when clock_gettime fails. Reported by Eric Saxby. [ruby-core:56762] [Bug #8805] Modified directories: branches/ruby_2_0_0/ Modified files: branches/ruby_2_0_0/ChangeLog branches/ruby_2_0_0/gc.c branches/ruby_2_0_0/version.h Index: ruby_2_0_0/ChangeLog =================================================================== --- ruby_2_0_0/ChangeLog (revision 42652) +++ ruby_2_0_0/ChangeLog (revision 42653) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ChangeLog#L1 +Fri Aug 23 00:55:02 2013 Tanaka Akira <akr@f...> + + * gc.c (getrusage_time): Fallback clock_gettime to getrusage when + clock_gettime fails. + Reported by Eric Saxby. [ruby-core:56762] [Bug #8805] + Sat Aug 17 00:42:12 2013 Kazuhiro NISHIYAMA <zn@m...> * parse.y: fix build error with bison-3.0. Index: ruby_2_0_0/gc.c =================================================================== --- ruby_2_0_0/gc.c (revision 42652) +++ ruby_2_0_0/gc.c (revision 42653) @@ -3879,43 +3879,54 @@ static double https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/gc.c#L3879 getrusage_time(void) { #if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_PROCESS_CPUTIME_ID) - struct timespec ts; - - if (clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts) == 0) { - return ts.tv_sec + ts.tv_nsec * 1e-9; + { + static int try_clock_gettime = 1; + struct timespec ts; + if (try_clock_gettime && clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts) == 0) { + return ts.tv_sec + ts.tv_nsec * 1e-9; + } + else { + try_clock_gettime = 0; + } } - return 0.0; -#elif defined RUSAGE_SELF - struct rusage usage; - struct timeval time; - getrusage(RUSAGE_SELF, &usage); - time = usage.ru_utime; - return time.tv_sec + time.tv_usec * 1e-6; -#elif defined _WIN32 - FILETIME creation_time, exit_time, kernel_time, user_time; - ULARGE_INTEGER ui; - LONG_LONG q; - double t; +#endif - if (GetProcessTimes(GetCurrentProcess(), - &creation_time, &exit_time, &kernel_time, &user_time) == 0) +#ifdef RUSAGE_SELF { - return 0.0; + struct rusage usage; + struct timeval time; + if (getrusage(RUSAGE_SELF, &usage) == 0) { + time = usage.ru_utime; + return time.tv_sec + time.tv_usec * 1e-6; + } } - memcpy(&ui, &user_time, sizeof(FILETIME)); - q = ui.QuadPart / 10L; - t = (DWORD)(q % 1000000L) * 1e-6; - q /= 1000000L; +#endif + +#ifdef _WIN32 + { + FILETIME creation_time, exit_time, kernel_time, user_time; + ULARGE_INTEGER ui; + LONG_LONG q; + double t; + + if (GetProcessTimes(GetCurrentProcess(), + &creation_time, &exit_time, &kernel_time, &user_time) != 0) { + memcpy(&ui, &user_time, sizeof(FILETIME)); + q = ui.QuadPart / 10L; + t = (DWORD)(q % 1000000L) * 1e-6; + q /= 1000000L; #ifdef __GNUC__ - t += q; + t += q; #else - t += (double)(DWORD)(q >> 16) * (1 << 16); - t += (DWORD)q & ~(~0 << 16); + t += (double)(DWORD)(q >> 16) * (1 << 16); + t += (DWORD)q & ~(~0 << 16); #endif - return t; -#else - return 0.0; + return t; + } + } #endif + + return 0.0; } static inline void Index: ruby_2_0_0/version.h =================================================================== --- ruby_2_0_0/version.h (revision 42652) +++ ruby_2_0_0/version.h (revision 42653) @@ -1,10 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/version.h#L1 #define RUBY_VERSION "2.0.0" -#define RUBY_RELEASE_DATE "2013-08-17" -#define RUBY_PATCHLEVEL 295 +#define RUBY_RELEASE_DATE "2013-08-23" +#define RUBY_PATCHLEVEL 296 #define RUBY_RELEASE_YEAR 2013 #define RUBY_RELEASE_MONTH 8 -#define RUBY_RELEASE_DAY 17 +#define RUBY_RELEASE_DAY 23 #include "ruby/version.h" Property changes on: ruby_2_0_0 ___________________________________________________________________ Modified: svn:mergeinfo Merged /trunk:r42639 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/