bug-gnulib
[Top][All Lists]
Advanced

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

Re: time_r.h -> time_.h


From: Paul Eggert
Subject: Re: time_r.h -> time_.h
Date: Mon, 12 Feb 2007 10:56:56 -0800
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux)

Simon Josefsson <address@hidden> writes:

> It would be nice to avoid '#include "time_r.h"' and just do '#include
> <time.h>' in my code.

OK, I've installed the following gnulib patch to implement this.  I've
tested this on Debian stable, Solaris 8, and OpenBSD 3.9 with
coreutils, and on Debian stable with GNU tar and Bison.  With a change
this extensive, though, there are bound to be some problems elsewhere.

Applications need to remove '#include "time_r.h"' and include <time.h>
instead, and similarly for strptime.h and timegm.h.

No changes to coreutils, tar, or Bison source were needed (except for
.cvsignore files), which is a good sign.

2007-02-12  Paul Eggert  <address@hidden>

        New module 'time', so that apps can include <time.h> as per
        POSIX and GNU instead of separate include files like time_r.h
        and timegm.h.  This implementation tries out a simpler approach
        for replacing decls in standard include files (as compared to
        the string module), somewhat as an experiment.

        * config/srclist.txt: Comment out mktime.c for now.
        * doc/gnulib-tool.texi (Initial import): Don't use time_r as an example
        since it doesn't apply any more.  Use generic wording instead.
        * MODULES.html.sh (Support for systems lacking POSIX:2001): New module
        'time'.
        * lib/time_.h, m4/time_h.m4, modules/time: New files.
        * lib/strptime.h, lib/time_r.h, lib/timegm.h: Remove.
        * lib/mktime.c: Include config.h depending on _LIBC, not HAVE_CONFIG_H.
        Don't include <sys/types.h>; no longer needed since we assume C89.
        * lib/mktime.c: Don't include "time_r.h"; no longer needed.
        * lib/strftime.c: Likewise.
        * lib/time_r.c: Likewise.
        * lib/nanosleep.c (nanosleep): #undef after include files, not before.
        * lib/nanosleep.c: Include <time.h> first, to check interface.
        * lib/strptime.c: Likewise.
        * lib/time_r.c: Likewise.
        * lib/timegm.c: Likewise.
        * lib/strptime.c: Don't include strptime.h or time_r.h; no longer
        needed.
        * lib/timegm.c: Don't include timegm.h; no longer needed.
        * lib/timespec.h: Don't include <sys/time.h> before <time.h>;
        time.h now handles any problems in that area.
        (struct timespec, nanosleep): Remove; time.h now arranges for these.
        * lib/xnanosleep.c: Don't include timespec.h; no longer needed now
        that time.h defines struct timespec.
        * m4/nanosleep.m4 (gl_FUNC_NANOSLEEP): Check that nanosleep is declared.
        Set REPLACE_NANOSLEEP.  Don't AC_DEFINE nanosleep; the time module now
        handles that.
        * m4/strptime.m4 (gl_FUNC_STPRTIME): Set REPLACE_STRPTIME.
        * m4/time_r.m4 (gl_TIME_R): Don't define HAVE_TIME_R_POSIX; no longer
        needed.  Set REPLACE_LOCALTIME.
        * m4/timegm.m4 (gl_FUNC_TIMEGM): Set REPLACE_TIMEGM.
        * m4/timespec.m4 (gl_CHECK_TYPE_STRUCT_TIMESPEC): Move to time_h.m4.
        (gl_TIMESPEC): Don't check for sys/time.h or struct timespec or
        nanosleep; time_h.m4 now does that.  Don't require
        gl_USE_SYSTEM_EXTENSIONS; no longer needed directly, and the time
        module handles this now.
        * modules/getdate (Depends-on): Remove timespec.  Add time.
        * modules/nanosleep (Depends-on): Likewise.
        * modules/stat-time (Depends-on): Likewise.
        * modules/nanosleep (Include): Include time.h, not timespec.h.
        * modules/strptime (Files): Remove lib/strptime.h.
        (Depends-on): Add extensions, time.
        (Include): Include time.h, not strptime.h.
        * modules/time_r (Files): Remove lib/time_r.h.
        (Depends-on): Add time.
        (Include): Include time.h, not time_r.h.
        * modules/timegm: Likewise.
        * modules/timespec (Description): Now does timespec-related decls
        of our own, instead of struct timespec itself.
        (Depends-on): Add time; remove extensions.
        (Maintainer): Add self.
        * modules/utimecmp (Depends-on): Add time; remove timespec.
        * modules/utimens (Depends-on): Likewise.
        * modules/xnanosleep (Depends-on): Likewise.

Index: config/srclist.txt
===================================================================
RCS file: /cvsroot/gnulib/gnulib/config/srclist.txt,v
retrieving revision 1.144
diff -u -p -r1.144 srclist.txt
--- config/srclist.txt  10 Feb 2007 14:46:17 -0000      1.144
+++ config/srclist.txt  12 Feb 2007 18:49:15 -0000
@@ -196,7 +196,7 @@ $LIBCSRC/stdlib/strtoll.c           lib gpl
 $LIBCSRC/stdlib/strtoul.c              lib gpl
 # (no more strtok_r.h) $LIBCSRC/string/strtok_r.c              lib gpl
 # (gnulib needs config.h?) $LIBCSRC/string/memmem.c            lib gpl
-$LIBCSRC/time/mktime.c                 lib gpl
+#$LIBCSRC/time/mktime.c                        lib gpl

 #
 # http://sourceware.org/bugzilla/show_bug.cgi?id=1439
Index: doc/gnulib-tool.texi
===================================================================
RCS file: /cvsroot/gnulib/gnulib/doc/gnulib-tool.texi,v
retrieving revision 1.8
diff -u -p -r1.8 gnulib-tool.texi
--- doc/gnulib-tool.texi        26 Jan 2007 22:16:55 -0000      1.8
+++ doc/gnulib-tool.texi        12 Feb 2007 18:49:15 -0000
@@ -229,17 +229,15 @@ example, you would need to make sure tha
 is evaluated when compiling all source code files, that want to make
 use of @code{strdup}.

-When an include file is provided by Gnulib
-you shouldn't try to include the corresponding system header files
-yourself, but let the gnulib header file do it.  The ordering
-of the definition for some symbols may be significant; the Gnulib
-header files take care of that.
-
-For example, to use the @code{time_r} gnulib module you should
-use include header file provided by the gnulib, and so
address@hidden "time_r.h"}, but you shouldn't explicitly
address@hidden <time.h>} as it is already done in @file{time_r.h}
-before the redefinition of some symbols.
+In the usual case where Autoconf is creating a @file{config.h} file,
+you should include @file{config.h} first, before any other include
+file.  That way, for example, if @file{config.h} defines
address@hidden to be the empty string on a pre-C99 host, the
+definition is consistent for all include files.
+
+You should include Gnulib-provided headers before system headers,
+so that Gnulib-provided headers can adjust how a system header
+behaves.

 A final word of warning: Gnulib currently assumes it will be
 responsible for @emph{all} functions that end up in the Autoconf
Index: MODULES.html.sh
===================================================================
RCS file: /cvsroot/gnulib/gnulib/MODULES.html.sh,v
retrieving revision 1.191
diff -u -p -r1.191 MODULES.html.sh
--- MODULES.html.sh     11 Feb 2007 17:02:31 -0000      1.191
+++ MODULES.html.sh     12 Feb 2007 18:49:15 -0000
@@ -1950,6 +1950,7 @@ func_all_modules ()
   func_module readlink
   func_module lstat
   func_module tempname
+  func_module time
   func_module time_r
   func_module timespec
   func_module nanosleep
Index: lib/time_.h
===================================================================
RCS file: lib/time_.h
diff -N lib/time_.h
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ lib/time_.h 12 Feb 2007 18:49:15 -0000
@@ -0,0 +1,107 @@
+/* A more-standard <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.  */
+
+/* Don't get in the way of glibc when it includes time.h merely to
+   declare a few standard symbols, rather than to declare all the
+   symbols.  */
+#if defined __need_time_t || defined __need_clock_t || defined __need_timespec
+# include @ABSOLUTE_TIME_H@
+
+#elif ! defined _GL_TIME_H
+# define _GL_TIME_H
+# include @ABSOLUTE_TIME_H@
+
+# ifdef __cplusplus
+extern "C" {
+# endif
+
+/* Some systems don't define struct timespec (e.g., AIX 4.1, Ultrix 4.3).
+   Or they define it with the wrong member names or define it in <sys/time.h>
+   (e.g., FreeBSD circa 1997).  */
+# if ! @TIME_H_DEFINES_STRUCT_TIMESPEC@
+#  if @SYS_TIME_H_DEFINES_STRUCT_TIMESPEC@
+#   include <sys/time.h>
+#  else
+#   undef timespec
+#   define timespec rpl_timespec
+struct timespec
+{
+  time_t tv_sec;
+  long int tv_nsec;
+};
+#  endif
+# endif
+
+/* Sleep for at least RQTP seconds unless interrupted,  If interrupted,
+   return -1 and store the remaining time into RMTP.  See
+   <http://www.opengroup.org/susv3xsh/nanosleep.html>.  */
+# if @REPLACE_NANOSLEEP@
+#  define nanosleep rpl_nanosleep
+int nanosleep (struct timespec const *__rqtp, struct timespec *__rmtp);
+# endif
+
+/* Convert TIMER to RESULT, assuming local time and UTC respectively.  See
+   <http://www.opengroup.org/susv3xsh/localtime_r.html> and
+   <http://www.opengroup.org/susv3xsh/gmtime_r.html>.  */
+# if @REPLACE_LOCALTIME_R@
+#  undef localtime_r
+#  define localtime_r rpl_localtime_r
+#  undef gmtime_r
+#  define gmtime_r rpl_gmtime_r
+struct tm *localtime_r (time_t const *restrict __timer,
+                       struct tm *restrict __result);
+struct tm *gmtime_r (time_t const *restrict __timer,
+                    struct tm *restrict __result);
+# endif
+
+/* Parse BUF as a time stamp, assuming FORMAT specifies its layout, and store
+   the resulting broken-down time into TM.  See
+   <http://www.opengroup.org/susv3xsh/strptime.html>.  */
+# if @REPLACE_STRPTIME@
+#  undef strptime
+#  define strptime rpl_strptime
+char *strptime (char const *restrict __buf, char const *restrict __format,
+               struct tm *restrict __tm);
+# endif
+
+/* Convert TM to a time_t value, assuming UTC.  */
+# if @REPLACE_TIMEGM@
+#  undef timegm
+#  define timegm rpl_timegm
+time_t timegm (struct tm *__tm);
+#endif
+
+/* Encourage applications to avoid unsafe functions that can overrrun
+   buffers when given outlandish struct tm values.  Portable
+   applications should use strftime (or even sprintf) instead.  */
+# if GNULIB_PORTCHECK
+#  undef asctime
+#  define asctime eschew_asctime
+#  undef asctime_r
+#  define asctime_r eschew_asctime_r
+#  undef ctime
+#  define ctime eschew_ctime
+#  undef ctime_r
+#  define ctime_r eschew_ctime_r
+# endif
+
+# ifdef __cplusplus
+}
+# endif
+
+#endif
Index: lib/strptime.h
===================================================================
RCS file: lib/strptime.h
diff -N lib/strptime.h
--- lib/strptime.h      29 Jan 2007 23:12:55 -0000      1.3
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,30 +0,0 @@
-/* Convert a string representation of time to a tm structure.
-   Copyright (C) 2001-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 GNULIB_STRPTIME_H_
-#define GNULIB_STRPTIME_H_
-
-#include <time.h>
-
-#if ! HAVE_STRPTIME
-/* See the POSIX:2001 specification
-   <http://www.opengroup.org/susv3xsh/strptime.html>.  */
-extern char *strptime (const char *restrict s, const char *restrict format,
-                      struct tm *restrict tm);
-#endif
-
-#endif /* GNULIB_STRPTIME_H_ */
Index: lib/time_r.h
===================================================================
RCS file: lib/time_r.h
diff -N lib/time_r.h
--- lib/time_r.h        12 Mar 2006 07:58:12 -0000      1.4
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,52 +0,0 @@
-/* Reentrant time functions like localtime_r.
-
-   Copyright (C) 2003, 2005, 2006 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 _TIME_R_H
-#define _TIME_R_H
-
-/* Include <time.h> first, since it may declare these functions with
-   signatures that disagree with POSIX, and we don't want to rename
-   those declarations.  */
-#include <time.h>
-
-#if !HAVE_TIME_R_POSIX
-
-/* Don't bother with asctime_r and ctime_r, since these functions are
-   not safe (like asctime and ctime, they can overrun their 26-byte
-   output buffers when given outlandish struct tm values), and we
-   don't want to encourage applications to use unsafe functions.  Use
-   strftime or even sprintf instead.  */
-
-# undef gmtime_r
-# undef localtime_r
-
-# define gmtime_r rpl_gmtime_r
-# define localtime_r rpl_localtime_r
-
-/* See the POSIX:2001 specification
-   <http://www.opengroup.org/susv3xsh/gmtime.html>.  */
-struct tm *gmtime_r (time_t const * restrict, struct tm * restrict);
-
-/* See the POSIX:2001 specification
-   <http://www.opengroup.org/susv3xsh/localtime.html>.  */
-struct tm *localtime_r (time_t const * restrict, struct tm * restrict);
-#endif
-
-#endif
Index: lib/timegm.h
===================================================================
RCS file: lib/timegm.h
diff -N lib/timegm.h
--- lib/timegm.h        14 May 2005 06:03:58 -0000      1.4
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,23 +0,0 @@
-/* Convert UTC calendar time to simple time.  Like mktime but assumes UTC.
-
-   Copyright (C) 2003, 2005 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.  */
-
-#include <time.h>
-
-#if defined HAVE_DECL_TIMEGM && !HAVE_DECL_TIMEGM
-time_t timegm (struct tm *tm);
-#endif
Index: lib/mktime.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/mktime.c,v
retrieving revision 1.55
diff -u -p -r1.55 mktime.c
--- lib/mktime.c        11 Sep 2006 12:56:50 -0000      1.55
+++ lib/mktime.c        12 Feb 2007 18:49:15 -0000
@@ -1,5 +1,5 @@
 /* Convert a `struct tm' to a time_t value.
-   Copyright (C) 1993-1999, 2002-2005, 2006 Free Software Foundation, Inc.
+   Copyright (C) 1993-1999, 2002-2005, 2006, 2007 Free Software Foundation, 
Inc.
    This file is part of the GNU C Library.
    Contributed by Paul Eggert <address@hidden>.

@@ -21,7 +21,7 @@
    mktime.  */
 /* #define DEBUG 1 */

-#ifdef HAVE_CONFIG_H
+#ifndef _LIBC
 # include <config.h>
 #endif

@@ -32,7 +32,6 @@
 # define LEAP_SECONDS_POSSIBLE 1
 #endif

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

 #include <limits.h>
