bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Status of the win32 gettimeofday module


From: Paul Eggert
Subject: Re: Status of the win32 gettimeofday module
Date: Thu, 18 Jan 2007 00:41:51 -0800
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux)

Bruno Haible <address@hidden> writes:

> - Coreutils has a comment explaining why it is useful to compute the
>   microseconds as
>      milliseconds * 1000 + 999
>   rather than as
>      milliseconds * 1000.

It's useful for that particular case, but there are other cases
where it's not useful (e.g., when 'date' outputs the time to
the nearest nanosecond).  In general I think it's better to
preserve time stamps when converting to a higher precision,
and to truncate towards minus infinity when converting to
a lower one.  This is a consistent rule and is easy for people
to follow.

I had independently constructed most (all?) the other patches you were
thinking of, and came up with the following extended patch as a more
general cleanup in the area.

The main idea here is that we should try to avoid separate include
files like "gettimeofday.h" for declarations that POSIX says should be
in a standard file like <sys/time.h>.  Instead, we should patch
<sys/time.h> by wrapping it; that way the user code can just code to
the POSIX standard.

A subsidiary idea is that timespec.h should do only struct timespec
related stuff in gnulib; it shouldn't mess with struct timeval.

More cleanup could be done to remove obsolescent time-related macros,
and to wrap <time.h> to put struct timespec and other stuff there, but
I think the following is a relatively sane stopping point for now.

2007-01-17  Paul Eggert  <address@hidden>

        * MODULES.html.sh (Support for systems lacking POSIX:2001): New
        module sys_time.
        * lib/gethrxtime.c: Include <sys/time.h>, since we can no longer
        assume timespec.h defines struct timeval.
        * lib/settime.c: Likewise.
        * lib/utimens.c: Likewise.
        * lib/gettime.c (gettime): Remove test against HAVE_GETTIMEOFDAY,
        since we now assume the gettimeofday module.
        * lib/tempname.c (__gen_tempname): Likewise.
        * lib/gettimeofday.h: Remove.
        * lib/gettimeofday.c: Include <sys/time.h> instead of "gettimeofday.h".
        Don't include <sys/types.h> and <stdlib.h>; shouldn't be needed.
        Include <time.h>, for 'time()'.
        (localtime_buffer_addr): Also use this workaround if
        TZSET_CLOBBERS_LOCALTIME.  Set to a dummy static variable by default,
        to simplify the uses.  All uses changed.
        (localtime, gmtime, tzset, gettimeofday): Reformat slightly so
        that #undef is inside {}, and 'const' follows type name consistently.
        (tzset): Define replacement only if TZSET_CLOBBERS_LOCALTIME.
        (gettimeofday): Do not use the maximum possible value for
        tv->tv_usec, since that might break usages other than ls.c.
        Instead, we'll leave ls.c alone.  This undoes today's patch
        by Bruno.  Add a compile-time warning for 1s-clock resolution;
        we've never observed the problem but might as well keep the
        canary.
        * lib/nanosleep.c: Include timespec.h first, for interface check.
        * lib/nanosleep.c: Include <sys/time.h> unconditionally, since we
        now assume the sys_time module.
        * lib/tempname.c: Likewise.
        * lib/timespec.h: Likewise.
        * lib/nanosleep.c: Don't worry about TIME_WITH_SYS_TIME; no longer
        needed.
        * lib/strftime.c: Likewise.
        * lib/timespec.h: Likewise.
        * lib/posixtm.c: Include posixtm.h first, for interface check.
        Don't worry about TM_IN_SYS_TIME; that's wayyy obsolete.
        * lib/posixtm.h: Include stdbool.h and time.h, for proper interface.
        * lib/strftime.c: Don't include <sys/types.h>; shouldn't be needed.
        * lib/sys_time_.h: New file.
        * lib/timespec.h (struct timespec): Use long int, not long.
        * m4/gettimeofday.m4 (gl_FUNC_GETTIMEOFDAY):
        (gl_FUNC_GETTIMEOFDAY_CLOBBER, gl_PREREQ_GETTIMEOFDAY):
        Remove obsolescent call to AC_HEADER_TIME.
        * m4/mktime.m4 (AC_FUNC_MKTIME): Likewise.
        * m4/nanosleep.m4 (gl_FUNC_NANOSLEEP): Likewise.
        * m4/strftime.m4 (gl_FUNC_STRFTIME): Likewise.
        * m4/timespec.m4 (gl_TIMESPEC, gl_CHECK_TYPE_STRUCT_TIMESPEC):
        Likewise.
        * m4/tzset.m4 (gl_FUNC_TZSET_CLOBBER): Likewise.
        * m4/utimbuf.m4 (gl_CHECK_TYPE_STRUCT_UTIMBUF): Likewise.
        * m4/gettimeofday.m4 (gl_FUNC_GETTIMEOFDAY): Move sys/time.h tests
        into the sys_time module.  Check for gettimeofday just once.
        Prefix our variables with gl_, not with ac_ or jm_.  Tighten test
        for gettimeofday signature to just check the signature.  Merely
        compile it, since linking doesn't test signature.  Improve test for
        whether gettimeofday.o is actually needed.
        (gl_FUNC_GETTIMEOFDAY_CLOBBER): Renamed from
        AC_FUNC_GETTIMEOFDAY_CLOBBER.  All uses changed.  Use
        AC_RUN_IFELSE rather than AC_TRY_RUN.  If clobbering, set
        and define GETTIMEOFDAY_CLOBBERS_LOCALTIME.
        (gl_GETTIMEOFDAY_REPLACE_LOCALTIME): Don't define
        GETTIMEOFDAY_CLOBBERS_LOCALTIME; that's gl_FUNC_GETTIMEOFDAY_CLOBBER's
        job.  Don't define tzset; that's gl_FUNC_TZSET_CLOBBER's job.
        * m4/mktime.m4 (AC_FUNC_MKTIME): Just include <time.h> rather
        than worrying about sys/time.h.
        * m4/nanosleep.m4 (gl_FUNC_NANOSLEEP):
        Don't bother worrying about TIME_WITH_SYS_TIME.
        * m4/stat-time.m4 (gl_STAT_TIME): Likewise.
        * m4/posixtm.m4 (gl_POSIXTM): Remove obsolescent call to AC_STRUCT_TM.
        * m4/sys_time_h.m4: New file.
        * m4/tzset.m4 (gl_FUNC_TZSET_CLOBBER): Require gl_HEADER_SYS_TIME_H.
        Don't include sys/time.h.  Return from main rather than exiting.
        Define TZSET_CLOBBERS_LOCALTIME, for consistency with other names;
        all uses changed.
        * modules/gethrxtime (Depends-on): Add sys_time.
        * modules/gettime (Depends-on): Likewise.
        * modules/gettimeofday (Depends-on): Likewise.
        * modules/nanosleep (Depends-on): Likewise.
        * modules/settime (Depends-on): Likewise.
        * modules/tempname (Depends-on): Likewise.
        * modules/utimens (Depends-on): Likewise.
        * modules/gettimeofday (Files): Remove lib/gettimeofday.h.
        (Include:) Change back to <sys/time.h>.
        (Maintainer:) Add self.
        * modules/sys_time: New file.
        * modules/tempname (Depends-on): Add gettimeofday.
        * tests/test-gettimeofday.c: Include <sys/time.h>
        rather than gettimeofday.h.

Index: MODULES.html.sh
===================================================================
RCS file: /cvsroot/gnulib/gnulib/MODULES.html.sh,v
retrieving revision 1.173
diff -u -p -r1.173 MODULES.html.sh
--- MODULES.html.sh     16 Jan 2007 03:47:24 -0000      1.173
+++ MODULES.html.sh     18 Jan 2007 08:33:30 -0000
@@ -1949,6 +1949,7 @@ func_all_modules ()
   func_module ssize_t
   func_module strtok_r
   func_module sys_stat
