changeset 22061:737b1d9d7ee3

use octave::sys::time instead of C library time function * graphics.cc, kpse.cc: Use octave::sys::time instead of calling C library time function directly. * bootstrap.conf: Drop unneeded time and times modules from list (octave::sys::time uses gettimeofday instead of calling time).
author John W. Eaton <jwe@octave.org>
date Thu, 07 Jul 2016 08:42:44 -0400
parents 9d2fc58e9eb6
children d18aad835ad6
files bootstrap.conf libinterp/corefcn/graphics.cc liboctave/util/kpse.cc
diffstat 3 files changed, 13 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/bootstrap.conf	Thu Jul 07 15:21:00 2016 +0200
+++ b/bootstrap.conf	Thu Jul 07 08:42:44 2016 -0400
@@ -106,8 +106,6 @@
   sys_times
   sys_wait
   tempname
-  time
-  times
   tmpfile
   trunc
   truncf
--- a/libinterp/corefcn/graphics.cc	Thu Jul 07 15:21:00 2016 +0200
+++ b/libinterp/corefcn/graphics.cc	Thu Jul 07 08:42:44 2016 -0400
@@ -27,7 +27,6 @@
 #include <cctype>
 #include <cfloat>
 #include <cstdlib>
-#include <ctime>
 
 #include <algorithm>
 #include <list>
@@ -40,6 +39,7 @@
 #include "file-ops.h"
 #include "file-stat.h"
 #include "oct-locbuf.h"
+#include "oct-time.h"
 #include "singleton-cleanup.h"
 
 #include "builtins.h"
@@ -11506,7 +11506,7 @@
   int max_arg_index = 0;
   int timeout_index = -1;
 
-  int timeout = 0;
+  double timeout = 0;
 
   if (args.length () > 1)
     {
@@ -11621,8 +11621,7 @@
       if (args.length () <= (timeout_index + 1))
         error ("waitfor: missing TIMEOUT value");
 
-      timeout = static_cast<int>
-        (args(timeout_index + 1).xscalar_value ("waitfor: TIMEOUT must be a scalar >= 1"));
+      timeout = args(timeout_index + 1).xscalar_value ("waitfor: TIMEOUT must be a scalar >= 1");
 
       if (timeout < 1)
         {
@@ -11646,10 +11645,10 @@
   //        The only "good" implementation would require object
   //        listeners, similar to property listeners.
 
-  time_t start = 0;
+  octave::sys::time start;
 
   if (timeout > 0)
-    start = time (0);
+    start.stamp ();
 
   while (true)
     {
@@ -11676,7 +11675,9 @@
 
       if (timeout > 0)
         {
-          if (start + timeout < time (0))
+          octave::sys::time now;
+
+          if (start + timeout < now)
             break;
         }
     }
--- a/liboctave/util/kpse.cc	Thu Jul 07 15:21:00 2016 +0200
+++ b/liboctave/util/kpse.cc	Thu Jul 07 08:42:44 2016 -0400
@@ -33,7 +33,6 @@
 #include <cctype>
 #include <cerrno>
 #include <cstdlib>
-#include <ctime>
 
 #include <map>
 #include <fstream>
@@ -46,6 +45,7 @@
 #include "kpse.h"
 #include "oct-env.h"
 #include "oct-passwd.h"
+#include "oct-time.h"
 #include "pathsearch.h"
 #include "unistd-wrappers.h"
 
@@ -264,7 +264,10 @@
   if (KPSE_DEBUG_P (KPSE_DEBUG_SEARCH))
     {
       for (const auto &filename : filenames)
-        std::cerr << time (0) << " " << filename << std::endl;
+        {
+          octave::sys::time now;
+          std::cerr << now.unix_time () << " " << filename << std::endl;
+        }
     }
 }