@@ -141,11 +140,10 @@ const unsigned short int __mon_yday[2][1


 #ifndef _LIBC
-/* Portable standalone applications should supply a "time_r.h" that
+/* Portable standalone applications should supply a <time.h> that
    declares a POSIX-compliant localtime_r, for the benefit of older
    implementations that lack localtime_r or have a nonstandard one.
    See the gnulib time_r module for one way to implement this.  */
-# include "time_r.h"
 # undef __localtime_r
 # define __localtime_r localtime_r
 # define __mktime_internal mktime_internal
Index: lib/strftime.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/strftime.c,v
retrieving revision 1.94
diff -u -p -r1.94 strftime.c
--- lib/strftime.c      18 Jan 2007 08:33:34 -0000      1.94
+++ lib/strftime.c      12 Feb 2007 18:49:15 -0000
@@ -134,11 +134,10 @@ extern char *tzname[];
 #endif

 #if !HAVE_TM_GMTOFF
-/* Portable standalone applications should supply a "time_r.h" that
+/* Portable standalone applications should supply a "time.h" that
    declares a POSIX-compliant localtime_r, for the benefit of older
    implementations that lack localtime_r or have a nonstandard one.
    See the gnulib time_r module for one way to implement this.  */
-# include "time_r.h"
 # undef __gmtime_r
 # undef __localtime_r
 # define __gmtime_r gmtime_r
Index: lib/time_r.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/time_r.c,v
retrieving revision 1.7
diff -u -p -r1.7 time_r.c
--- lib/time_r.c        13 Sep 2006 22:38:14 -0000      1.7
+++ lib/time_r.c        12 Feb 2007 18:49:15 -0000
@@ -1,6 +1,6 @@
 /* Reentrant time functions like localtime_r.

-   Copyright (C) 2003, 2006 Free Software Foundation, Inc.
+   Copyright (C) 2003, 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
@@ -20,7 +20,7 @@

 #include <config.h>

-#include "time_r.h"
+#include <time.h>

 #include <string.h>

Index: lib/nanosleep.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/nanosleep.c,v
retrieving revision 1.22
diff -u -p -r1.22 nanosleep.c
--- lib/nanosleep.c     18 Jan 2007 08:33:34 -0000      1.22
+++ lib/nanosleep.c     12 Feb 2007 18:49:15 -0000
@@ -21,9 +21,7 @@

 #include <config.h>

-/* Undefine nanosleep here so any prototype is not redefined to be a
-   prototype for rpl_nanosleep. (they'd conflict e.g., on alpha-dec-osf3.2)  */
-#undef nanosleep
+#include <time.h>

 #include "timespec.h"

@@ -36,12 +34,12 @@
 #include <signal.h>

 #include <sys/time.h>
-#include <time.h>
-
 #include <errno.h>

 #include <unistd.h>

+#undef nanosleep
+
 enum { BILLION = 1000 * 1000 * 1000 };

 #if HAVE_BUG_BIG_NANOSLEEP
Index: lib/strptime.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/strptime.c,v
retrieving revision 1.2
diff -u -p -r1.2 strptime.c
--- lib/strptime.c      29 Jan 2007 23:12:55 -0000      1.2
+++ lib/strptime.c      12 Feb 2007 18:49:15 -0000
@@ -17,9 +17,10 @@

 #ifndef _LIBC
 # include <config.h>
-# include "strptime.h"
 #endif

+#include <time.h>
+
 #include <assert.h>
 #include <ctype.h>
 #ifdef _LIBC
@@ -27,7 +28,6 @@
 #endif
 #include <limits.h>
 #include <string.h>
-#include <time.h>
 #include <stdbool.h>

 #ifdef _LIBC
@@ -35,7 +35,6 @@
 #endif

 #ifndef _LIBC
-# include "time_r.h"
 enum ptime_locale_status { not, loc, raw };
 #endif

Index: lib/timegm.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/timegm.c,v
retrieving revision 1.5
diff -u -p -r1.5 timegm.c
--- lib/timegm.c        13 Sep 2006 22:38:14 -0000      1.5
+++ lib/timegm.c        12 Feb 2007 18:49:15 -0000
@@ -1,6 +1,6 @@
 /* Convert UTC calendar time to simple time.  Like mktime but assumes UTC.

-   Copyright (C) 1994, 1997, 2003, 2004, 2006 Free Software
+   Copyright (C) 1994, 1997, 2003, 2004, 2006, 2007 Free Software
    Foundation, Inc.  This file is part of the GNU C Library.

    This program is free software; you can redistribute it and/or modify
@@ -17,12 +17,13 @@
    along with this program; if not, write to the Free Software Foundation,
    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */

-#ifdef _LIBC
-# include <time.h>
-#else
+#ifndef _LIBC
 # include <config.h>
-# include "timegm.h"
-# include <time_r.h>
+#endif
+
+#include <time.h>
+
+#ifndef _LIBC
 # undef __gmtime_r
 # define __gmtime_r gmtime_r
 # define __mktime_internal mktime_internal
Index: lib/timespec.h
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/timespec.h,v
retrieving revision 1.8
diff -u -p -r1.8 timespec.h
--- lib/timespec.h      18 Jan 2007 08:33:34 -0000      1.8
+++ lib/timespec.h      12 Feb 2007 18:49:15 -0000
@@ -19,20 +19,8 @@
 #if ! defined TIMESPEC_H
 # define TIMESPEC_H

-# if HAVE_SYS_TIME_H
-#  include <sys/time.h>
-# 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 int tv_nsec;
-};
-# endif
-
 /* Return negative, zero, positive if A < B, A == B, A > B, respectively.
    Assume the nanosecond components are in range, or close to it.  */
 static inline int
@@ -43,12 +31,6 @@ timespec_cmp (struct timespec a, struct 
          : a.tv_nsec - b.tv_nsec);
 }

-# if ! HAVE_DECL_NANOSLEEP
-/* Don't specify a prototype here.  Some systems (e.g., OSF) declare
-   nanosleep with a conflicting one (const-less first parameter).  */
-int nanosleep ();
-# endif
-
 void gettime (struct timespec *);
 int settime (struct timespec const *);

Index: lib/xnanosleep.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/xnanosleep.c,v
retrieving revision 1.8
diff -u -p -r1.8 xnanosleep.c
--- lib/xnanosleep.c    13 Sep 2006 22:38:14 -0000      1.8
+++ lib/xnanosleep.c    12 Feb 2007 18:49:15 -0000
@@ -1,6 +1,7 @@
 /* xnanosleep.c -- a more convenient interface to nanosleep

-   Copyright (C) 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+   Copyright (C) 2002, 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
@@ -32,7 +33,6 @@
 #include <time.h>

 #include "intprops.h"
-#include "timespec.h"

 #ifndef TIME_T_MAX
 # define TIME_T_MAX TYPE_MAXIMUM (time_t)
Index: m4/time_h.m4
===================================================================
RCS file: m4/time_h.m4
diff -N m4/time_h.m4
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ m4/time_h.m4        12 Feb 2007 18:49:15 -0000
@@ -0,0 +1,76 @@
+# Configure a more-standard replacement for <time.h>.
+
+# Copyright (C) 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,
+# with or without modifications, as long as this notice is preserved.
+
+# Written by Paul Eggert and Jim Meyering.
+
+AC_DEFUN([gl_HEADER_TIME_H],
+[
+  dnl Use AC_REQUIRE here, so that the default behavior below is expanded
+  dnl once only, before all statements that occur in other macros.
+  AC_REQUIRE([gl_HEADER_TIME_H_BODY])
+])
+
+AC_DEFUN([gl_HEADER_TIME_H_BODY],
+[
+  AC_REQUIRE([AC_C_RESTRICT])
+  AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS])
+  gl_ABSOLUTE_HEADER([time.h])
+  ABSOLUTE_TIME_H=\"$gl_cv_absolute_time_h\"
+  AC_SUBST([ABSOLUTE_TIME_H])
+  AC_REQUIRE([gl_CHECK_TYPE_STRUCT_TIMESPEC])
+])
+
+AC_DEFUN([gl_HEADER_TIME_H_DEFAULTS],
+[
+  dnl If another module says to replace or to not replace, do that.
+  dnl Otherwise, replace only if someone compiles with -DGNULIB_PORTCHECK;
+  dnl this lets maintainers check for portability.
+  REPLACE_LOCALTIME_R=GNULIB_PORTCHECK;  AC_SUBST([REPLACE_LOCALTIME_R])
+  REPLACE_NANOSLEEP=GNULIB_PORTCHECK;    AC_SUBST([REPLACE_NANOSLEEP])
+  REPLACE_STRPTIME=GNULIB_PORTCHECK;     AC_SUBST([REPLACE_STRPTIME])
+  REPLACE_TIMEGM=GNULIB_PORTCHECK;       AC_SUBST([REPLACE_TIMEGM])
+])
+
+dnl Define HAVE_STRUCT_TIMESPEC if `struct timespec' is declared
+dnl in time.h or sys/time.h.
+
+AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC],
+[
+  AC_CHECK_HEADERS_ONCE([sys/time.h])
+  AC_CACHE_CHECK([for struct timespec in <time.h>],
+    [gl_cv_sys_struct_timespec_in_time_h],
+    [AC_COMPILE_IFELSE(
+       [AC_LANG_PROGRAM(
+         [[#include <time.h>
+         ]],
+         [[static struct timespec x; x.tv_sec = x.tv_nsec;]])],
+       [gl_cv_sys_struct_timespec_in_time_h=yes],
+       [gl_cv_sys_struct_timespec_in_time_h=no])])
+
+  TIME_H_DEFINES_STRUCT_TIMESPEC=0
+  SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=0
+  if test $gl_cv_sys_struct_timespec_in_time_h = yes; then
+    TIME_H_DEFINES_STRUCT_TIMESPEC=1
+  else
+    AC_CACHE_CHECK([for struct timespec in <sys/time.h>],
+      [gl_cv_sys_struct_timespec_in_sys_time_h],
+      [AC_COMPILE_IFELSE(
+        [AC_LANG_PROGRAM(
+           [[#include <sys/time.h>
+           ]],
+           [[static struct timespec x; x.tv_sec = x.tv_nsec;]])],
+        [gl_cv_sys_struct_timespec_in_sys_time_h=yes],
+        [gl_cv_sys_struct_timespec_in_sys_time_h=no])])
+    if test $gl_cv_sys_struct_timespec_in_time_h = yes; then
+      SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=1
+    fi
+  fi
+  AC_SUBST([TIME_H_DEFINES_STRUCT_TIMESPEC])
+  AC_SUBST([SYS_TIME_H_DEFINES_STRUCT_TIMESPEC])
+])
Index: m4/nanosleep.m4
===================================================================
RCS file: /cvsroot/gnulib/gnulib/m4/nanosleep.m4,v
retrieving revision 1.27
diff -u -p -r1.27 nanosleep.m4
--- m4/nanosleep.m4     18 Jan 2007 08:33:35 -0000      1.27
+++ m4/nanosleep.m4     12 Feb 2007 18:49:15 -0000
@@ -1,4 +1,4 @@
-#serial 20
+#serial 21

 dnl From Jim Meyering.
 dnl Check for the nanosleep function.
@@ -67,6 +67,7 @@ AC_DEFUN([gl_FUNC_NANOSLEEP],
          ts_sleep.tv_nsec = 999999999;
          alarm (1);
          if (nanosleep (&ts_sleep, &ts_remaining) == -1 && errno == EINTR
+             && nanosleep
              && TYPE_MAXIMUM (time_t) - 10 < ts_remaining.tv_sec)
            return 0;
          return 119;
@@ -78,7 +79,10 @@ AC_DEFUN([gl_FUNC_NANOSLEEP],
       esac],
      [gl_cv_func_nanosleep=cross-compiling])
   ])
-  if test "$gl_cv_func_nanosleep" != yes; then
+  if test "$gl_cv_func_nanosleep" = yes; then
+    REPLACE_NANOSLEEP=0
+  else
+    REPLACE_NANOSLEEP=1
     if test "$gl_cv_func_nanosleep" = 'no (mishandles large arguments)'; then
       AC_DEFINE([HAVE_BUG_BIG_NANOSLEEP], 1,
        [Define to 1 if nanosleep mishandle large arguments.])
@@ -90,8 +94,6 @@ AC_DEFUN([gl_FUNC_NANOSLEEP],
       done
     fi
     AC_LIBOBJ(nanosleep)
-    AC_DEFINE(nanosleep, rpl_nanosleep,
-      [Define to rpl_nanosleep if the replacement function should be used.])
     gl_PREREQ_NANOSLEEP
   fi

Index: m4/strptime.m4
===================================================================
RCS file: /cvsroot/gnulib/gnulib/m4/strptime.m4,v
retrieving revision 1.2
diff -u -p -r1.2 strptime.m4
--- m4/strptime.m4      29 Jan 2007 23:12:55 -0000      1.2
+++ m4/strptime.m4      12 Feb 2007 18:49:15 -0000
@@ -1,4 +1,4 @@
-# strptime.m4 serial 2
+# strptime.m4 serial 3
 dnl Copyright (C) 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,
@@ -9,4 +9,9 @@ AC_DEFUN([gl_FUNC_STRPTIME],
   AC_REQUIRE([AC_C_RESTRICT])
   AC_REPLACE_FUNCS(strptime)
   AC_REQUIRE([gl_TM_GMTOFF])
+  if test $ac_cv_func_strptime = yes; then
+    REPLACE_STRPTIME=0
+  else
+    REPLACE_STRPTIME=1
+  fi
 ])
Index: m4/time_r.m4
===================================================================
RCS file: /cvsroot/gnulib/gnulib/m4/time_r.m4,v
retrieving revision 1.6
diff -u -p -r1.6 time_r.m4
--- m4/time_r.m4        22 Sep 2006 18:09:47 -0000      1.6
+++ m4/time_r.m4        12 Feb 2007 18:49:15 -0000
@@ -1,6 +1,6 @@
 dnl Reentrant time functions like localtime_r.

-dnl Copyright (C) 2003, 2006 Free Software Foundation, Inc.
+dnl Copyright (C) 2003, 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.
@@ -24,10 +24,9 @@ AC_DEFUN([gl_TIME_R],
        [gl_cv_time_r_posix=yes],
        [gl_cv_time_r_posix=no])])
   if test $gl_cv_time_r_posix = yes; then
-    AC_DEFINE([HAVE_TIME_R_POSIX], 1,
-      [Define to 1 if localtime_r, etc. have the type signatures that
-       POSIX requires.])
+    REPLACE_LOCALTIME_R=0
   else
+    REPLACE_LOCALTIME_R=1
     AC_LIBOBJ([time_r])
     gl_PREREQ_TIME_R
   fi
Index: m4/timegm.m4
===================================================================
RCS file: /cvsroot/gnulib/gnulib/m4/timegm.m4,v
retrieving revision 1.3
diff -u -p -r1.3 timegm.m4
--- m4/timegm.m4        23 Jan 2005 08:06:57 -0000      1.3
+++ m4/timegm.m4        12 Feb 2007 18:49:15 -0000
@@ -1,5 +1,5 @@
-# timegm.m4 serial 3
-dnl Copyright (C) 2003 Free Software Foundation, Inc.
+# timegm.m4 serial 4
+dnl Copyright (C) 2003, 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.
@@ -14,11 +14,13 @@ AC_DEFUN([gl_FUNC_TIMEGM],
   else
     AC_REPLACE_FUNCS(timegm)
   fi
-  if test $ac_cv_func_timegm = no; then
+  REPLACE_TIMEGM=1
+  if test $ac_cv_func_timegm = yes; then
+    AC_CHECK_DECLS([timegm], [REPLACE_TIMEGM=0], [], [#include <time.h>])
+  fi
+  if test $REPLACE_TIMEGM = 1; then
     gl_PREREQ_TIMEGM
   fi
-
-  AC_CHECK_DECLS([timegm], , , [#include <time.h>])
 ])

 # Prerequisites of lib/timegm.c.
Index: m4/timespec.m4
===================================================================
RCS file: /cvsroot/gnulib/gnulib/m4/timespec.m4,v
retrieving revision 1.14
diff -u -p -r1.14 timespec.m4
--- m4/timespec.m4      18 Jan 2007 08:33:35 -0000      1.14
+++ m4/timespec.m4      12 Feb 2007 18:49:15 -0000
@@ -1,4 +1,4 @@
-#serial 13
+#serial 14

 # Copyright (C) 2000, 2001, 2003, 2004, 2005, 2006, 2007 Free Software
 # Foundation, Inc.
@@ -13,38 +13,4 @@ AC_DEFUN([gl_TIMESPEC],
 [
   dnl Prerequisites of lib/timespec.h.
   AC_REQUIRE([AC_C_INLINE])
-  AC_CHECK_HEADERS_ONCE(sys/time.h)
-  gl_CHECK_TYPE_STRUCT_TIMESPEC
-
-  dnl Persuade glibc and Solaris <time.h> to declare nanosleep.
-  AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
-
-  AC_CHECK_DECLS(nanosleep, , , [#include <time.h>])
-])
-
-dnl Define HAVE_STRUCT_TIMESPEC if `struct timespec' is declared
-dnl in time.h or sys/time.h.
-
-AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC],
-[
-  dnl Persuade pedantic Solaris to declare struct timespec.
-  AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
-
-  AC_CHECK_HEADERS_ONCE(sys/time.h)
-  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: modules/time
===================================================================
RCS file: modules/time
diff -N modules/time
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ modules/time        12 Feb 2007 18:49:15 -0000
@@ -0,0 +1,42 @@
+Description:
+A more-standard <time.h>.
+
+Files:
+lib/time_.h
+m4/time_h.m4
+
+Depends-on:
+absolute-header
+extensions
+
+configure.ac:
+gl_HEADER_TIME_H
+
+Makefile.am:
+BUILT_SOURCES += time.h
+
+# We need the following in order to create <time.h> when the system
+# doesn't have one that works with the given compiler.
+time.h: time_.h
+       rm -f address@hidden $@
+       { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */' && \
+         sed -e 's|@ABSOLUTE_TIME_H''@|$(ABSOLUTE_TIME_H)|g' \
+             -e 's|@REPLACE_LOCALTIME_R''@|$(REPLACE_LOCALTIME_R)|g' \
+             -e 's|@REPLACE_NANOSLEEP''@|$(REPLACE_NANOSLEEP)|g' \
+             -e 's|@REPLACE_STRPTIME''@|$(REPLACE_STRPTIME)|g' \
+             -e 's|@REPLACE_TIMEGM''@|$(REPLACE_TIMEGM)|g' \
+             -e 
's|@SYS_TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(SYS_TIME_H_DEFINES_STRUCT_TIMESPEC)|g'
 \
+             -e 
's|@TIME_H_DEFINES_STRUCT_TIMESPEC''@|$(TIME_H_DEFINES_STRUCT_TIMESPEC)|g' \
+             < $(srcdir)/time_.h; \
+       } > address@hidden
+       mv address@hidden $@
+MOSTLYCLEANFILES += time.h time.h-t
+
+Include:
+#include <time.h>
+
+License:
+LGPL
+
+Maintainer:
+all
Index: modules/getdate
===================================================================
RCS file: /cvsroot/gnulib/gnulib/modules/getdate,v
retrieving revision 1.15
diff -u -p -r1.15 getdate
--- modules/getdate     13 Oct 2006 12:40:23 -0000      1.15
+++ modules/getdate     12 Feb 2007 18:49:15 -0000
@@ -10,11 +10,11 @@ m4/tm_gmtoff.m4
 m4/getdate.m4

 Depends-on:
-timespec
 stdbool
 gettime
 mktime
 setenv
+time
 xalloc

 configure.ac:
Index: modules/nanosleep
===================================================================
RCS file: /cvsroot/gnulib/gnulib/modules/nanosleep,v
retrieving revision 1.13
diff -u -p -r1.13 nanosleep
--- modules/nanosleep   1 Feb 2007 01:52:34 -0000       1.13
+++ modules/nanosleep   12 Feb 2007 18:49:15 -0000
@@ -10,7 +10,7 @@ clock-time
 extensions
 stdbool
 sys_time
-timespec
+time

 configure.ac:
 gl_FUNC_NANOSLEEP
@@ -18,7 +18,7 @@ gl_FUNC_NANOSLEEP
 Makefile.am:

 Include:
-"timespec.h"
+<time.h>

 Link:
 $(LIB_NANOSLEEP)
Index: modules/stat-time
===================================================================
RCS file: /cvsroot/gnulib/gnulib/modules/stat-time,v
retrieving revision 1.3
diff -u -p -r1.3 stat-time
--- modules/stat-time   13 Oct 2006 12:40:23 -0000      1.3
+++ modules/stat-time   12 Feb 2007 18:49:15 -0000
@@ -6,7 +6,7 @@ lib/stat-time.h
 m4/stat-time.m4

 Depends-on:
-timespec
+time

 configure.ac:
 gl_STAT_TIME
Index: modules/strptime
===================================================================
RCS file: /cvsroot/gnulib/gnulib/modules/strptime,v
retrieving revision 1.3
diff -u -p -r1.3 strptime
--- modules/strptime    29 Jan 2007 23:12:55 -0000      1.3
+++ modules/strptime    12 Feb 2007 18:49:15 -0000
@@ -2,16 +2,17 @@ Description:
 Convert a string representation of time to a tm structure.

 Files:
-lib/strptime.h
 lib/strptime.c
 m4/strptime.m4
 m4/tm_gmtoff.m4

 Depends-on:
+extensions
 sys_time
 string
 strcase
 stdbool
+time
 time_r

 configure.ac:
@@ -20,7 +21,7 @@ gl_FUNC_STRPTIME
 Makefile.am:

 Include:
-"strptime.h"
+<time.h>

 License:
 LGPL
Index: modules/time_r
===================================================================
RCS file: /cvsroot/gnulib/gnulib/modules/time_r,v
retrieving revision 1.10
diff -u -p -r1.10 time_r
--- modules/time_r      13 Oct 2006 12:40:23 -0000      1.10
+++ modules/time_r      12 Feb 2007 18:49:15 -0000
@@ -3,11 +3,11 @@ Reentrant time functions like localtime_

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

 Depends-on:
 extensions
+time

 configure.ac:
 gl_TIME_R
@@ -15,7 +15,7 @@ gl_TIME_R
 Makefile.am:

 Include:
-"time_r.h"
+<time.h>

 License:
 LGPL
Index: modules/timegm
===================================================================
RCS file: /cvsroot/gnulib/gnulib/modules/timegm,v
retrieving revision 1.5
diff -u -p -r1.5 timegm
--- modules/timegm      13 Oct 2006 12:40:23 -0000      1.5
+++ modules/timegm      12 Feb 2007 18:49:15 -0000
@@ -2,12 +2,12 @@ Description:
 Convert calendar time to simple time, inverse of mktime.

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

 Depends-on:
 mktime
+time
 time_r

 configure.ac:
@@ -16,7 +16,7 @@ gl_FUNC_TIMEGM
 Makefile.am:

 Include:
-"timegm.h"
+<time.h>

 License:
 LGPL
Index: modules/timespec
===================================================================
RCS file: /cvsroot/gnulib/gnulib/modules/timespec,v
retrieving revision 1.9
diff -u -p -r1.9 timespec
--- modules/timespec    13 Oct 2006 12:40:23 -0000      1.9
+++ modules/timespec    12 Feb 2007 18:49:15 -0000
@@ -1,12 +1,12 @@
 Description:
-struct timespec.
+timespec-related declarations

 Files:
 lib/timespec.h
 m4/timespec.m4

 Depends-on:
-extensions
+time

 configure.ac:
 gl_TIMESPEC
@@ -20,4 +20,4 @@ License:
 GPL

 Maintainer:
-Jim Meyering
+Paul Eggert and Jim Meyering
Index: modules/utimecmp
===================================================================
RCS file: /cvsroot/gnulib/gnulib/modules/utimecmp,v
retrieving revision 1.12
diff -u -p -r1.12 utimecmp
--- modules/utimecmp    13 Oct 2006 12:40:23 -0000      1.12
+++ modules/utimecmp    12 Feb 2007 18:49:15 -0000
@@ -9,7 +9,7 @@ m4/utimecmp.m4
 Depends-on:
 hash
 stat-time
-timespec
+time
 utimens
 xalloc
 intprops
Index: modules/utimens
===================================================================
RCS file: /cvsroot/gnulib/gnulib/modules/utimens,v
retrieving revision 1.8
diff -u -p -r1.8 utimens
--- modules/utimens     18 Jan 2007 08:33:35 -0000      1.8
+++ modules/utimens     12 Feb 2007 18:49:15 -0000
@@ -10,7 +10,7 @@ m4/utimes.m4

 Depends-on:
 sys_time
-timespec
+time

 configure.ac:
 gl_UTIMENS
Index: modules/xnanosleep
===================================================================
RCS file: /cvsroot/gnulib/gnulib/modules/xnanosleep,v
retrieving revision 1.11
diff -u -p -r1.11 xnanosleep
--- modules/xnanosleep  13 Oct 2006 12:40:23 -0000      1.11
+++ modules/xnanosleep  12 Feb 2007 18:49:15 -0000
@@ -8,7 +8,7 @@ m4/xnanosleep.m4

 Depends-on:
 nanosleep
-timespec
+time
 intprops
 stdbool





reply via email to

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