summaryrefslogtreecommitdiff
path: root/process.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-07-06 14:30:20 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-07-06 14:30:20 +0000
commitac2348271a90f724ed3254b5e7a06e9064ec255f (patch)
tree08e2bcaa30e9e158283e773d45c6fbbefa7f2906 /process.c
parent69aeed5065cdedaa48c9fcc09185a8df354391a7 (diff)
* process.c (rb_proc_times): use sysconf(_SC_CLK_TCK) value prior to
HZ and CLK_TCK. fixed: [ruby-talk:200293] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10476 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'process.c')
-rw-r--r--process.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/process.c b/process.c
index 97a45d5986..5b4672b0e0 100644
--- a/process.c
+++ b/process.c
@@ -3516,6 +3516,10 @@ VALUE
rb_proc_times(VALUE obj)
{
#if defined(HAVE_TIMES) && !defined(__CHECKER__)
+ const double hz =
+#ifdef HAVE__SC_CLK_TCK
+ (double)sysconf(_SC_CLK_TCK);
+#else
#ifndef HZ
# ifdef CLK_TCK
# define HZ CLK_TCK
@@ -3523,15 +3527,17 @@ rb_proc_times(VALUE obj)
# define HZ 60
# endif
#endif /* HZ */
+ HZ;
+#endif
struct tms buf;
volatile VALUE utime, stime, cutime, sctime;
times(&buf);
return rb_struct_new(S_Tms,
- utime = rb_float_new((double)buf.tms_utime / HZ),
- stime = rb_float_new((double)buf.tms_stime / HZ),
- cutime = rb_float_new((double)buf.tms_cutime / HZ),
- sctime = rb_float_new((double)buf.tms_cstime / HZ));
+ utime = rb_float_new(buf.tms_utime / hz),
+ stime = rb_float_new(buf.tms_stime / hz),
+ cutime = rb_float_new(buf.tms_cutime / hz),
+ sctime = rb_float_new(buf.tms_cstime / hz));
#else
rb_notimplement();
#endif