changeset 10240:fa7b5751730c

use gnulib time, sys_time, and sys_times modules
author John W. Eaton <jwe@octave.org>
date Tue, 02 Feb 2010 00:53:31 -0500
parents e45ccac6017f
children a277ba5da4dc
files ChangeLog bootstrap.conf configure.ac liboctave/ChangeLog liboctave/Makefile.am liboctave/oct-time.cc liboctave/oct-time.h liboctave/systime.h src/ChangeLog src/DLD-FUNCTIONS/getrusage.cc src/cutils.c src/data.cc
diffstat 12 files changed, 46 insertions(+), 106 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Feb 02 00:51:52 2010 -0500
+++ b/ChangeLog	Tue Feb 02 00:53:31 2010 -0500
@@ -1,3 +1,11 @@
+2010-02-02  John W. Eaton  <jwe@octave.org>
+
+	* bootstrap.conf (gnulib_modules): Include sys_time, sys_times,
+	and time in the list.
+	* configure.ac: Don't check for sys/time.h, sys/times.h,
+	sys/stat.h, sys/utimes, or utimes.h.
+	Don't call AC_HEADER_TIME.
+
 2010-02-02  John W. Eaton  <jwe@octave.org>
 
 	* acinclue.m4 (OCTAVE_STRPTIME_BROKEN): Delete.
--- a/bootstrap.conf	Tue Feb 02 00:51:52 2010 -0500
+++ b/bootstrap.conf	Tue Feb 02 00:53:31 2010 -0500
@@ -37,6 +37,9 @@
   strptime
   symlink
   sys_stat
+  sys_time
+  sys_times
+  time
   times
   unistd
   unlink
--- a/configure.ac	Tue Feb 02 00:51:52 2010 -0500
+++ b/configure.ac	Tue Feb 02 00:53:31 2010 -0500
@@ -1451,7 +1451,6 @@
 
 AC_HEADER_STDC
 AC_HEADER_DIRENT
-AC_HEADER_TIME
 AC_HEADER_SYS_WAIT
 
 ### C headers
@@ -1459,9 +1458,8 @@
 AC_CHECK_HEADERS(curses.h direct.h dlfcn.h fcntl.h \
   floatingpoint.h grp.h ieeefp.h inttypes.h locale.h memory.h nan.h \
   ncurses.h poll.h pthread.h pwd.h stdint.h sunmath.h sys/ioctl.h \
-  sys/param.h sys/poll.h sys/resource.h sys/select.h sys/stat.h \
-  sys/time.h sys/times.h sys/utsname.h sys/utime.h termcap.h \
-  utime.h)
+  sys/param.h sys/poll.h sys/resource.h sys/select.h \
+  sys/utsname.h termcap.h)
 
 ### C++ headers
 
--- a/liboctave/ChangeLog	Tue Feb 02 00:51:52 2010 -0500
+++ b/liboctave/ChangeLog	Tue Feb 02 00:53:31 2010 -0500
@@ -1,3 +1,12 @@
+2010-02-02  John W. Eaton  <jwe@octave.org>
+
+	* oct-time.h: Include <ctime>, not "systime.h".
+	* oct-time.cc: Include <strftime.h>, not "strftime.h".
+	Don't include <windows.h>.
+
+	* systime.h: Delete.
+	* Makefile.am (INCS): Remove it from the list.
+
 2010-02-02  John W. Eaton  <jwe@octave.org>
 
 	* lo-utils.h, lo-cutils.c (oct_strptime): Delete.
--- a/liboctave/Makefile.am	Tue Feb 02 00:51:52 2010 -0500
+++ b/liboctave/Makefile.am	Tue Feb 02 00:53:31 2010 -0500
@@ -243,7 +243,6 @@
   str-vec.h \
   sun-utils.h \
   sysdir.h \
-  systime.h \
   syswait.h \
   $(MATRIX_INC)
 
--- a/liboctave/oct-time.cc	Tue Feb 02 00:51:52 2010 -0500
+++ b/liboctave/oct-time.cc	Tue Feb 02 00:53:31 2010 -0500
@@ -27,18 +27,11 @@
 #include <climits>
 #include <ctime>
 
+#include <sys/time.h>
 #include <sys/types.h>
 #include <unistd.h>
 
-#if defined (OCTAVE_USE_WINDOWS_API)
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-#undef min
-#undef max
-#endif
-
-#include <sys/time.h>
-#include "strftime.h"
+#include <strftime.h>
 
 #include "lo-error.h"
 #include "lo-math.h"
--- a/liboctave/oct-time.h	Tue Feb 02 00:51:52 2010 -0500
+++ b/liboctave/oct-time.h	Tue Feb 02 00:53:31 2010 -0500
@@ -23,10 +23,10 @@
 #if !defined (octave_time_h)
 #define octave_time_h 1
 
+#include <ctime>
 #include <string>
 
 #include "lo-math.h"
-#include "systime.h"
 
 class octave_base_tm;
 
