Mercurial > hg > octave-lojdl
changeset 10072:0b0bf1fd1ed7
use gettimeofday module from gnulib
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Thu, 07 Jan 2010 16:43:48 -0500 |
parents | e42b1bbd1052 |
children | dcde57cb5778 |
files | ChangeLog bootstrap.conf configure.ac liboctave/ChangeLog liboctave/oct-time.cc |
diffstat | 5 files changed, 13 insertions(+), 121 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-01-07 John W. Eaton <jwe@octave.org> + + * 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 <jwe@octave.org> * bootstrap.conf (gnulib_modules): Include mkfifo in the list.
--- a/bootstrap.conf +++ b/bootstrap.conf @@ -20,6 +20,7 @@ gnulib_modules=" crypto/md5 fnmatch + gettimeofday glob lstat mkdir
--- a/configure.ac +++ b/configure.ac @@ -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 <sys/time.h> -#include <time.h> -#else -#ifdef HAVE_SYS_TIME_H -#include <sys/time.h> -#else -#include <time.h> -#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 <sys/time.h> -#include <time.h> -#else -#ifdef HAVE_SYS_TIME_H -#include <sys/time.h> -#else -#include <time.h> -#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 <cmath> defines the IEEE functions we need. OCTAVE_CMATH_FUNC(isnan)
--- a/liboctave/ChangeLog +++ b/liboctave/ChangeLog @@ -1,3 +1,8 @@ +2010-01-07 John W. Eaton <jwe@octave.org> + + * oct-time.cc (octave_time::stamp): Assume gettimeofday is + available and that it takes two arguments. + 2010-01-07 Jaroslav Hajek <highegg@gmail.com> * lo-utils.cc (octave_fgets (FILE *, bool&)): Add OCTAVE_QUIT at the
--- a/liboctave/oct-time.cc +++ b/liboctave/oct-time.cc @@ -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: