time_r: Add missing declarations on HP-UX 11.
authorBruno Haible <bruno@clisp.org>
Fri, 31 Dec 2010 13:01:33 +0000 (14:01 +0100)
committerBruno Haible <bruno@clisp.org>
Fri, 31 Dec 2010 13:01:33 +0000 (14:01 +0100)
* lib/time.in.h (localtime_r, gmtime_r): Test HAVE_DECL_LOCALTIME_R
instead of HAVE_LOCALTIME_R.
* m4/time_r.m4 (gl_TIME_R): Test whether localtime_r is declared. Set
HAVE_LOCALTIME_R always.
* m4/time_h.m4 (gl_HEADER_TIME_H_DEFAULTS): Initialize
HAVE_DECL_LOCALTIME_R, not HAVE_LOCALTIME_R.
* modules/time (Makefile.am): Substitute HAVE_DECL_LOCALTIME_R, not
HAVE_LOCALTIME_R.
* doc/posix-functions/gmtime_r.texi: Document the HP-UX 11 problem.
* doc/posix-functions/localtime_r.texi: Likewise.

ChangeLog
doc/posix-functions/gmtime_r.texi
doc/posix-functions/localtime_r.texi
lib/time.in.h
m4/time_h.m4
m4/time_r.m4
modules/time

index 2e12c65..865705d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2010-12-31  Bruno Haible  <bruno@clisp.org>
+
+       time_r: Add missing declarations on HP-UX 11.
+       * lib/time.in.h (localtime_r, gmtime_r): Test HAVE_DECL_LOCALTIME_R
+       instead of HAVE_LOCALTIME_R.
+       * m4/time_r.m4 (gl_TIME_R): Test whether localtime_r is declared. Set
+       HAVE_LOCALTIME_R always.
+       * m4/time_h.m4 (gl_HEADER_TIME_H_DEFAULTS): Initialize
+       HAVE_DECL_LOCALTIME_R, not HAVE_LOCALTIME_R.
+       * modules/time (Makefile.am): Substitute HAVE_DECL_LOCALTIME_R, not
+       HAVE_LOCALTIME_R.
+       * doc/posix-functions/gmtime_r.texi: Document the HP-UX 11 problem.
+       * doc/posix-functions/localtime_r.texi: Likewise.
+
 2010-12-29  Eric Blake  <eblake@redhat.com>
 
        mountlist: tweak previous commit
index f4d5a48..7d1bb30 100644 (file)
@@ -12,6 +12,10 @@ Portability problems fixed by Gnulib:
 This function is missing on some platforms:
 mingw.
 @item
+This function is not declared unless @code{_REENTRANT} is defined,
+on some platforms:
+HP-UX 11.
+@item
 Some platforms define a function of this name that is incompatible to POSIX:
 HP-UX 10.
 @end itemize
index 150663a..9c8bb10 100644 (file)
@@ -12,6 +12,10 @@ Portability problems fixed by Gnulib:
 This function is missing on some platforms:
 mingw.
 @item
+This function is not declared unless @code{_REENTRANT} is defined,
+on some platforms:
+HP-UX 11.
+@item
 Some platforms define a function of this name that is incompatible to POSIX:
 HP-UX 10.
 @end itemize
index 9507087..9eced68 100644 (file)
@@ -147,7 +147,7 @@ _GL_FUNCDECL_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
 _GL_CXXALIAS_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
                                              struct tm *restrict __result));
 #  else
-#   if ! @HAVE_LOCALTIME_R@
+#   if ! @HAVE_DECL_LOCALTIME_R@
 _GL_FUNCDECL_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
                                              struct tm *restrict __result)
                                             _GL_ARG_NONNULL ((1, 2)));
@@ -155,7 +155,9 @@ _GL_FUNCDECL_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
 _GL_CXXALIAS_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
                                              struct tm *restrict __result));
 #  endif
+#  if @HAVE_DECL_LOCALTIME_R@
 _GL_CXXALIASWARN (localtime_r);
+#  endif
 #  if @REPLACE_LOCALTIME_R@
 #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 #    undef gmtime_r
@@ -167,7 +169,7 @@ _GL_FUNCDECL_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
 _GL_CXXALIAS_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
                                           struct tm *restrict __result));
 #  else
-#   if ! @HAVE_LOCALTIME_R@
+#   if ! @HAVE_DECL_LOCALTIME_R@
 _GL_FUNCDECL_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
                                           struct tm *restrict __result)
                                          _GL_ARG_NONNULL ((1, 2)));
@@ -175,7 +177,9 @@ _GL_FUNCDECL_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
 _GL_CXXALIAS_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
                                           struct tm *restrict __result));
 #  endif
+#  if @HAVE_DECL_LOCALTIME_R@
 _GL_CXXALIASWARN (gmtime_r);
+#  endif
 # endif
 
 /* Parse BUF as a time stamp, assuming FORMAT specifies its layout, and store
index a45a10a..28dfcfe 100644 (file)
@@ -2,7 +2,7 @@
 
 # Copyright (C) 2000-2001, 2003-2007, 2009-2010 Free Software Foundation, Inc.
 
-# serial 2
+# serial 3
 
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -95,7 +95,7 @@ AC_DEFUN([gl_HEADER_TIME_H_DEFAULTS],
   GNULIB_TIMEGM=0;                       AC_SUBST([GNULIB_TIMEGM])
   GNULIB_TIME_R=0;                       AC_SUBST([GNULIB_TIME_R])
   dnl Assume proper GNU behavior unless another module says otherwise.
-  HAVE_LOCALTIME_R=1;                    AC_SUBST([HAVE_LOCALTIME_R])
+  HAVE_DECL_LOCALTIME_R=1;               AC_SUBST([HAVE_DECL_LOCALTIME_R])
   HAVE_NANOSLEEP=1;                      AC_SUBST([HAVE_NANOSLEEP])
   HAVE_STRPTIME=1;                       AC_SUBST([HAVE_STRPTIME])
   HAVE_TIMEGM=1;                         AC_SUBST([HAVE_TIMEGM])
index 9e82d39..f9bed0c 100644 (file)
@@ -15,8 +15,16 @@ AC_DEFUN([gl_TIME_R],
   AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS])
   AC_REQUIRE([AC_C_RESTRICT])
 
+  dnl Some systems don't declare localtime_r() and gmtime_r() if _REENTRANT is
+  dnl not defined.
+  AC_CHECK_DECLS_ONCE([localtime_r])
+  if test $ac_cv_have_decl_localtime_r = no; then
+    HAVE_DECL_LOCALTIME_R=0
+  fi
+
   AC_CHECK_FUNCS_ONCE([localtime_r])
   if test $ac_cv_func_localtime_r = yes; then
+    HAVE_LOCALTIME_R=1
     AC_CACHE_CHECK([whether localtime_r is compatible with its POSIX signature],
       [gl_cv_time_r_posix],
       [AC_COMPILE_IFELSE(
index 71da97d..ab5efe9 100644 (file)
@@ -33,7 +33,7 @@ time.h: time.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
              -e 's|@''GNULIB_STRPTIME''@|$(GNULIB_STRPTIME)|g' \
              -e 's|@''GNULIB_TIMEGM''@|$(GNULIB_TIMEGM)|g' \
              -e 's|@''GNULIB_TIME_R''@|$(GNULIB_TIME_R)|g' \
-             -e 's|@''HAVE_LOCALTIME_R''@|$(HAVE_LOCALTIME_R)|g' \
+             -e 's|@''HAVE_DECL_LOCALTIME_R''@|$(HAVE_DECL_LOCALTIME_R)|g' \
              -e 's|@''HAVE_NANOSLEEP''@|$(HAVE_NANOSLEEP)|g' \
              -e 's|@''HAVE_STRPTIME''@|$(HAVE_STRPTIME)|g' \
              -e 's|@''HAVE_TIMEGM''@|$(HAVE_TIMEGM)|g' \