* MODULES.html.sh (Support for systems lacking POSIX:2001): New
authorPaul Eggert <eggert@cs.ucla.edu>
Thu, 18 Jan 2007 08:33:34 +0000 (08:33 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 18 Jan 2007 08:33:34 +0000 (08:33 +0000)
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.

34 files changed:
ChangeLog
MODULES.html.sh
lib/gethrxtime.c
lib/gettime.c
lib/gettimeofday.c
lib/gettimeofday.h [deleted file]
lib/nanosleep.c
lib/posixtm.c
lib/posixtm.h
lib/settime.c
lib/strftime.c
lib/sys_time_.h [new file with mode: 0644]
lib/tempname.c
lib/timespec.h
lib/utimens.c
m4/gettimeofday.m4
m4/mktime.m4
m4/nanosleep.m4
m4/posixtm.m4
m4/stat-time.m4
m4/strftime.m4
m4/sys_time_h.m4 [new file with mode: 0644]
m4/timespec.m4
m4/tzset.m4
m4/utimbuf.m4
modules/gethrxtime
modules/gettime
modules/gettimeofday
modules/nanosleep
modules/settime
modules/sys_time [new file with mode: 0644]
modules/tempname
modules/utimens
tests/test-gettimeofday.c

index 25b69a4..d4169aa 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,94 @@
+2007-01-17  Paul Eggert  <eggert@cs.ucla.edu>
+
+       * 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.
+
 2007-01-17  Bruno Haible  <bruno@clisp.org>
 
        * gnulib-tool (func_get_license): Revert last patch. Instead, let
index d1a6684..eff713c 100755 (executable)
@@ -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 f3d41c7..2046e06 100644 (file)
@@ -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 abef2c4..86bd325 100644 (file)
@@ -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 38094b0..1aee107 100644 (file)
@@ -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
 #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;
-  int result;
+# if GETTIMEOFDAY_CLOBBERS_LOCALTIME
+  /* 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
 
-  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
 }
diff --git a/lib/gettimeofday.h b/lib/gettimeofday.h
deleted file mode 100644 (file)
index d361ed1..0000000
+++ /dev/null
@@ -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 fe22a97..bb47268 100644 (file)
@@ -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>
 #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 5a839d6..5514ba4 100644 (file)
@@ -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
 
 #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 c17b318..e91749d 100644 (file)
@@ -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 9d48f16..25e7e68 100644 (file)
@@ -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 361a212..3fce99b 100644 (file)
 #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
diff --git a/lib/sys_time_.h b/lib/sys_time_.h
new file mode 100644 (file)
index 0000000..96291c9
--- /dev/null
@@ -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 919badb..e213600 100644 (file)
@@ -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
 #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 8188c20..c652577 100644 (file)
@@ -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
 #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 8f4273c..71bc510 100644 (file)
@@ -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 51b916a..9f70e10 100644 (file)
@@ -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_REQUIRE([gl_HEADER_SYS_TIME_H])
+  AC_CHECK_FUNCS_ONCE([gettimeofday])
 
-  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_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_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
+ AC_REQUIRE([gl_HEADER_SYS_TIME_H])
 
-#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);
+ AC_CACHE_CHECK([whether gettimeofday clobbers localtime buffer],
+  [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])])
 
-  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
+ 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 a65a369..b0eac13 100644 (file)
@@ -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 9741b15..d25295e 100644 (file)
@@ -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 f0c5b28..7ace2a9 100644 (file)
@@ -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 1e46a09..353de21 100644 (file)
@@ -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 7abad56..ec5873a 100644 (file)
@@ -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])
 
diff --git a/m4/sys_time_h.m4 b/m4/sys_time_h.m4
new file mode 100644 (file)
index 0000000..4387cd8
--- /dev/null
@@ -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 c281128..3305fd7 100644 (file)
@@ -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)
-    ])
-
-  if test $fu_cv_sys_struct_timespec = yes; then
+  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 $gl_cv_sys_struct_timespec = yes; then
     AC_DEFINE(HAVE_STRUCT_TIMESPEC, 1,
              [Define if struct timespec is declared in <time.h>. ])
   fi
index 134080c..b8c111b 100644 (file)
@@ -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.
 
 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 56f1bce..9927908 100644 (file)
@@ -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 declare the struct anywhere.
 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 2eea8b4..3de2ee4 100644 (file)
@@ -10,8 +10,9 @@ m4/longlong.m4
 
 Depends-on:
 clock-time
-gettime
 extensions
+gettime
+sys_time
 
 configure.ac:
 gl_GETHRXTIME
index f787a78..2e2c52e 100644 (file)
@@ -9,6 +9,7 @@ Depends-on:
 clock-time
 gettime
 gettimeofday
+sys_time
 timespec
 extensions
 
index 9b9b35a..d9821d4 100644 (file)
@@ -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 64cc02e..02398d4 100644 (file)
@@ -7,9 +7,10 @@ m4/nanosleep.m4
 
 Depends-on:
 clock-time
-timespec
-stdbool
 extensions
+stdbool
+sys_time
+timespec
 
 configure.ac:
 gl_FUNC_NANOSLEEP
index 6f33653..9ca84a0 100644 (file)
@@ -8,6 +8,7 @@ m4/settime.m4
 Depends-on:
 clock-time
 extensions
+sys_time
 timespec
 
 configure.ac:
diff --git a/modules/sys_time b/modules/sys_time
new file mode 100644 (file)
index 0000000..16a227e
--- /dev/null
@@ -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 $@-t $@
+       { 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; \
+       } > $@-t
+       mv $@-t $@
+MOSTLYCLEANFILES += sys/time.h sys/time.h-t
+
+Include:
+#include <sys/time.h>
+
+License:
+LGPL
+
+Maintainer:
+all
index 9b619a3..af689de 100644 (file)
@@ -8,8 +8,10 @@ m4/tempname.m4
 
 Depends-on:
 extensions
+gettimeofday
 stdint
 sys_stat
+sys_time
 
 configure.ac:
 gl_FUNC_GEN_TEMPNAME
index 6cc5e31..c341f65 100644 (file)
@@ -9,6 +9,7 @@ m4/utimens.m4
 m4/utimes.m4
 
 Depends-on:
+sys_time
 timespec
 
 configure.ac:
index e98266a..f4735d6 100644 (file)
 
 #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