changeset 10303:e4899d6320b6

data.cc: use CLOCKS_PER_SEC instead of HZ
author John W. Eaton <jwe@octave.org>
date Wed, 10 Feb 2010 16:12:13 -0500
parents 5669a0b893db
children 2ceae0b40515
files src/ChangeLog src/data.cc
diffstat 2 files changed, 15 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Wed Feb 10 15:42:59 2010 -0500
+++ b/src/ChangeLog	Wed Feb 10 16:12:13 2010 -0500
@@ -1,3 +1,8 @@
+2010-02-10  John W. Eaton  <jwe@octave.org>
+
+	* data.cc: Ensure that CLOCKS_PER_SEC is defined instead of HZ.
+	(Fcputime): Use CLOCKS_PER_SEC instead of HZ.
+
 2010-02-10  John W. Eaton  <jwe@octave.org>
 
 	* data.cc: Include <sys/times.h>.  Define HZ if it is not defined.
--- a/src/data.cc	Wed Feb 10 15:42:59 2010 -0500
+++ b/src/data.cc	Wed Feb 10 16:12:13 2010 -0500
@@ -35,6 +35,7 @@
 #endif
 
 #include <cfloat>
+#include <ctime>
 
 #include <string>
 
@@ -65,11 +66,11 @@
 #include "pager.h"
 #include "xnorm.h"
 
-#if ! defined (HZ)
+#if ! defined (CLOCKS_PER_SEC)
 #if defined (CLK_TCK)
-#define HZ CLK_TCK
+#define CLOCKS_PER_SEC CLK_TCK
 #else
-#define HZ 60
+#error "no definition for CLOCKS_PER_SEC!"
 #endif
 #endif
 
@@ -5675,18 +5676,18 @@
   unsigned long fraction;
 
   ticks = t.tms_utime + t.tms_cutime;
-  fraction = ticks % HZ;
-  seconds = ticks / HZ;
+  fraction = ticks % CLOCKS_PER_SEC;
+  seconds = ticks / CLOCKS_PER_SEC;
 
   usr = static_cast<double> (seconds) + static_cast<double>(fraction) /
-    static_cast<double>(HZ);
+    static_cast<double>(CLOCKS_PER_SEC);
 
   ticks = t.tms_stime + t.tms_cstime;
-  fraction = ticks % HZ;
-  seconds = ticks / HZ;
+  fraction = ticks % CLOCKS_PER_SEC;
+  seconds = ticks / CLOCKS_PER_SEC;
 
   sys = static_cast<double> (seconds) + static_cast<double>(fraction) /
-    static_cast<double>(HZ);
+    static_cast<double>(CLOCKS_PER_SEC);
 
 #endif