+2010-04-03 Bruno Haible <bruno@clisp.org>
+
+ time_r: Fix C++ test error on mingw.
+ * lib/time.in.h (localtime_r, gmtime_r): Use modern idiom.
+ * m4/time_r.m4 (gl_TIME_R): When localtime_r does not exist, set
+ HAVE_LOCALTIME_R to 0, not REPLACE_LOCALTIME_R to 1.
+ * m4/time_h.m4 (gl_HEADER_TIME_H_DEFAULTS): Initialize HAVE_LOCALTIME_R.
+ * modules/time (Makefile.am): Substitute HAVE_LOCALTIME_R.
+
2010-04-03 Bruno Haible <bruno@clisp.org>
time_r: Minor updates.
_GL_CXXALIAS_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
struct tm *restrict __result));
# else
+# if ! @HAVE_LOCALTIME_R@
+_GL_FUNCDECL_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
+ struct tm *restrict __result)
+ _GL_ARG_NONNULL ((1, 2)));
+# endif
_GL_CXXALIAS_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
struct tm *restrict __result));
# endif
_GL_CXXALIAS_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
struct tm *restrict __result));
# else
+# if ! @HAVE_LOCALTIME_R@
+_GL_FUNCDECL_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
+ struct tm *restrict __result)
+ _GL_ARG_NONNULL ((1, 2)));
+# endif
_GL_CXXALIAS_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
struct tm *restrict __result));
# endif
GNULIB_STRPTIME=0; AC_SUBST([GNULIB_STRPTIME])
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=0; AC_SUBST([HAVE_LOCALTIME_R])
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.
AC_DEFUN([gl_TIME_R],
[
- dnl Persuade glibc and Solaris <time.h> to declare localtime_r.
+ dnl Persuade glibc and Solaris <time.h> to declare localtime_r.
AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS])
AC_REQUIRE([AC_C_RESTRICT])
- AC_CACHE_CHECK([whether localtime_r is compatible with its POSIX signature],
- [gl_cv_time_r_posix],
- [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
- [[#include <time.h>]],
- [[/* We don't need to append 'restrict's to the argument types,
- even though the POSIX signature has the 'restrict's,
- since C99 says they can't affect type compatibility. */
- struct tm * (*ptr) (time_t const *, struct tm *) = localtime_r;
- if (ptr) return 0;
- /* Check the return type is a pointer. On HP-UX 10 it is 'int'. */
- *localtime_r (0, 0);]])],
- [gl_cv_time_r_posix=yes],
- [gl_cv_time_r_posix=no])])
- if test $gl_cv_time_r_posix = yes; then
- REPLACE_LOCALTIME_R=0
+ AC_CHECK_FUNCS_ONCE([localtime_r])
+ if test $ac_cv_func_localtime_r = yes; then
+ AC_CACHE_CHECK([whether localtime_r is compatible with its POSIX signature],
+ [gl_cv_time_r_posix],
+ [AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[#include <time.h>]],
+ [[/* We don't need to append 'restrict's to the argument types,
+ even though the POSIX signature has the 'restrict's,
+ since C99 says they can't affect type compatibility. */
+ struct tm * (*ptr) (time_t const *, struct tm *) = localtime_r;
+ if (ptr) return 0;
+ /* Check the return type is a pointer.
+ On HP-UX 10 it is 'int'. */
+ *localtime_r (0, 0);]])
+ ],
+ [gl_cv_time_r_posix=yes],
+ [gl_cv_time_r_posix=no])
+ ])
+ if test $gl_cv_time_r_posix = yes; then
+ REPLACE_LOCALTIME_R=0
+ else
+ REPLACE_LOCALTIME_R=1
+ fi
else
- REPLACE_LOCALTIME_R=1
+ HAVE_LOCALTIME_R=0
+ fi
+ if test $HAVE_LOCALTIME_R = 0 || test $REPLACE_LOCALTIME_R = 1; then
AC_LIBOBJ([time_r])
gl_PREREQ_TIME_R
fi
-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|@''REPLACE_LOCALTIME_R''@|$(REPLACE_LOCALTIME_R)|g' \
-e 's|@''REPLACE_MKTIME''@|$(REPLACE_MKTIME)|g' \
-e 's|@''REPLACE_NANOSLEEP''@|$(REPLACE_NANOSLEEP)|g' \