# HG changeset patch # User Bruno Haible # Date 1293800493 -3600 # Node ID f00add3c323d1442b648cb77317284cfd4e3f74e # Parent 602afdb74dc3ead4024cd0874b6e04c8486b2e9c 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. diff --git a/ChangeLog b/ChangeLog --- 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 --- a/doc/posix-functions/gmtime_r.texi +++ b/doc/posix-functions/gmtime_r.texi @@ -12,6 +12,10 @@ 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 --- a/doc/posix-functions/localtime_r.texi +++ b/doc/posix-functions/localtime_r.texi @@ -12,6 +12,10 @@ 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 --- a/lib/time.in.h +++ b/lib/time.in.h @@ -147,7 +147,7 @@ _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_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_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_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 --- 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 @@ 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 --- a/m4/time_r.m4 +++ b/m4/time_r.m4 @@ -15,8 +15,16 @@ 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 --- a/modules/time +++ b/modules/time @@ -33,7 +33,7 @@ -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' \