ruby-changes:30569
From: akr <ko1@a...>
Date: Thu, 22 Aug 2013 07:18:01 +0900 (JST)
Subject: [ruby-changes:30569] akr:r42648 (trunk): Exchange order of ISO_C_CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID and
akr 2013-08-22 07:17:55 +0900 (Thu, 22 Aug 2013) New Revision: 42648 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=42648 Log: Exchange order of ISO_C_CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID and POSIX_TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID. Modified files: trunk/process.c Index: process.c =================================================================== --- process.c (revision 42647) +++ process.c (revision 42648) @@ -6764,13 +6764,6 @@ make_clock_result(struct timespec *tsp, https://github.com/ruby/ruby/blob/trunk/process.c#L6764 * getrusage() is defined by Single Unix Specification. * The result is addition of ru_utime and ru_stime. * The resolution is 1 micro second. - * [:ISO_C_CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID] - * Use clock() defined by ISO C. - * The resolution is 1/CLOCKS_PER_SEC. - * CLOCKS_PER_SEC is the C-level macro defined by time.h. - * Single Unix Specification defines CLOCKS_PER_SEC is 1000000. - * Non-Unix systems may define it a different value, though. - * If CLOCKS_PER_SEC is 1000000 as SUS, the resolution is 1 micro second. * [:POSIX_TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID] * Use times() defined by POSIX. * The result is addition of tms_utime and tms_stime. @@ -6779,6 +6772,13 @@ make_clock_result(struct timespec *tsp, https://github.com/ruby/ruby/blob/trunk/process.c#L6772 * "getconf CLK_TCK" command shows the clock ticks per second. * (The clock ticks per second is defined by HZ macro in older systems.) * If it is 100, the resolution is 10 milli second. + * [:ISO_C_CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID] + * Use clock() defined by ISO C. + * The resolution is 1/CLOCKS_PER_SEC. + * CLOCKS_PER_SEC is the C-level macro defined by time.h. + * Single Unix Specification defines CLOCKS_PER_SEC is 1000000. + * Non-Unix systems may define it a different value, though. + * If CLOCKS_PER_SEC is 1000000 as SUS, the resolution is 1 micro second. * * If the given +clock_id+ is not supported, Errno::EINVAL is raised. * @@ -6868,21 +6868,6 @@ rb_clock_gettime(int argc, VALUE *argv) https://github.com/ruby/ruby/blob/trunk/process.c#L6868 } #endif -#define RUBY_ISO_C_CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID \ - ID2SYM(rb_intern("ISO_C_CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID")) - if (clk_id == RUBY_ISO_C_CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID) { - double ns; - clock_t c; - c = clock(); - errno = 0; - if (c == (clock_t)-1) - rb_sys_fail("clock"); - ns = c * (1e9 / CLOCKS_PER_SEC); - ts.tv_sec = (time_t)(ns*1e-9); - ts.tv_nsec = ns - ts.tv_sec*1e9; - goto success; - } - #ifdef HAVE_TIMES #define RUBY_POSIX_TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID \ ID2SYM(rb_intern("POSIX_TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID")) @@ -6898,6 +6883,21 @@ rb_clock_gettime(int argc, VALUE *argv) https://github.com/ruby/ruby/blob/trunk/process.c#L6883 } #endif +#define RUBY_ISO_C_CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID \ + ID2SYM(rb_intern("ISO_C_CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID")) + if (clk_id == RUBY_ISO_C_CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID) { + double ns; + clock_t c; + c = clock(); + errno = 0; + if (c == (clock_t)-1) + rb_sys_fail("clock"); + ns = c * (1e9 / CLOCKS_PER_SEC); + ts.tv_sec = (time_t)(ns*1e-9); + ts.tv_nsec = ns - ts.tv_sec*1e9; + goto success; + } + #ifdef __APPLE__ #define RUBY_MACH_ABSOLUTE_TIME_BASED_CLOCK_MONOTONIC ID2SYM(rb_intern("MACH_ABSOLUTE_TIME_BASED_CLOCK_MONOTONIC")) if (clk_id == RUBY_MACH_ABSOLUTE_TIME_BASED_CLOCK_MONOTONIC) { -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/