mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* process.c (rb_clock_gettime): Strip "s" from unit names.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42652 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
3873e09cad
commit
a641003f66
3 changed files with 18 additions and 14 deletions
|
@ -1,3 +1,7 @@
|
|||
Thu Aug 22 22:01:04 2013 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* process.c (rb_clock_gettime): Strip "s" from unit names.
|
||||
|
||||
Thu Aug 22 20:14:59 2013 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* process.c (unsigned_clock_t): Defined.
|
||||
|
|
24
process.c
24
process.c
|
@ -6672,27 +6672,27 @@ make_clock_result(struct timespec *tsp, VALUE unit)
|
|||
{
|
||||
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, VALUE unit)
|
|||
*
|
||||
* +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
|
||||
|
|
|
@ -1661,9 +1661,9 @@ EOS
|
|||
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) }
|
||||
|
|
Loading…
Add table
Reference in a new issue