+  func_module sys_time
   func_module tsearch
   func_module unistd
   func_module utime
Index: lib/gethrxtime.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/gethrxtime.c,v
retrieving revision 1.5
diff -u -p -r1.5 gethrxtime.c
--- lib/gethrxtime.c    13 Sep 2006 22:38:14 -0000      1.5
+++ lib/gethrxtime.c    18 Jan 2007 08:33:30 -0000
@@ -1,6 +1,6 @@
 /* gethrxtime -- get high resolution real time

-   Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+   Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -22,6 +22,7 @@

 #include "gethrxtime.h"

+#include <sys/time.h>
 #include "timespec.h"

 /* Get the current time, as a count of the number of nanoseconds since
Index: lib/settime.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/settime.c,v
retrieving revision 1.7
diff -u -p -r1.7 settime.c
--- lib/settime.c       13 Sep 2006 22:38:14 -0000      1.7
+++ lib/settime.c       18 Jan 2007 08:33:30 -0000
@@ -1,6 +1,7 @@
 /* settime -- set the system clock

-   Copyright (C) 2002, 2004, 2005, 2006 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2004, 2005, 2006, 2007 Free Software
+   Foundation, Inc.

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -22,6 +23,7 @@

 #include "timespec.h"

+#include <sys/time.h>
 #include <unistd.h>

 #include <errno.h>
Index: lib/utimens.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/utimens.c,v
retrieving revision 1.13
diff -u -p -r1.13 utimens.c
--- lib/utimens.c       5 Dec 2006 18:13:50 -0000       1.13
+++ lib/utimens.c       18 Jan 2007 08:33:30 -0000
@@ -1,6 +1,7 @@
 /* Set file access and modification times.

-   Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software
+   Foundation, Inc.

    This program is free software; you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by the
@@ -26,6 +27,7 @@

 #include <errno.h>
 #include <fcntl.h>
+#include <sys/time.h>
 #include <unistd.h>

 #if HAVE_UTIME_H
Index: lib/gettime.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/gettime.c,v
retrieving revision 1.7
diff -u -p -r1.7 gettime.c
--- lib/gettime.c       13 Sep 2006 22:38:14 -0000      1.7
+++ lib/gettime.c       18 Jan 2007 08:33:30 -0000
@@ -1,6 +1,6 @@
 /* gettime -- get the system clock

-   Copyright (C) 2002, 2004, 2005, 2006 Free Software Foundation, Inc.
+   Copyright (C) 2002, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -22,6 +22,8 @@

 #include "timespec.h"

+#include <sys/time.h>
+
 /* Get the system time into *TS.  */

 void
@@ -36,23 +38,12 @@ gettime (struct timespec *ts)
     return;
 # endif

-# if HAVE_GETTIMEOFDAY
   {
     struct timeval tv;
     gettimeofday (&tv, NULL);
     ts->tv_sec = tv.tv_sec;
     ts->tv_nsec = tv.tv_usec * 1000;
   }
-# else
-
-#  ifndef OK_TO_USE_1S_CLOCK
-#   error "Only 1-second nominal clock resolution found.  Is that intended?" \
-          "If so, compile with the -DOK_TO_USE_1S_CLOCK option."
-#  endif
-  ts->tv_sec = time (NULL);
-  ts->tv_nsec = 0;
-
-# endif

 #endif
 }
Index: lib/tempname.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/tempname.c,v
retrieving revision 1.23
diff -u -p -r1.23 tempname.c
--- lib/tempname.c      9 Nov 2006 18:49:46 -0000       1.23
+++ lib/tempname.c      18 Jan 2007 08:33:30 -0000
@@ -1,7 +1,8 @@
 /* tempname.c - generate the name of a temporary file.

    Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
-   2000, 2001, 2002, 2003, 2005, 2006 Free Software Foundation, Inc.
+   2000, 2001, 2002, 2003, 2005, 2006, 2007 Free Software Foundation,
+   Inc.

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -51,11 +52,7 @@
 #include <string.h>

 #include <fcntl.h>
-
-#if HAVE_SYS_TIME_H || _LIBC
-# include <sys/time.h>
-#endif
-
+#include <sys/time.h>
 #include <stdint.h>
 #include <unistd.h>

@@ -242,15 +239,11 @@ __gen_tempname (char *tmpl, int kind)
 #ifdef RANDOM_BITS
   RANDOM_BITS (random_time_bits);
 #else
-# if HAVE_GETTIMEOFDAY || _LIBC
   {
     struct timeval tv;
     __gettimeofday (&tv, NULL);
     random_time_bits = ((uint64_t) tv.tv_usec << 16) ^ tv.tv_sec;
   }
-# else
-  random_time_bits = time (NULL);
-# endif
 #endif
   value += random_time_bits ^ __getpid ();

Index: lib/gettimeofday.h
===================================================================
RCS file: lib/gettimeofday.h
diff -N lib/gettimeofday.h
--- lib/gettimeofday.h  17 Jan 2007 01:04:18 -0000      1.2
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,53 +0,0 @@
-/* Provide gettimeofday
-   1. for systems that don't have it,
-   2. for some systems where gettimeofday clobbers the static buffer that
-      localtime uses for it's return value.  The gettimeofday function from
-      Mac OS X 10.0.4, i.e. Darwin 1.3.7 has this problem.
-      The tzset replacement is necessary for at least Solaris 2.5, 2.5.1, and
-      2.6.
-
-   Copyright (C) 2001, 2002, 2003, 2005, 2007 Free Software Foundation, Inc.
-
-   This program 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 2, or (at your option)
-   any later version.
-
-   This program 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 this program; if not, write to the Free Software Foundation,
-   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
-
-#ifndef GETTIMEOFDAY_H
-#define GETTIMEOFDAY_H
-
-#if TIME_WITH_SYS_TIME
-# include <sys/time.h>
-# include <time.h>
-#else
-# if HAVE_SYS_TIME_H
-#  include <sys/time.h>
-# else
-#  include <time.h>
-# endif
-#endif
-
-#if !HAVE_STRUCT_TIMEVAL
-struct timeval
-{
-  time_t tv_sec;
-  suseconds_t tv_usec;
-};
-#endif
-
-#if !HAVE_GETTIMEOFDAY_POSIX_SIGNATURE || GETTIMEOFDAY_CLOBBERS_LOCALTIME
-# undef gettimeofday
-# define gettimeofday rpl_gettimeofday
-extern int gettimeofday (struct timeval *restrict tp, void *restrict tzp);
-#endif
-
-#endif /* GETTIMEOFDAY_H */
Index: lib/gettimeofday.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/gettimeofday.c,v
retrieving revision 1.11
diff -u -p -r1.11 gettimeofday.c
--- lib/gettimeofday.c  17 Jan 2007 11:48:22 -0000      1.11
+++ lib/gettimeofday.c  18 Jan 2007 08:33:30 -0000
@@ -1,12 +1,7 @@
-/* Provide gettimeofday
-   1. for systems that don't have it,
-   2. for some systems where gettimeofday clobbers the static buffer that
-      localtime uses for it's return value.  The gettimeofday function from
-      Mac OS X 10.0.4, i.e. Darwin 1.3.7 has this problem.
-      The tzset replacement is necessary for at least Solaris 2.5, 2.5.1, and
-      2.6.
+/* Provide gettimeofday for systems that don't have it or for which it's 
broken.

-   Copyright (C) 2001, 2002, 2003, 2005, 2006, 2007 Free Software Foundation, 
Inc.
+   Copyright (C) 2001, 2002, 2003, 2005, 2006, 2007 Free Software
+   Foundation, Inc.

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -27,18 +22,24 @@
 #include <config.h>

 /* Specification.  */
