ruby-changes:30573
From: akr <ko1@a...>
Date: Thu, 22 Aug 2013 22:04:14 +0900 (JST)
Subject: [ruby-changes:30573] akr:r42652 (trunk): * process.c (rb_clock_gettime): Strip "s" from unit names.
akr 2013-08-22 22:04:06 +0900 (Thu, 22 Aug 2013) New Revision: 42652 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=42652 Log: * process.c (rb_clock_gettime): Strip "s" from unit names. Modified files: trunk/ChangeLog trunk/process.c trunk/test/ruby/test_process.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 42651) +++ ChangeLog (revision 42652) @@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Thu Aug 22 22:01:04 2013 Tanaka Akira <akr@f...> + + * process.c (rb_clock_gettime): Strip "s" from unit names. + Thu Aug 22 20:14:59 2013 Tanaka Akira <akr@f...> * process.c (unsigned_clock_t): Defined. Index: process.c =================================================================== --- process.c (revision 42651) +++ process.c (revision 42652) @@ -6672,27 +6672,27 @@ make_clock_result(struct timespec *tsp, https://github.com/ruby/ruby/blob/trunk/process.c#L6672 { long factor; - if (unit == ID2SYM(rb_intern("nanoseconds"))) { + if (unit == ID2SYM(rb_intern("nanosecond"))) { factor = 1000000000; goto return_integer; } - else if (unit == ID2SYM(rb_intern("microseconds"))) { + else if (unit == ID2SYM(rb_intern("microsecond"))) { factor = 1000000; goto return_integer; } - else if (unit == ID2SYM(rb_intern("milliseconds"))) { + else if (unit == ID2SYM(rb_intern("millisecond"))) { factor = 1000; goto return_integer; } - else if (unit == ID2SYM(rb_intern("float_microseconds"))) { + else if (unit == ID2SYM(rb_intern("float_microsecond"))) { factor = 1000000; goto return_float; } - else if (unit == ID2SYM(rb_intern("float_milliseconds"))) { + else if (unit == ID2SYM(rb_intern("float_millisecond"))) { factor = 1000; goto return_float; } - else if (NIL_P(unit) || unit == ID2SYM(rb_intern("float_seconds"))) { + else if (NIL_P(unit) || unit == ID2SYM(rb_intern("float_second"))) { factor = 1; goto return_float; } @@ -6792,12 +6792,12 @@ make_clock_result(struct timespec *tsp, https://github.com/ruby/ruby/blob/trunk/process.c#L6792 * * +unit+ specifies a type of the return value. * - * [:float_seconds] number of seconds as a float (default) - * [:float_milliseconds] number of milliseconds as a float - * [:float_microseconds] number of microseconds as a float - * [:milliseconds] number of milliseconds as an integer - * [:microseconds] number of microseconds as an integer - * [:nanoseconds] number of nanoseconds as an integer + * [:float_second] number of seconds as a float (default) + * [:float_millisecond] number of milliseconds as a float + * [:float_microsecond] number of microseconds as a float + * [:millisecond] number of milliseconds as an integer + * [:microsecond] number of microseconds as an integer + * [:nanosecond] number of nanoseconds as an integer * * The underlying function, clock_gettime(), returns a number of nanoseconds. * Float object (IEEE 754 double) is not enough to represent Index: test/ruby/test_process.rb =================================================================== --- test/ruby/test_process.rb (revision 42651) +++ test/ruby/test_process.rb (revision 42652) @@ -1661,9 +1661,9 @@ EOS https://github.com/ruby/ruby/blob/trunk/test/ruby/test_process.rb#L1661 end if windows? def test_clock_gettime - t1 = Process.clock_gettime(Process::CLOCK_REALTIME, :nanoseconds) + t1 = Process.clock_gettime(Process::CLOCK_REALTIME, :nanosecond) t2 = Time.now; t2 = t2.tv_sec * 1000000000 + t2.tv_nsec - t3 = Process.clock_gettime(Process::CLOCK_REALTIME, :nanoseconds) + t3 = Process.clock_gettime(Process::CLOCK_REALTIME, :nanosecond) assert_operator(t1, :<=, t2) assert_operator(t2, :<=, t3) assert_raise(Errno::EINVAL) { Process.clock_gettime(:foo) } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/