ruby-changes:30596
From: akr <ko1@a...>
Date: Sat, 24 Aug 2013 10:38:41 +0900 (JST)
Subject: [ruby-changes:30596] akr:r42675 (trunk): * process.c (rb_clock_gettime): The emulated clock names changed.
akr 2013-08-24 10:38:34 +0900 (Sat, 24 Aug 2013) New Revision: 42675 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=42675 Log: * process.c (rb_clock_gettime): The emulated clock names changed. Modified files: trunk/ChangeLog trunk/process.c trunk/test/ruby/test_process.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 42674) +++ ChangeLog (revision 42675) @@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sat Aug 24 10:35:09 2013 Tanaka Akira <akr@f...> + + * process.c (rb_clock_gettime): The emulated clock names changed. + Fri Aug 23 22:22:07 2013 Tanaka Akira <akr@f...> * process.c (rb_clock_gettime): Add a cast to fix compile error by Index: process.c =================================================================== --- process.c (revision 42674) +++ process.c (revision 42675) @@ -6868,13 +6868,13 @@ make_clock_result(struct timetick *ttp, https://github.com/ruby/ruby/blob/trunk/process.c#L6868 * There are emulations for clock_gettime(). * * For example, Process::CLOCK_REALTIME is defined as - * +:SUS_GETTIMEOFDAY_BASED_CLOCK_REALTIME+ when clock_gettime() is not available. + * +:GETTIMEOFDAY_BASED_CLOCK_REALTIME+ when clock_gettime() is not available. * * Emulations for +CLOCK_REALTIME+: - * [:SUS_GETTIMEOFDAY_BASED_CLOCK_REALTIME] + * [:GETTIMEOFDAY_BASED_CLOCK_REALTIME] * Use gettimeofday(). * The resolution is 1 micro second. - * [:ISO_C_TIME_BASED_CLOCK_REALTIME] + * [:TIME_BASED_CLOCK_REALTIME] * Use time(). * The resolution is 1 second. * @@ -6883,12 +6883,12 @@ make_clock_result(struct timetick *ttp, https://github.com/ruby/ruby/blob/trunk/process.c#L6883 * The resolution is CPU dependent. * * Emulations for +CLOCK_PROCESS_CPUTIME_ID+: - * [:SUS_GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID] + * [:GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID] * Use getrusage() with RUSAGE_SELF. * getrusage() is defined by Single Unix Specification. * The result is addition of ru_utime and ru_stime. * The resolution is 1 micro second. - * [:POSIX_TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID] + * [:TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID] * Use times() defined by POSIX. * The result is addition of tms_utime and tms_stime. * tms_cutime and tms_cstime are ignored. @@ -6896,7 +6896,7 @@ make_clock_result(struct timetick *ttp, https://github.com/ruby/ruby/blob/trunk/process.c#L6896 * "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] + * [: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. @@ -6952,11 +6952,11 @@ rb_clock_gettime(int argc, VALUE *argv) https://github.com/ruby/ruby/blob/trunk/process.c#L6952 * Non-clock_gettime clocks are provided by symbol clk_id. * * gettimeofday is always available on platforms supported by Ruby. - * SUS_GETTIMEOFDAY_BASED_CLOCK_REALTIME is used for + * GETTIMEOFDAY_BASED_CLOCK_REALTIME is used for * CLOCK_REALTIME if clock_gettime is not available. */ -#define RUBY_SUS_GETTIMEOFDAY_BASED_CLOCK_REALTIME ID2SYM(rb_intern("SUS_GETTIMEOFDAY_BASED_CLOCK_REALTIME")) - if (clk_id == RUBY_SUS_GETTIMEOFDAY_BASED_CLOCK_REALTIME) { +#define RUBY_GETTIMEOFDAY_BASED_CLOCK_REALTIME ID2SYM(rb_intern("GETTIMEOFDAY_BASED_CLOCK_REALTIME")) + if (clk_id == RUBY_GETTIMEOFDAY_BASED_CLOCK_REALTIME) { struct timeval tv; ret = gettimeofday(&tv, 0); if (ret != 0) @@ -6967,8 +6967,8 @@ rb_clock_gettime(int argc, VALUE *argv) https://github.com/ruby/ruby/blob/trunk/process.c#L6967 goto success; } -#define RUBY_ISO_C_TIME_BASED_CLOCK_REALTIME ID2SYM(rb_intern("ISO_C_TIME_BASED_CLOCK_REALTIME")) - if (clk_id == RUBY_ISO_C_TIME_BASED_CLOCK_REALTIME) { +#define RUBY_TIME_BASED_CLOCK_REALTIME ID2SYM(rb_intern("TIME_BASED_CLOCK_REALTIME")) + if (clk_id == RUBY_TIME_BASED_CLOCK_REALTIME) { time_t t; t = time(NULL); if (t == (time_t)-1) @@ -6980,9 +6980,9 @@ rb_clock_gettime(int argc, VALUE *argv) https://github.com/ruby/ruby/blob/trunk/process.c#L6980 } #ifdef RUSAGE_SELF -#define RUBY_SUS_GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID \ - ID2SYM(rb_intern("SUS_GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID")) - if (clk_id == RUBY_SUS_GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID) { +#define RUBY_GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID \ + ID2SYM(rb_intern("GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID")) + if (clk_id == RUBY_GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID) { struct rusage usage; int32_t usec; ret = getrusage(RUSAGE_SELF, &usage); @@ -7001,9 +7001,9 @@ rb_clock_gettime(int argc, VALUE *argv) https://github.com/ruby/ruby/blob/trunk/process.c#L7001 #endif #ifdef HAVE_TIMES -#define RUBY_POSIX_TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID \ - ID2SYM(rb_intern("POSIX_TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID")) - if (clk_id == RUBY_POSIX_TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID) { +#define RUBY_TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID \ + ID2SYM(rb_intern("TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID")) + if (clk_id == RUBY_TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID) { struct tms buf; unsigned_clock_t utime, stime; if (times(&buf) == (clock_t)-1) @@ -7021,9 +7021,9 @@ rb_clock_gettime(int argc, VALUE *argv) https://github.com/ruby/ruby/blob/trunk/process.c#L7021 } #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) { +#define RUBY_CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID \ + ID2SYM(rb_intern("CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID")) + if (clk_id == RUBY_CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID) { clock_t c; unsigned_clock_t uc; errno = 0; @@ -7340,8 +7340,8 @@ Init_process(void) https://github.com/ruby/ruby/blob/trunk/process.c#L7340 #ifdef CLOCK_REALTIME rb_define_const(rb_mProcess, "CLOCK_REALTIME", CLOCKID2NUM(CLOCK_REALTIME)); -#elif defined(RUBY_SUS_GETTIMEOFDAY_BASED_CLOCK_REALTIME) - rb_define_const(rb_mProcess, "CLOCK_REALTIME", RUBY_SUS_GETTIMEOFDAY_BASED_CLOCK_REALTIME); +#elif defined(RUBY_GETTIMEOFDAY_BASED_CLOCK_REALTIME) + rb_define_const(rb_mProcess, "CLOCK_REALTIME", RUBY_GETTIMEOFDAY_BASED_CLOCK_REALTIME); #endif #ifdef CLOCK_MONOTONIC rb_define_const(rb_mProcess, "CLOCK_MONOTONIC", CLOCKID2NUM(CLOCK_MONOTONIC)); @@ -7350,8 +7350,8 @@ Init_process(void) https://github.com/ruby/ruby/blob/trunk/process.c#L7350 #endif #ifdef CLOCK_PROCESS_CPUTIME_ID rb_define_const(rb_mProcess, "CLOCK_PROCESS_CPUTIME_ID", CLOCKID2NUM(CLOCK_PROCESS_CPUTIME_ID)); -#elif defined(RUBY_SUS_GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID) - rb_define_const(rb_mProcess, "CLOCK_PROCESS_CPUTIME_ID", RUBY_SUS_GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID); +#elif defined(RUBY_GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID) + rb_define_const(rb_mProcess, "CLOCK_PROCESS_CPUTIME_ID", RUBY_GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID); #endif #ifdef CLOCK_THREAD_CPUTIME_ID rb_define_const(rb_mProcess, "CLOCK_THREAD_CPUTIME_ID", CLOCKID2NUM(CLOCK_THREAD_CPUTIME_ID)); Index: test/ruby/test_process.rb =================================================================== --- test/ruby/test_process.rb (revision 42674) +++ test/ruby/test_process.rb (revision 42675) @@ -1681,20 +1681,20 @@ EOS https://github.com/ruby/ruby/blob/trunk/test/ruby/test_process.rb#L1681 } end - def test_clock_gettime_SUS_GETTIMEOFDAY_BASED_CLOCK_REALTIME - n = :SUS_GETTIMEOFDAY_BASED_CLOCK_REALTIME + def test_clock_gettime_GETTIMEOFDAY_BASED_CLOCK_REALTIME + n = :GETTIMEOFDAY_BASED_CLOCK_REALTIME t = Process.clock_gettime(n) assert_kind_of(Float, t, "Process.clock_gettime(:#{n})") end - def test_clock_gettime_ISO_C_TIME_BASED_CLOCK_REALTIME - n = :ISO_C_TIME_BASED_CLOCK_REALTIME + def test_clock_gettime_TIME_BASED_CLOCK_REALTIME + n = :TIME_BASED_CLOCK_REALTIME t = Process.clock_gettime(n) assert_kind_of(Float, t, "Process.clock_gettime(:#{n})") end - def test_clock_gettime_SUS_GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID - n = :SUS_GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID + def test_clock_gettime_GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID + n = :GETRUSAGE_BASED_CLOCK_PROCESS_CPUTIME_ID begin t = Process.clock_gettime(n) rescue Errno::EINVAL @@ -1703,8 +1703,8 @@ EOS https://github.com/ruby/ruby/blob/trunk/test/ruby/test_process.rb#L1703 assert_kind_of(Float, t, "Process.clock_gettime(:#{n})") end - def test_clock_gettime_POSIX_TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID - n = :POSIX_TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID + def test_clock_gettime_TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID + n = :TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID begin t = Process.clock_gettime(n) rescue Errno::EINVAL @@ -1713,8 +1713,8 @@ EOS https://github.com/ruby/ruby/blob/trunk/test/ruby/test_process.rb#L1713 assert_kind_of(Float, t, "Process.clock_gettime(:#{n})") end - def test_clock_gettime_ISO_C_CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID - n = :ISO_C_CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID + def test_clock_gettime_CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID + n = :CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID t = Process.clock_gettime(n) assert_kind_of(Float, t, "Process.clock_gettime(:#{n})") end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/