Exchange order of ISO_C_CLOCK_BASED_CLOCK_PROCESS_CPUTIME_ID and

POSIX_TIMES_BASED_CLOCK_PROCESS_CPUTIME_ID.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42648 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2013-08-21 22:17:55 +00:00
Родитель cda87d9e00
Коммит 9438bc0c86
1 изменённых файлов: 22 добавлений и 22 удалений

Просмотреть файл

@ -6764,13 +6764,6 @@ make_clock_result(struct timespec *tsp, VALUE unit)
* 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, VALUE unit)
* "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)
}
#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)
}
#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) {