aboutsummaryrefslogtreecommitdiffstats
path: root/process.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-08-21 22:17:55 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-08-21 22:17:55 +0000
commit9438bc0c86d984838dd7fe3761520832c8e5bb14 (patch)
tree5f421a23213b72dcfae0ca96cce102ae48cd7506 /process.c
parentcda87d9e00a463ac8e4d7db3b06b413a284e94a3 (diff)
downloadruby-9438bc0c86d984838dd7fe3761520832c8e5bb14.tar.gz
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
Diffstat (limited to 'process.c')
-rw-r--r--process.c44
1 files changed, 22 insertions, 22 deletions
diff --git a/process.c b/process.c
index 5b409c504a..7e9b5e9c08 100644
--- a/process.c
+++ b/process.c
@@ -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) {