--- a/liboctave/systime.h	Tue Feb 02 00:51:52 2010 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,37 +0,0 @@
-/*
-
-Copyright (C) 1996, 1997, 1999, 2005, 2007 John W. Eaton
-
-This file is part of Octave.
-
-Octave is free software; you can redistribute it and/or modify it
-under the terms of the GNU General Public License as published by the
-Free Software Foundation; either version 3 of the License, or (at your
-option) any later version.
-
-Octave is distributed in the hope that it will be useful, but WITHOUT
-ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License
-along with Octave; see the file COPYING.  If not, see
-<http://www.gnu.org/licenses/>.
-
-*/
-
-#if !defined (octave_systime_h)
-#define octave_systime_h 1
-
-#ifdef TIME_WITH_SYS_TIME
-#include <sys/time.h>
-#include <time.h>
-#else
-#ifdef HAVE_SYS_TIME_H
-#include <sys/time.h>
-#else
-#include <time.h>
-#endif
-#endif
-
-#endif
--- a/src/ChangeLog	Tue Feb 02 00:51:52 2010 -0500
+++ b/src/ChangeLog	Tue Feb 02 00:53:31 2010 -0500
@@ -1,3 +1,12 @@
+2010-02-02  John W. Eaton  <jwe@octave.org>
+
+	* cutils.c: Include <sys/times.h>, not "systime.h".
+	* data.cc (Fcputime): Assume we have times.
+
+	* DLD-FUNCTIONS/getrusage.cc (Fgetrusage): Assume we have times.
+	Include <times.h> and <sys/times.h> unconditionally.
+	Don't include <windows.h>
+
 2010-02-01  Jaroslav Hajek  <highegg@gmail.com>
 
 	* strfns.cc (Fstrncmpi): Fix typo in docstring.
--- a/src/DLD-FUNCTIONS/getrusage.cc	Tue Feb 02 00:51:52 2010 -0500
+++ b/src/DLD-FUNCTIONS/getrusage.cc	Tue Feb 02 00:53:31 2010 -0500
@@ -25,28 +25,24 @@
 #include <config.h>
 #endif
 
-#include "systime.h"
-
+#include <sys/time.h>
+#include <sys/times.h>
 #include <sys/types.h>
 
 #ifdef HAVE_SYS_RESOURCE_H
 #include <sys/resource.h>
 #endif
 
-#if defined (__WIN32__)
-#include <windows.h>
-#ifdef min
-#undef min
-#undef max
-#endif
-#endif
-
-#if defined (HAVE_TIMES) && defined (HAVE_SYS_TIMES_H)
-
 #if defined (HAVE_SYS_PARAM_H)
 #include <sys/param.h>
 #endif
-#include <sys/times.h>
+
+#include "defun-dld.h"
+#include "oct-map.h"
+#include "sysdep.h"
+#include "ov.h"
+#include "oct-obj.h"
+#include "utils.h"
 
 #if !defined (HZ)
 #if defined (CLK_TCK)
@@ -58,15 +54,6 @@
 #endif
 #endif
 
-#endif
-
-#include "defun-dld.h"
-#include "oct-map.h"
-#include "sysdep.h"
-#include "ov.h"
-#include "oct-obj.h"
-#include "utils.h"
-
 #ifndef RUSAGE_SELF
 #define RUSAGE_SELF 0
 #endif
@@ -172,7 +159,6 @@
 #endif
 
 #else
-#if defined (HAVE_TIMES) && defined (HAVE_SYS_TIMES_H)
 
   struct tms t;
 
@@ -198,32 +184,6 @@
   tv_tmp.assign ("usec", static_cast<double> (fraction * 1e6 / HZ));
   m.assign ("stime", octave_value (tv_tmp));
 
-#elif defined (__WIN32__)
-  HANDLE hProcess = GetCurrentProcess ();
-  FILETIME ftCreation, ftExit, ftUser, ftKernel;
-  GetProcessTimes (hProcess, &ftCreation, &ftExit, &ftKernel, &ftUser);
-
-  int64_t itmp = *(reinterpret_cast<int64_t *> (&ftUser));
-  tv_tmp.assign ("sec", static_cast<double> (itmp / 10000000U));
-  tv_tmp.assign ("usec", static_cast<double> (itmp % 10000000U) / 10.);
-  m.assign ("utime", octave_value (tv_tmp));
-
-  itmp = *(reinterpret_cast<int64_t *> (&ftKernel));
-  tv_tmp.assign ("sec", static_cast<double> (itmp / 10000000U));
-  tv_tmp.assign ("usec", static_cast<double> (itmp % 10000000U) / 10.);
-  m.assign ("stime", octave_value (tv_tmp));
-#else
-
-  tv_tmp.assign ("sec", 0);
-  tv_tmp.assign ("usec", 0);
-  m.assign ("utime", octave_value (tv_tmp));
-
-  tv_tmp.assign ("sec", 0);
-  tv_tmp.assign ("usec", 0);
-  m.assign ("stime", octave_value (tv_tmp));
-
-#endif
-
   double tmp = lo_ieee_nan_value ();
 
   m.assign ("maxrss", tmp);
--- a/src/cutils.c	Tue Feb 02 00:51:52 2010 -0500
+++ b/src/cutils.c	Tue Feb 02 00:53:31 2010 -0500
@@ -35,11 +35,10 @@
 
 #else
 
+#include <sys/time.h>
 #include <sys/types.h>
 #include <unistd.h>
 
-#include "systime.h"
-
 #ifdef HAVE_POLL_H
 #include <poll.h>
 #elif HAVE_SYS_POLL_H
--- a/src/data.cc	Tue Feb 02 00:51:52 2010 -0500
+++ b/src/data.cc	Tue Feb 02 00:53:31 2010 -0500
@@ -27,8 +27,6 @@
 #include <config.h>
 #endif
 
-#include "systime.h"
-
 #include <sys/types.h>
 
 #ifdef HAVE_SYS_RESOURCE_H
@@ -41,6 +39,7 @@
 
 #include "lo-ieee.h"
 #include "lo-math.h"
+#include "oct-time.h"
 #include "str-vec.h"
 #include "quit.h"
 #include "mx-base.h"
@@ -5667,7 +5666,7 @@
   sys = static_cast<double> (ru.ru_stime.tv_sec) +
     static_cast<double> (ru.ru_stime.tv_usec) * 1e-6;
 
-#elif defined (HAVE_TIMES) && defined (HAVE_SYS_TIMES_H)
+#else
 
   struct tms t;