-#include "gettimeofday.h"
+#include <sys/time.h>

-#include <sys/types.h>
-#include <stdlib.h>
+#include <time.h>

 #if HAVE_SYS_TIMEB_H
 # include <sys/timeb.h>
 #endif

-#if GETTIMEOFDAY_CLOBBERS_LOCALTIME
+#if GETTIMEOFDAY_CLOBBERS_LOCALTIME || TZSET_CLOBBERS_LOCALTIME

-static struct tm *localtime_buffer_addr;
+/* Work around the bug in some systems whereby gettimeofday clobbers
+   the static buffer that localtime uses for its return value.  The
+   gettimeofday function from Mac OS X 10.0.4 (i.e., Darwin 1.3.7) has
+   this problem.  The tzset replacement is necessary for at least
+   Solaris 2.5, 2.5.1, and 2.6.  */
+
+static struct tm tm_zero_buffer;
+static struct tm *localtime_buffer_addr = &tm_zero_buffer;

 /* This is a wrapper for localtime.  It is used only on systems for which
    gettimeofday clobbers the static buffer used for localtime's result.
@@ -47,13 +48,13 @@ static struct tm *localtime_buffer_addr;
    localtime uses for its result.  */

 struct tm *
-localtime (const time_t *timep)
-#undef localtime
+localtime (time_t const *timep)
 {
-  extern struct tm *localtime (const time_t *);
+#undef localtime
+  extern struct tm *localtime (time_t const *);
   struct tm *tm = localtime (timep);

-  if (! localtime_buffer_addr)
+  if (localtime_buffer_addr == &tm_zero_buffer)
     localtime_buffer_addr = tm;

   return tm;
@@ -61,107 +62,83 @@ localtime (const time_t *timep)

 /* Same as above, since gmtime and localtime use the same buffer.  */
 struct tm *
-gmtime (const time_t *timep)
-#undef gmtime
+gmtime (time_t const *timep)
 {
-  extern struct tm *gmtime (const time_t *);
+#undef gmtime
+  extern struct tm *gmtime (time_t const *);
   struct tm *tm = gmtime (timep);

-  if (! localtime_buffer_addr)
+  if (localtime_buffer_addr == &tm_zero_buffer)
     localtime_buffer_addr = tm;

   return tm;
 }

-/* This is a wrapper for tzset. It is used only on systems for which
-   tzset may clobber the static buffer used for localtime's result.
-   Save and restore the contents of the buffer used for localtime's
-   result around the call to tzset.  */
+#endif /* GETTIMEOFDAY_CLOBBERS_LOCALTIME || TZSET_CLOBBERS_LOCALTIME */
+
+#if TZSET_CLOBBERS_LOCALTIME
+/* This is a wrapper for tzset, for systems on which tzset may clobber
+   the static buffer used for localtime's result.  */
 void
 tzset (void)
-#undef tzset
 {
-  extern struct tm *localtime (const time_t *);
+#undef tzset
   extern void tzset (void);
-  struct tm save;
-
-  if (! localtime_buffer_addr)
-    {
-      time_t t = 0;
-      localtime_buffer_addr = localtime (&t);
-    }

-  save = *localtime_buffer_addr;
+  /* Save and restore the contents of the buffer used for localtime's
+     result around the call to tzset.  */
+  struct tm save = *localtime_buffer_addr;
   tzset ();
   *localtime_buffer_addr = save;
 }
-
 #endif

-/* This is a wrapper for gettimeofday.
-   It is used only on systems that lack this function, or for whose
-   implementation of this function causes problems. */
+/* This is a wrapper for gettimeofday.  It is used only on systems
+   that lack this function, or whose implementation of this function
+   causes problems.  */

 int
 gettimeofday (struct timeval *restrict tv, void *restrict tz)
-#undef gettimeofday
 {
+#undef gettimeofday
 #if HAVE_GETTIMEOFDAY
   extern int gettimeofday (/* unspecified arguments */);
+
 # if GETTIMEOFDAY_CLOBBERS_LOCALTIME
-  extern struct tm *localtime (const time_t *);
+  /* Save and restore the contents of the buffer used for localtime's
+     result around the call to gettimeofday.  */
+  struct tm save = *localtime_buffer_addr;
+# endif

-  /* Save and restore the contents of the buffer used for localtime's result
-     around the call to gettimeofday. */
-  struct tm save;
-  int result;
-
-  if (! localtime_buffer_addr)
-    {
-      time_t t = 0;
-      localtime_buffer_addr = localtime (&t);
-    }
+  int result = gettimeofday (tv, tz);

-  save = *localtime_buffer_addr;
-  result = gettimeofday (tv, tz);
+# if GETTIMEOFDAY_CLOBBERS_LOCALTIME
   *localtime_buffer_addr = save;
+# endif

   return result;

-# else
-
-  return gettimeofday (tv, tz);
-
-# endif
 #else

-  /* The clock does not have microsecond resolution, so get the maximum
-     possible value for the current time that is consistent with the
-     reported clock.  That way, files are not considered to be in the
-     future merely because their time stamps have higher resolution
-     than the clock resolution.  */
-
 # if HAVE__FTIME

   struct _timeb timebuf;
-
   _ftime (&timebuf);
   tv->tv_sec = timebuf.time;
-  tv->tv_usec = timebuf.millitm * 1000 + 999;
-
-  return 0;
+  tv->tv_usec = timebuf.millitm * 1000;

 # else

-  time_t t = time (NULL);
+#  if !defined OK_TO_USE_1S_CLOCK
+#   error "Only 1-second nominal clock resolution found.  Is that intended?" \
+          "If so, compile with the -DOK_TO_USE_1S_CLOCK option."
+#  endif
+  tv->tv_sec = time (NULL);
+  tv->tv_usec = 0;

-  if (t == (time_t) -1)
-    return -1;
-  tv->tv_sec = t;
-  tv->tv_usec = 999999;
+# endif

   return 0;

-# endif
 #endif
 }
Index: lib/nanosleep.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/nanosleep.c,v
retrieving revision 1.21
diff -u -p -r1.21 nanosleep.c
--- lib/nanosleep.c     13 Sep 2006 22:38:14 -0000      1.21
+++ lib/nanosleep.c     18 Jan 2007 08:33:30 -0000
@@ -1,7 +1,7 @@
 /* Provide a replacement for the POSIX nanosleep function.

-   Copyright (C) 1999, 2000, 2002, 2004, 2005, 2006 Free Software
-   Foundation, Inc.
+   Copyright (C) 1999, 2000, 2002, 2004, 2005, 2006, 2007 Free
+   Software Foundation, Inc.

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -25,6 +25,8 @@
    prototype for rpl_nanosleep. (they'd conflict e.g., on alpha-dec-osf3.2)  */
 #undef nanosleep

+#include "timespec.h"
+
 #include <stdbool.h>
 #include <stdio.h>
 #include <sys/types.h>
@@ -33,23 +35,13 @@
 #endif
 #include <signal.h>

-#if TIME_WITH_SYS_TIME
-# include <sys/time.h>
-# include <time.h>
-#else
-# if HAVE_SYS_TIME_H
-#  include <sys/time.h>
-# else
-#  include <time.h>
-# endif
-#endif
+#include <sys/time.h>
+#include <time.h>

 #include <errno.h>

 #include <unistd.h>

-#include "timespec.h"
-
 enum { BILLION = 1000 * 1000 * 1000 };

 #if HAVE_BUG_BIG_NANOSLEEP
Index: lib/timespec.h
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/timespec.h,v
retrieving revision 1.7
diff -u -p -r1.7 timespec.h
--- lib/timespec.h      19 Sep 2005 17:28:15 -0000      1.7
+++ lib/timespec.h      18 Jan 2007 08:33:30 -0000
@@ -1,6 +1,6 @@
 /* timespec -- System time interface

-   Copyright (C) 2000, 2002, 2004, 2005 Free Software Foundation, Inc.
+   Copyright (C) 2000, 2002, 2004, 2005, 2007 Free Software Foundation, Inc.

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -19,24 +19,17 @@
 #if ! defined TIMESPEC_H
 # define TIMESPEC_H

-# include <sys/types.h>
-# if TIME_WITH_SYS_TIME
+# if HAVE_SYS_TIME_H
 #  include <sys/time.h>
-#  include <time.h>
-# else
-#  if HAVE_SYS_TIME_H
-#   include <sys/time.h>
-#  else
-#   include <time.h>
-#  endif
 # endif
+# include <time.h>

 # if ! HAVE_STRUCT_TIMESPEC
 /* Some systems don't define this struct, e.g., AIX 4.1, Ultrix 4.3.  */
 struct timespec
 {
   time_t tv_sec;
-  long tv_nsec;
+  long int tv_nsec;
 };
 # endif

Index: lib/strftime.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/strftime.c,v
retrieving revision 1.93
diff -u -p -r1.93 strftime.c
--- lib/strftime.c      16 Jan 2007 16:31:23 -0000      1.93
+++ lib/strftime.c      18 Jan 2007 08:33:30 -0000
@@ -36,18 +36,8 @@
 #endif

 #include <ctype.h>
-#include <sys/types.h>         /* Some systems define `time_t' here.  */
+#include <time.h>

-#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
 #if HAVE_TZNAME && ! defined tzname
 extern char *tzname[];
 #endif
Index: lib/posixtm.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/posixtm.c,v
retrieving revision 1.24
diff -u -p -r1.24 posixtm.c
--- lib/posixtm.c       13 Sep 2006 22:38:14 -0000      1.24
+++ lib/posixtm.c       18 Jan 2007 08:33:30 -0000
@@ -1,7 +1,7 @@
 /* Parse dates for touch and date.

    Copyright (C) 1989, 1990, 1991, 1998, 2000, 2001, 2002, 2003, 2004,
-   2005, 2006 Free Software Foundation Inc.
+   2005, 2006, 2007 Free Software Foundation Inc.

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -22,21 +22,13 @@

 #include <config.h>

-#include <stdbool.h>
+#include "posixtm.h"

 #include <stdio.h>
 #include <stdlib.h>
 #include <sys/types.h>
 #include <string.h>

-#ifdef TM_IN_SYS_TIME
-# include <sys/time.h>
-#else
-# include <time.h>
-#endif
-
-#include "posixtm.h"
-
 #if USE_UNLOCKED_IO
 # include "unlocked-io.h"
 #endif
Index: lib/posixtm.h
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/posixtm.h,v
retrieving revision 1.7
diff -u -p -r1.7 posixtm.h
--- lib/posixtm.h       9 Jan 2006 23:13:56 -0000       1.7
+++ lib/posixtm.h       18 Jan 2007 08:33:30 -0000
@@ -1,6 +1,6 @@
 /* Parse dates for touch and date.

-   Copyright (C) 1998, 2003, 2005 Free Software Foundation Inc.
+   Copyright (C) 1998, 2003, 2005, 2007 Free Software Foundation Inc.

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -22,6 +22,9 @@
 #ifndef POSIXTM_H_
 # define POSIXTM_H_

+# include <stdbool.h>
+# include <time.h>
+
 /* POSIX Date Syntax flags.  */
 # define PDS_LEADING_YEAR 1
 # define PDS_TRAILING_YEAR 2
Index: lib/sys_time_.h
===================================================================
RCS file: lib/sys_time_.h
diff -N lib/sys_time_.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ lib/sys_time_.h     18 Jan 2007 08:33:30 -0000
@@ -0,0 +1,44 @@
+/* Provide a more complete sys/time.h.
+
+   Copyright (C) 2007 Free Software Foundation, Inc.
+
+   This program 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 2, or (at your option)
+   any later version.
+
+   This program 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 this program; if not, write to the Free Software Foundation,
+   Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
+
+/* Written by Paul Eggert.  */
+
+#ifndef _gl_SYS_TIME_H
+#define _gl_SYS_TIME_H
+
+#if @HAVE_SYS_TIME_H@
+# include @ABSOLUTE_SYS_TIME_H@
+#else
+# include <time.h>
+#endif
+
+#if ! @HAVE_STRUCT_TIMEVAL@
+struct timeval
+{
+  time_t tv_sec;
+  long int tv_usec;
+};
+#endif
+
+#if ! @HAVE_GETTIMEOFDAY_POSIX_SIGNATURE@ || @GETTIMEOFDAY_CLOBBERS_LOCALTIME@
+# undef gettimeofday
+# define gettimeofday rpl_gettimeofday
+int gettimeofday (struct timeval *restrict, void *restrict);
+#endif
+
+#endif /* _gl_SYS_TIME_H */
Index: m4/gettimeofday.m4
===================================================================
RCS file: /cvsroot/gnulib/gnulib/m4/gettimeofday.m4,v
retrieving revision 1.12
diff -u -p -r1.12 gettimeofday.m4
--- m4/gettimeofday.m4  17 Jan 2007 01:04:18 -0000      1.12
+++ m4/gettimeofday.m4  18 Jan 2007 08:33:30 -0000
@@ -1,86 +1,45 @@
-#serial 8
+#serial 9

 # Copyright (C) 2001, 2002, 2003, 2005, 2007 Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.

+dnl From Jim Meyering.
+
 AC_DEFUN([gl_FUNC_GETTIMEOFDAY],
 [
   AC_REQUIRE([AC_C_RESTRICT])
-  AC_REQUIRE([AC_HEADER_TIME])
-  AC_CHECK_HEADERS_ONCE([sys/time.h])
-  AC_CHECK_FUNCS([gettimeofday])
-  
-  AC_CHECK_TYPE([suseconds_t], ,
-    [AC_DEFINE([suseconds_t], [int],
-       [Define to `int' if `suseconds_t' is missing.])
-    ],
-    [
-#    if TIME_WITH_SYS_TIME
-#     include <sys/time.h>
-#     include <time.h>
-#    else
-#     if HAVE_SYS_TIME_H
-#      include <sys/time.h>
-#     else
-#      include <time.h>
-#     endif
-#    endif
-    ])
-
-  AC_CACHE_CHECK([for struct timeval], [fu_cv_sys_struct_timeval],
-    [AC_TRY_COMPILE(
-      [
-#      if TIME_WITH_SYS_TIME
-#       include <sys/time.h>
-#       include <time.h>
-#      else
-#       if HAVE_SYS_TIME_H
-#        include <sys/time.h>
-#       else
-#        include <time.h>
-#       endif
-#      endif
-      ],
-      [static struct timeval x; x.tv_sec = x.tv_usec;],
-      fu_cv_sys_struct_timeval=yes,
-      fu_cv_sys_struct_timeval=no)
-    ])
-
-  if test $fu_cv_sys_struct_timeval = yes; then
-    AC_DEFINE(HAVE_STRUCT_TIMEVAL, 1,
-      [Define if struct timeval is declared in <time.h> or <sys/time.h>. ])
-  fi
-  
-  AC_CACHE_CHECK([for gettimeofday whose signature conforms to POSIX],
-    [ac_cv_func_gettimeofday_posix_signature],
-    [AC_LINK_IFELSE(
+  AC_REQUIRE([gl_HEADER_SYS_TIME_H])
+  AC_CHECK_FUNCS_ONCE([gettimeofday])
+
+  AC_CACHE_CHECK([for gettimeofday with POSIX signature],
+    [gl_cv_func_gettimeofday_posix_signature],
+    [AC_COMPILE_IFELSE(
        [AC_LANG_PROGRAM(
-          [[#include <sys/time.h>
-           time_t a;
-           suseconds_t b;
+         [[#include <sys/time.h>
            struct timeval c;
          ]],
          [[
-           int x = gettimeofday (&c, 0);
            int (*f) (struct timeval *restrict, void *restrict) = gettimeofday;
+           int x = f (&c, 0);
            return !(x | c.tv_sec | c.tv_usec);
          ]])],
-       [ac_cv_func_gettimeofday_posix_signature=yes],
-       [ac_cv_func_gettimeofday_posix_signature=no])])
-  if test $ac_cv_func_gettimeofday_posix_signature = yes; then
-    AC_DEFINE([HAVE_GETTIMEOFDAY_POSIX_SIGNATURE], 1,
-      [Define if gettimeofday's signature conforms to POSIX.])
-    AC_FUNC_GETTIMEOFDAY_CLOBBER
-  else
-    gl_PREREQ_GETTIMEOFDAY
-    AC_LIBOBJ([gettimeofday])
+       [gl_cv_func_gettimeofday_posix_signature=yes],
+       [gl_cv_func_gettimeofday_posix_signature=no])])
+
+  gl_FUNC_GETTIMEOFDAY_CLOBBER
+
+  if test $gl_cv_func_gettimeofday_posix_signature != yes; then
+    HAVE_GETTIMEOFDAY_POSIX_SIGNATURE=0
+    if test $gl_cv_func_gettimeofday_clobber != yes; then
+      AC_LIBOBJ(gettimeofday)
+      gl_PREREQ_GETTIMEOFDAY
+    fi
   fi
 ])

-dnl From Jim Meyering.
-dnl
+
 dnl See if gettimeofday clobbers the static buffer that localtime uses
 dnl for its return value.  The gettimeofday function from Mac OS X 10.0.4
 dnl (i.e., Darwin 1.3.7) has this problem.
@@ -88,70 +47,53 @@ dnl
 dnl If it does, then arrange to use gettimeofday and localtime only via
 dnl the wrapper functions that work around the problem.

-AC_DEFUN([AC_FUNC_GETTIMEOFDAY_CLOBBER],
+AC_DEFUN([gl_FUNC_GETTIMEOFDAY_CLOBBER],
 [
- AC_REQUIRE([AC_HEADER_TIME])
+ AC_REQUIRE([gl_HEADER_SYS_TIME_H])
+
  AC_CACHE_CHECK([whether gettimeofday clobbers localtime buffer],
-  [jm_cv_func_gettimeofday_clobber],
-  [AC_TRY_RUN([
-#include <stdio.h>
-#include <string.h>
-
-#if TIME_WITH_SYS_TIME
-# include <sys/time.h>
-# include <time.h>
-#else
-# if HAVE_SYS_TIME_H
-#  include <sys/time.h>
-# else
-#  include <time.h>
-# endif
-#endif
-
-#include <stdlib.h>
-
-int
-main ()
-{
-  time_t t = 0;
-  struct tm *lt;
-  struct tm saved_lt;
-  struct timeval tv;
-  lt = localtime (&t);
-  saved_lt = *lt;
-  gettimeofday (&tv, NULL);
-  if (memcmp (lt, &saved_lt, sizeof (struct tm)) != 0)
-    exit (1);
-
-  exit (0);
-}
-         ],
-        jm_cv_func_gettimeofday_clobber=no,
-        jm_cv_func_gettimeofday_clobber=yes,
-        dnl When crosscompiling, assume it is broken.
-        jm_cv_func_gettimeofday_clobber=yes)
-  ])
-  if test $jm_cv_func_gettimeofday_clobber = yes; then
-    gl_GETTIMEOFDAY_REPLACE_LOCALTIME
-  fi
+  [gl_cv_func_gettimeofday_clobber],
+  [AC_RUN_IFELSE(
+     [AC_LANG_PROGRAM(
+       [[#include <string.h>
+         #include <sys/time.h>
+         #include <time.h>
+         #include <stdlib.h>
+       ]],
+       [[
+         time_t t = 0;
+         struct tm *lt;
+         struct tm saved_lt;
+         struct timeval tv;
+         lt = localtime (&t);
+         saved_lt = *lt;
+         gettimeofday (&tv, NULL);
+         return memcmp (lt, &saved_lt, sizeof (struct tm)) != 0;
+       ]])],
+     [gl_cv_func_gettimeofday_clobber=no],
+     [gl_cv_func_gettimeofday_clobber=yes],
+     dnl When crosscompiling, assume it is broken.
+     [gl_cv_func_gettimeofday_clobber=yes])])
+
+ if test $gl_cv_func_gettimeofday_clobber = yes; then
+   gl_GETTIMEOFDAY_REPLACE_LOCALTIME
+   GETTIMEOFDAY_CLOBBERS_LOCALTIME=1
+   AC_DEFINE([GETTIMEOFDAY_CLOBBERS_LOCALTIME], 1,
+     [Define if gettimeofday clobbers the localtime buffer.])
+ fi
 ])

 AC_DEFUN([gl_GETTIMEOFDAY_REPLACE_LOCALTIME], [
   AC_LIBOBJ(gettimeofday)
   gl_PREREQ_GETTIMEOFDAY
-  AC_DEFINE([GETTIMEOFDAY_CLOBBERS_LOCALTIME], 1,
-    [Define if gettimeofday clobbers the localtime buffer.])
   AC_DEFINE([gmtime], [rpl_gmtime],
     [Define to rpl_gmtime if the replacement function should be used.])
   AC_DEFINE([localtime], [rpl_localtime],
     [Define to rpl_localtime if the replacement function should be used.])
-  AC_DEFINE([tzset], [rpl_tzset],
-    [Define to rpl_tzset if the replacement function should be used.])
 ])

 # Prerequisites of lib/gettimeofday.c.
 AC_DEFUN([gl_PREREQ_GETTIMEOFDAY], [
-  AC_REQUIRE([AC_HEADER_TIME])
   AC_CHECK_HEADERS([sys/timeb.h])
   AC_CHECK_FUNCS([_ftime])
 ])
Index: m4/mktime.m4
===================================================================
RCS file: /cvsroot/gnulib/gnulib/m4/mktime.m4,v
retrieving revision 1.26
diff -u -p -r1.26 mktime.m4
--- m4/mktime.m4        22 Dec 2006 08:53:57 -0000      1.26
+++ m4/mktime.m4        18 Jan 2007 08:33:30 -0000
@@ -1,5 +1,5 @@
-#serial 9
-dnl Copyright (C) 2002, 2003, 2005, 2006 Free Software Foundation, Inc.
+#serial 10
+dnl Copyright (C) 2002, 2003, 2005, 2006, 2007 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -13,25 +13,14 @@ dnl From Jim Meyering.
 # AC_FUNC_MKTIME
 # --------------
 AC_DEFUN([AC_FUNC_MKTIME],
-[AC_REQUIRE([AC_HEADER_TIME])dnl
-AC_CHECK_HEADERS_ONCE(sys/time.h unistd.h)
+[AC_CHECK_HEADERS_ONCE(sys/time.h unistd.h)
 AC_CHECK_FUNCS_ONCE(alarm)
 AC_CACHE_CHECK([for working mktime], ac_cv_func_working_mktime,
 [AC_RUN_IFELSE([AC_LANG_SOURCE(
 [[/* Test program from Paul Eggert and Tony Leneis.  */
-#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
-
 #include <limits.h>
 #include <stdlib.h>
+#include <time.h>

 #ifdef HAVE_UNISTD_H
 # include <unistd.h>
Index: m4/nanosleep.m4
===================================================================
RCS file: /cvsroot/gnulib/gnulib/m4/nanosleep.m4,v
retrieving revision 1.26
diff -u -p -r1.26 nanosleep.m4
--- m4/nanosleep.m4     31 Aug 2006 07:00:50 -0000      1.26
+++ m4/nanosleep.m4     18 Jan 2007 08:33:30 -0000
@@ -1,12 +1,12 @@
-#serial 19
+#serial 20

 dnl From Jim Meyering.
 dnl Check for the nanosleep function.
 dnl If not found, use the supplied replacement.
 dnl

-# Copyright (C) 1999, 2000, 2001, 2003, 2004, 2005, 2006 Free Software
-# Foundation, Inc.
+# Copyright (C) 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007 Free
+# Software Foundation, Inc.

 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -17,7 +17,6 @@ AC_DEFUN([gl_FUNC_NANOSLEEP],
  dnl Persuade glibc and Solaris <time.h> to declare nanosleep.
  AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])

- AC_REQUIRE([AC_HEADER_TIME])
  AC_REQUIRE([gl_CLOCK_TIME])
  AC_CHECK_HEADERS_ONCE(sys/time.h)

@@ -34,19 +33,13 @@ AC_DEFUN([gl_FUNC_NANOSLEEP],
   [
    AC_RUN_IFELSE(
      [AC_LANG_SOURCE([[
-       #if TIME_WITH_SYS_TIME
-        #include <sys/time.h>
-        #include <time.h>
-       #else
-        #if HAVE_SYS_TIME_H
-         #include <sys/time.h>
-        #else
-         #include <time.h>
-        #endif
-       #endif
        #include <errno.h>
        #include <limits.h>
        #include <signal.h>
+       #if HAVE_SYS_TIME_H
+        #include <sys/time.h>
+       #endif
+       #include <time.h>
        #include <unistd.h>
        #define TYPE_SIGNED(t) (! ((t) 0 < (t) -1))
        #define TYPE_MAXIMUM(t) \
Index: m4/strftime.m4
===================================================================
RCS file: /cvsroot/gnulib/gnulib/m4/strftime.m4,v
retrieving revision 1.37
diff -u -p -r1.37 strftime.m4
--- m4/strftime.m4      21 Aug 2006 21:46:31 -0000      1.37
+++ m4/strftime.m4      18 Jan 2007 08:33:30 -0000
@@ -1,7 +1,7 @@
 #serial 28

-# Copyright (C) 1996, 1997, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
-# Free Software Foundation, Inc.
+# Copyright (C) 1996, 1997, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
+# 2006, 2007 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -21,7 +21,6 @@ AC_DEFUN([gl_FUNC_STRFTIME],
  # This defines (or not) HAVE_TZNAME and HAVE_TM_ZONE.
  AC_REQUIRE([AC_STRUCT_TIMEZONE])

- AC_REQUIRE([AC_HEADER_TIME])
  AC_REQUIRE([AC_TYPE_MBSTATE_T])
  AC_REQUIRE([gl_TM_GMTOFF])

Index: m4/timespec.m4
===================================================================
RCS file: /cvsroot/gnulib/gnulib/m4/timespec.m4,v
retrieving revision 1.13
diff -u -p -r1.13 timespec.m4
--- m4/timespec.m4      21 Aug 2006 21:46:31 -0000      1.13
+++ m4/timespec.m4      18 Jan 2007 08:33:30 -0000
@@ -1,6 +1,6 @@
-#serial 12
+#serial 13

-# Copyright (C) 2000, 2001, 2003, 2004, 2005, 2006 Free Software
+# Copyright (C) 2000, 2001, 2003, 2004, 2005, 2006, 2007 Free Software
 # Foundation, Inc.

 # This file is free software; the Free Software Foundation
@@ -13,7 +13,6 @@ AC_DEFUN([gl_TIMESPEC],
 [
   dnl Prerequisites of lib/timespec.h.
   AC_REQUIRE([AC_C_INLINE])
-  AC_REQUIRE([AC_HEADER_TIME])
   AC_CHECK_HEADERS_ONCE(sys/time.h)
   gl_CHECK_TYPE_STRUCT_TIMESPEC

@@ -31,28 +30,20 @@ AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC]
   dnl Persuade pedantic Solaris to declare struct timespec.
   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])

-  AC_REQUIRE([AC_HEADER_TIME])
   AC_CHECK_HEADERS_ONCE(sys/time.h)
-  AC_CACHE_CHECK([for struct timespec], fu_cv_sys_struct_timespec,
-    [AC_TRY_COMPILE(
-      [
-#      if TIME_WITH_SYS_TIME
-#       include <sys/time.h>
-#       include <time.h>
-#      else
-#       if HAVE_SYS_TIME_H
-#        include <sys/time.h>
-#       else
-#        include <time.h>
-#       endif
-#      endif
-      ],
-      [static struct timespec x; x.tv_sec = x.tv_nsec;],
-      fu_cv_sys_struct_timespec=yes,
-      fu_cv_sys_struct_timespec=no)
-    ])
+  AC_CACHE_CHECK([for struct timespec], [gl_cv_sys_struct_timespec],
+    [AC_COMPILE_IFELSE(
+       [AC_LANG_PROGRAM(
+         [[#if HAVE_SYS_TIME_H
+            #include <sys/time.h>
+           #endif
+           #include <time.h>
+         ]],
+         [[static struct timespec x; x.tv_sec = x.tv_nsec;]])],
+       [gl_cv_sys_struct_timespec=yes],
+       [gl_cv_sys_struct_timespec=no])])

-  if test $fu_cv_sys_struct_timespec = yes; then
+  if test $gl_cv_sys_struct_timespec = yes; then
     AC_DEFINE(HAVE_STRUCT_TIMESPEC, 1,
              [Define if struct timespec is declared in <time.h>. ])
   fi
Index: m4/tzset.m4
===================================================================
RCS file: /cvsroot/gnulib/gnulib/m4/tzset.m4,v
retrieving revision 1.2
diff -u -p -r1.2 tzset.m4
--- m4/tzset.m4 23 Jan 2005 08:06:57 -0000      1.2
+++ m4/tzset.m4 18 Jan 2007 08:33:30 -0000
@@ -1,6 +1,6 @@
-#serial 2
+#serial 3

-# Copyright (C) 2003 Free Software Foundation, Inc.
+# Copyright (C) 2003, 2007 Free Software Foundation, Inc.
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
@@ -15,21 +15,12 @@

 AC_DEFUN([gl_FUNC_TZSET_CLOBBER],
 [
-  AC_REQUIRE([AC_HEADER_TIME])
+  AC_REQUIRE([gl_HEADER_SYS_TIME_H])
   AC_CACHE_CHECK([whether tzset clobbers localtime buffer],
                  gl_cv_func_tzset_clobber,
   [
   AC_RUN_IFELSE([AC_LANG_SOURCE([[
-#if TIME_WITH_SYS_TIME
-# include <sys/time.h>
-# include <time.h>
-#else
-# if HAVE_SYS_TIME_H
-#  include <sys/time.h>
-# else
-#  include <time.h>
-# endif
-#endif
+#include <time.h>
 #include <stdlib.h>

 int
@@ -42,12 +33,12 @@ main ()
   s = *p;
   putenv ("TZ=EST+3EDT+2,M10.1.0/00:00:00,M2.3.0/00:00:00");
   tzset ();
-  exit (p->tm_year != s.tm_year
-        || p->tm_mon != s.tm_mon
-        || p->tm_mday != s.tm_mday
-        || p->tm_hour != s.tm_hour
-        || p->tm_min != s.tm_min
-        || p->tm_sec != s.tm_sec);
+  return (p->tm_year != s.tm_year
+         || p->tm_mon != s.tm_mon
+         || p->tm_mday != s.tm_mday
+         || p->tm_hour != s.tm_hour
+         || p->tm_min != s.tm_min
+         || p->tm_sec != s.tm_sec);
 }
   ]])],
        [gl_cv_func_tzset_clobber=no],
@@ -62,7 +53,7 @@ main ()

     AC_DEFINE(tzset, rpl_tzset,
       [Define to rpl_tzset if the wrapper function should be used.])
-    AC_DEFINE(TZSET_CLOBBERS_LOCALTIME_BUFFER, 1,
+    AC_DEFINE([TZSET_CLOBBERS_LOCALTIME], 1,
       [Define if tzset clobbers localtime's static buffer.])
   fi
 ])
Index: m4/utimbuf.m4
===================================================================
RCS file: /cvsroot/gnulib/gnulib/m4/utimbuf.m4,v
retrieving revision 1.9
diff -u -p -r1.9 utimbuf.m4
--- m4/utimbuf.m4       23 Jan 2005 08:06:57 -0000      1.9
+++ m4/utimbuf.m4       18 Jan 2007 08:33:30 -0000
@@ -1,6 +1,6 @@
-#serial 7
+#serial 8

-# Copyright (C) 1998, 1999, 2000, 2001, 2003, 2004 Free Software
+# Copyright (C) 1998, 1999, 2000, 2001, 2003, 2004, 2007 Free Software
 # Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
@@ -16,30 +16,22 @@ dnl Some systems have utime.h but don't 
 AC_DEFUN([gl_CHECK_TYPE_STRUCT_UTIMBUF],
 [
   AC_CHECK_HEADERS_ONCE(sys/time.h utime.h)
-  AC_REQUIRE([AC_HEADER_TIME])
-  AC_CACHE_CHECK([for struct utimbuf], fu_cv_sys_struct_utimbuf,
-    [AC_TRY_COMPILE(
-      [
-#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
-#ifdef HAVE_UTIME_H
-# include <utime.h>
-#endif
-      ],
-      [static struct utimbuf x; x.actime = x.modtime;],
-      fu_cv_sys_struct_utimbuf=yes,
-      fu_cv_sys_struct_utimbuf=no)
-    ])
+  AC_CACHE_CHECK([for struct utimbuf], [gl_cv_sys_struct_utimbuf],
+    [AC_COMPILE_IFELSE(
+       [AC_LANG_PROGRAM(
+         [[#if HAVE_SYS_TIME_H
+            #include <sys/time.h>
+           #endif
+           #include <time.h>
+           #ifdef HAVE_UTIME_H
+            #include <utime.h>
+           #endif
+         ]],
+         [[static struct utimbuf x; x.actime = x.modtime;]])],
+       [gl_cv_sys_struct_utimbuf=yes],
+       [gl_cv_sys_struct_utimbuf=no])])

-  if test $fu_cv_sys_struct_utimbuf = yes; then
+  if test $gl_cv_sys_struct_utimbuf = yes; then
     AC_DEFINE(HAVE_STRUCT_UTIMBUF, 1,
       [Define if struct utimbuf is declared -- usually in <utime.h>.
        Some systems have utime.h but don't declare the struct anywhere. ])
Index: m4/stat-time.m4
===================================================================
RCS file: /cvsroot/gnulib/gnulib/m4/stat-time.m4,v
retrieving revision 1.3
diff -u -p -r1.3 stat-time.m4
--- m4/stat-time.m4     21 Aug 2006 21:46:31 -0000      1.3
+++ m4/stat-time.m4     18 Jan 2007 08:33:30 -0000
@@ -1,6 +1,6 @@
 # Checks for stat-related time functions.

-# Copyright (C) 1998, 1999, 2001, 2003, 2005, 2006 Free Software
+# Copyright (C) 1998, 1999, 2001, 2003, 2005, 2006, 2007 Free Software
 # Foundation, Inc.

 # This file is free software; the Free Software Foundation
@@ -19,6 +19,7 @@ AC_DEFUN([gl_STAT_TIME],
 [
   AC_REQUIRE([AC_C_INLINE])
   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
+  AC_CHECK_HEADERS_ONCE([sys/time.h])

   AC_CHECK_MEMBERS([struct stat.st_atim.tv_nsec],
     [AC_CACHE_CHECK([whether struct stat.st_atim is of type struct timespec],
@@ -26,17 +27,11 @@ AC_DEFUN([gl_STAT_TIME],
        [AC_TRY_COMPILE(
          [
            #include <sys/types.h>
-           #if TIME_WITH_SYS_TIME
+           #include <sys/stat.h>
+           #if HAVE_SYS_TIME_H
            # include <sys/time.h>
-           # include <time.h>
-           #else
-           # if HAVE_SYS_TIME_H
-           #  include <sys/time.h>
-           # else
-           #  include <time.h>
-           # endif
            #endif
-           #include <sys/stat.h>
+           #include <time.h>
            struct timespec ts;
            struct stat st;
          ],
Index: m4/posixtm.m4
===================================================================
RCS file: /cvsroot/gnulib/gnulib/m4/posixtm.m4,v
retrieving revision 1.5
diff -u -p -r1.5 posixtm.m4
--- m4/posixtm.m4       21 Aug 2006 21:46:31 -0000      1.5
+++ m4/posixtm.m4       18 Jan 2007 08:33:30 -0000
@@ -1,5 +1,5 @@
-# posixtm.m4 serial 5
-dnl Copyright (C) 2002, 2003, 2005, 2006 Free Software Foundation, Inc.
+# posixtm.m4 serial 6
+dnl Copyright (C) 2002, 2003, 2005, 2006, 2007 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
 dnl with or without modifications, as long as this notice is preserved.
@@ -8,6 +8,5 @@ AC_DEFUN([gl_POSIXTM],
 [
   AC_LIBOBJ(posixtm)

-  dnl Prerequisites of lib/posixtm.c.
-  AC_STRUCT_TM
+  dnl No prerequisites of lib/posixtm.c.
 ])
Index: m4/sys_time_h.m4
===================================================================
RCS file: m4/sys_time_h.m4
diff -N m4/sys_time_h.m4
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ m4/sys_time_h.m4    18 Jan 2007 08:33:31 -0000
@@ -0,0 +1,49 @@
+# Configure a replacement for <sys/time.h>.
+
+# Copyright (C) 2007 Free Software Foundation, Inc.
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# Written by Paul Eggert and Martin Lambers.
+
+AC_DEFUN([gl_HEADER_SYS_TIME_H],
+[
+  AC_REQUIRE([AC_C_RESTRICT])
+  AC_CHECK_HEADERS_ONCE([sys/time.h])
+
+  if test $ac_cv_header_sys_time_h = yes; then
+    gl_ABSOLUTE_HEADER([sys/time.h])
+    ABSOLUTE_SYS_TIME_H=\"$gl_cv_absolute_sys_time_h\"
+    HAVE_SYS_TIME_H=1
+  else
+    ABSOLUTE_SYS_TIME_H=\"no/such/file/sys/time.h\"
+    HAVE_SYS_TIME_H=0
+  fi
+  AC_SUBST([ABSOLUTE_SYS_TIME_H])
+  AC_SUBST([HAVE_SYS_TIME_H])
+
+  AC_CACHE_CHECK([for struct timeval], [gl_cv_sys_struct_timeval],
+    [AC_COMPILE_IFELSE(
+       [AC_LANG_PROGRAM(
+         [[#if HAVE_SYS_TIME_H
+            #include <sys/time.h>
+           #endif
+           #include <time.h>
+         ]],
+         [[static struct timeval x; x.tv_sec = x.tv_usec;]])],
+       [gl_cv_sys_struct_timeval=yes],
+       [gl_cv_sys_struct_timeval=no])])
+  if test $gl_cv_sys_struct_timeval = yes; then
+    HAVE_STRUCT_TIMEVAL=1
+  else
+    HAVE_STRUCT_TIMEVAL=0
+  fi
+  AC_SUBST([HAVE_STRUCT_TIMEVAL])
+
+  dnl Assume POSIX behavior unless another module says otherwise.
+  HAVE_GETTIMEOFDAY_POSIX_SIGNATURE=1
+  AC_SUBST([HAVE_GETTIMEOFDAY_POSIX_SIGNATURE])
+  GETTIMEOFDAY_CLOBBERS_LOCALTIME=0
+  AC_SUBST([GETTIMEOFDAY_CLOBBERS_LOCALTIME])
+])
Index: modules/gethrxtime
===================================================================
RCS file: /cvsroot/gnulib/gnulib/modules/gethrxtime,v
retrieving revision 1.7
diff -u -p -r1.7 gethrxtime
--- modules/gethrxtime  13 Oct 2006 12:40:23 -0000      1.7
+++ modules/gethrxtime  18 Jan 2007 08:33:31 -0000
@@ -10,8 +10,9 @@ m4/longlong.m4

 Depends-on:
 clock-time
-gettime
 extensions
+gettime
+sys_time

 configure.ac:
 gl_GETHRXTIME
Index: modules/gettime
===================================================================
RCS file: /cvsroot/gnulib/gnulib/modules/gettime,v
retrieving revision 1.10
diff -u -p -r1.10 gettime
--- modules/gettime     13 Oct 2006 12:40:23 -0000      1.10
+++ modules/gettime     18 Jan 2007 08:33:31 -0000
@@ -9,6 +9,7 @@ Depends-on:
 clock-time
 gettime
 gettimeofday
+sys_time
 timespec
 extensions

Index: modules/gettimeofday
===================================================================
RCS file: /cvsroot/gnulib/gnulib/modules/gettimeofday,v
retrieving revision 1.8
diff -u -p -r1.8 gettimeofday
--- modules/gettimeofday        17 Jan 2007 01:04:18 -0000      1.8
+++ modules/gettimeofday        18 Jan 2007 08:33:31 -0000
@@ -2,11 +2,11 @@ Description:
 gettimeofday() function: return current time.

 Files:
-lib/gettimeofday.h
 lib/gettimeofday.c
 m4/gettimeofday.m4

 Depends-on:
+sys_time

 configure.ac:
 gl_FUNC_GETTIMEOFDAY
@@ -14,11 +14,10 @@ gl_FUNC_GETTIMEOFDAY
 Makefile.am:

 Include:
-"gettimeofday.h"
+<sys/time.h>

 License:
 GPL

 Maintainer:
-Jim Meyering
-
+Paul Eggert, Jim Meyering
Index: modules/nanosleep
===================================================================
RCS file: /cvsroot/gnulib/gnulib/modules/nanosleep,v
retrieving revision 1.11
diff -u -p -r1.11 nanosleep
--- modules/nanosleep   2 Jan 2007 23:50:44 -0000       1.11
+++ modules/nanosleep   18 Jan 2007 08:33:31 -0000
@@ -7,9 +7,10 @@ m4/nanosleep.m4

 Depends-on:
 clock-time
-timespec
-stdbool
 extensions
+stdbool
+sys_time
+timespec

 configure.ac:
 gl_FUNC_NANOSLEEP
Index: modules/settime
===================================================================
RCS file: /cvsroot/gnulib/gnulib/modules/settime,v
retrieving revision 1.10
diff -u -p -r1.10 settime
--- modules/settime     2 Jan 2007 23:50:44 -0000       1.10
+++ modules/settime     18 Jan 2007 08:33:31 -0000
@@ -8,6 +8,7 @@ m4/settime.m4
 Depends-on:
 clock-time
 extensions
+sys_time
 timespec

 configure.ac:
Index: modules/tempname
===================================================================
RCS file: /cvsroot/gnulib/gnulib/modules/tempname,v
retrieving revision 1.2
diff -u -p -r1.2 tempname
--- modules/tempname    14 Nov 2006 14:12:03 -0000      1.2
+++ modules/tempname    18 Jan 2007 08:33:31 -0000
@@ -8,8 +8,10 @@ m4/tempname.m4

 Depends-on:
 extensions
+gettimeofday
 stdint
 sys_stat
+sys_time

 configure.ac:
 gl_FUNC_GEN_TEMPNAME
Index: modules/utimens
===================================================================
RCS file: /cvsroot/gnulib/gnulib/modules/utimens,v
retrieving revision 1.7
diff -u -p -r1.7 utimens
--- modules/utimens     13 Oct 2006 12:40:23 -0000      1.7
+++ modules/utimens     18 Jan 2007 08:33:31 -0000
@@ -9,6 +9,7 @@ m4/utimens.m4
 m4/utimes.m4

 Depends-on:
+sys_time
 timespec

 configure.ac:
Index: modules/sys_time
===================================================================
RCS file: modules/sys_time
diff -N modules/sys_time
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ modules/sys_time    18 Jan 2007 08:33:31 -0000
@@ -0,0 +1,40 @@
+Description:
+A <sys/time.h> that conforms better to POSIX.
+
+Files:
+lib/sys_time_.h
+m4/sys_time_h.m4
+
+Depends-on:
+absolute-header
+
+configure.ac:
+gl_HEADER_SYS_TIME_H
+
+Makefile.am:
+BUILT_SOURCES += sys/time.h
+
+# We need the following in order to create <sys/time.h> when the system
+# doesn't have one that works with the given compiler.
+sys/time.h: sys_time_.h
+       test -d sys || mkdir sys
+       rm -f address@hidden $@
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+         sed -e 's/@''HAVE_SYS_TIME_H''@/$(HAVE_SYS_TIME_H)/g' \
+             -e 's|@''ABSOLUTE_SYS_TIME_H''@|$(ABSOLUTE_SYS_TIME_H)|g' \
+             -e 
's/@''GETTIMEOFDAY_CLOBBERS_LOCALTIME''@/$(GETTIMEOFDAY_CLOBBERS_LOCALTIME)/g' \
+             -e 
's/@''HAVE_GETTIMEOFDAY_POSIX_SIGNATURE''@/$(HAVE_GETTIMEOFDAY_POSIX_SIGNATURE)/g'
 \
+             -e 's/@''HAVE_STRUCT_TIMEVAL''@/$(HAVE_STRUCT_TIMEVAL)/g' \
+             < $(srcdir)/sys_time_.h; \
+       } > address@hidden
+       mv address@hidden $@
+MOSTLYCLEANFILES += sys/time.h sys/time.h-t
+
+Include:
+#include <sys/time.h>
+
+License:
+LGPL
+
+Maintainer:
+all
Index: tests/test-gettimeofday.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/tests/test-gettimeofday.c,v
retrieving revision 1.2
diff -u -p -r1.2 test-gettimeofday.c
--- tests/test-gettimeofday.c   17 Jan 2007 01:04:18 -0000      1.2
+++ tests/test-gettimeofday.c   18 Jan 2007 08:33:31 -0000
@@ -19,11 +19,11 @@

 #include <config.h>

+#include <sys/time.h>
+
 #include <stdio.h>
 #include <string.h>

-#include "gettimeofday.h"
-
 suseconds_t dummy = 0; /* just to test if this type is available */

 int




reply via email to

[Prev in Thread] Current Thread [Next in Thread]