# HG changeset patch # User John W. Eaton # Date 1262900628 18000 # Node ID 0b0bf1fd1ed72b01b3af2c99dd4047f13919196e # Parent e42b1bbd1052b45b1e8d3b4008657cbcf0495b01 use gettimeofday module from gnulib diff -r e42b1bbd1052 -r 0b0bf1fd1ed7 ChangeLog --- a/ChangeLog Thu Jan 07 15:07:19 2010 -0500 +++ b/ChangeLog Thu Jan 07 16:43:48 2010 -0500 @@ -1,3 +1,9 @@ +2010-01-07 John W. Eaton + + * configure.ac: Don't check for gettimeofday, or whether + gettimeofday accepts one or two arguments. + * bootstrap.conf (gnulib_modules): Include gettimeofday in the list. + 2010-01-05 John W. Eaton * bootstrap.conf (gnulib_modules): Include mkfifo in the list. diff -r e42b1bbd1052 -r 0b0bf1fd1ed7 bootstrap.conf --- a/bootstrap.conf Thu Jan 07 15:07:19 2010 -0500 +++ b/bootstrap.conf Thu Jan 07 16:43:48 2010 -0500 @@ -20,6 +20,7 @@ gnulib_modules=" crypto/md5 fnmatch + gettimeofday glob lstat mkdir diff -r e42b1bbd1052 -r 0b0bf1fd1ed7 configure.ac --- a/configure.ac Thu Jan 07 15:07:19 2010 -0500 +++ b/configure.ac Thu Jan 07 16:43:48 2010 -0500 @@ -1433,7 +1433,7 @@ AC_CHECK_FUNCS(atexit basename bcopy bzero canonicalize_file_name \ chmod dup2 endgrent endpwent execvp expm1 expm1f fcntl fork getcwd \ getegid geteuid getgid getgrent getgrgid getgrnam getpgrp getpid \ - getppid getpwent getpwuid gettimeofday getuid getwd _kbhit kill \ + getppid getpwent getpwuid getuid getwd _kbhit kill \ lgamma lgammaf lgamma_r lgammaf_r link localtime_r log1p log1pf \ memmove mkstemp on_exit pipe poll putenv raise readlink \ realpath rename resolvepath rindex rmdir roundl select setgrent setlocale \ @@ -1580,47 +1580,6 @@ AC_SUBST(LIBOCTAVE) AC_SUBST(LIBCRUFT) -### There is more than one possible prototype for gettimeofday. See -### which one (if any) appears in sys/time.h. These tests are from -### Emacs 19. - -AC_MSG_CHECKING([for struct timeval]) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#ifdef TIME_WITH_SYS_TIME -#include -#include -#else -#ifdef HAVE_SYS_TIME_H -#include -#else -#include -#endif -#endif]], [[static struct timeval x; x.tv_sec = x.tv_usec;]])], - [AC_MSG_RESULT(yes) - HAVE_TIMEVAL=yes - AC_DEFINE(HAVE_TIMEVAL, 1, [Define if struct timeval is defined.])], - [AC_MSG_RESULT(no) - HAVE_TIMEVAL=no]) - -if test "x$HAVE_TIMEVAL" = xyes; then -AC_MSG_CHECKING([whether gettimeofday can't accept two arguments]) -AC_LINK_IFELSE([AC_LANG_PROGRAM([[#ifdef TIME_WITH_SYS_TIME -#include -#include -#else -#ifdef HAVE_SYS_TIME_H -#include -#else -#include -#endif -#endif]], [[struct timeval time; - struct timezone dummy; - gettimeofday (&time, &dummy);]])], - [AC_MSG_RESULT(no)], - [AC_MSG_RESULT(yes) - AC_DEFINE(GETTIMEOFDAY_NO_TZ, 1, - [Define if your system has a single-arg prototype for gettimeofday.])]) -fi - dnl Maybe defines the IEEE functions we need. OCTAVE_CMATH_FUNC(isnan) diff -r e42b1bbd1052 -r 0b0bf1fd1ed7 liboctave/ChangeLog --- a/liboctave/ChangeLog Thu Jan 07 15:07:19 2010 -0500 +++ b/liboctave/ChangeLog Thu Jan 07 16:43:48 2010 -0500 @@ -1,3 +1,8 @@ +2010-01-07 John W. Eaton + + * oct-time.cc (octave_time::stamp): Assume gettimeofday is + available and that it takes two arguments. + 2010-01-07 Jaroslav Hajek * lo-utils.cc (octave_fgets (FILE *, bool&)): Add OCTAVE_QUIT at the diff -r e42b1bbd1052 -r 0b0bf1fd1ed7 liboctave/oct-time.cc --- a/liboctave/oct-time.cc Thu Jan 07 15:07:19 2010 -0500 +++ b/liboctave/oct-time.cc Thu Jan 07 16:43:48 2010 -0500 @@ -85,91 +85,12 @@ void octave_time::stamp (void) { -#if defined (HAVE_GETTIMEOFDAY) - struct timeval tp; -#if defined (GETTIMEOFDAY_NO_TZ) - gettimeofday (&tp); -#else gettimeofday (&tp, 0); -#endif ot_unix_time = tp.tv_sec; ot_usec = tp.tv_usec; - -#elif defined (OCTAVE_USE_WINDOWS_API) - - // Loosely based on the code from Cygwin - // Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. - // Licenced under the GPL. - - const LONGLONG TIME_OFFSET = 0x19db1ded53e8000LL; - - static int init = 1; - static LARGE_INTEGER base; - static LARGE_INTEGER t0; - static double dt; - - if (init) - { - LARGE_INTEGER ifreq; - - if (QueryPerformanceFrequency (&ifreq)) - { - // Get clock frequency - dt = (double) 1000000.0 / (double) ifreq.QuadPart; - - // Get base time as microseconds from Jan 1. 1970 - int priority = GetThreadPriority (GetCurrentThread ()); - SetThreadPriority (GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL); - if (QueryPerformanceCounter (&base)) - { - FILETIME f; - - GetSystemTimeAsFileTime (&f); - - t0.HighPart = f.dwHighDateTime; - t0.LowPart = f.dwLowDateTime; - t0.QuadPart -= TIME_OFFSET; - t0.QuadPart /= 10; - - init = 0; - } - - SetThreadPriority (GetCurrentThread (), priority); - } - - if (! init) - { - ot_unix_time = time (0); - ot_usec = 0; - - return; - } - } - - LARGE_INTEGER now; - - if (QueryPerformanceCounter (&now)) - { - now.QuadPart = (LONGLONG) (dt * (double)(now.QuadPart - base.QuadPart)); - now.QuadPart += t0.QuadPart; - - ot_unix_time = now.QuadPart / 1000000LL; - ot_usec = now.QuadPart % 1000000LL; - } - else - { - ot_unix_time = time (0); - ot_usec = 0; - } - -#else - - ot_unix_time = time (0); - -#endif } // From the mktime() manual page: