From 115dcb2a1ade67d78b430081e225f46aad742e7b Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Fri, 31 Dec 2010 14:01:33 +0100 Subject: [PATCH] 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. --- ChangeLog | 14 ++++++++++++++ doc/posix-functions/gmtime_r.texi | 4 ++++ doc/posix-functions/localtime_r.texi | 4 ++++ lib/time.in.h | 8 ++++++-- m4/time_h.m4 | 4 ++-- m4/time_r.m4 | 8 ++++++++ modules/time | 2 +- 7 files changed, 39 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2e12c65a4..865705d3d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2010-12-31 Bruno Haible + + 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 mountlist: tweak previous commit diff --git a/doc/posix-functions/gmtime_r.texi b/doc/posix-functions/gmtime_r.texi index f4d5a48d9..7d1bb3094 100644 --- a/doc/posix-functions/gmtime_r.texi +++ b/doc/posix-functions/gmtime_r.texi @@ -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 diff --git a/doc/posix-functions/localtime_r.texi b/doc/posix-functions/localtime_r.texi index 150663ad0..9c8bb10fb 100644 --- a/doc/posix-functions/localtime_r.texi +++ b/doc/posix-functions/localtime_r.texi @@ -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 diff --git a/lib/time.in.h b/lib/time.in.h index 95070871a..9eced68d0 100644 --- a/lib/time.in.h +++ b/lib/time.in.h @@ -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 diff --git a/m4/time_h.m4 b/m4/time_h.m4 index a45a10a9e..28dfcfe39 100644 --- a/m4/time_h.m4 +++ b/m4/time_h.m4 @@ -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]) diff --git a/m4/time_r.m4 b/m4/time_r.m4 index 9e82d39ff..f9bed0c5c 100644 --- a/m4/time_r.m4 +++ b/m4/time_r.m4 @@ -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( diff --git a/modules/time b/modules/time index 71da97dfc..ab5efe913 100644 --- a/modules/time +++ b/modules/time @@ -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' \ -- 2.11.0