From 1ecf90d34bc48369746e4c8c8d093a57d175a68c Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sat, 3 Apr 2010 19:15:04 +0200 Subject: [PATCH] timegm: Fix C++ test error on mingw. --- ChangeLog | 9 +++++++++ lib/time.in.h | 3 +++ m4/time_h.m4 | 1 + m4/timegm.m4 | 16 ++++++++-------- modules/time | 1 + 5 files changed, 22 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index ecea28d75..cd8c29658 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 2010-04-03 Bruno Haible + timegm: Fix C++ test error on mingw. + * lib/time.in.h (timegm): Use modern idiom. + * m4/timegm.m4 (gl_FUNC_TIMEGM): When timegm does not exist, set + HAVE_TIMEGM to 0, not REPLACE_TIMEGM to 1. + * m4/time_h.m4 (gl_HEADER_TIME_H_DEFAULTS): Initialize HAVE_TIMEGM. + * modules/time (Makefile.am): Substitute HAVE_TIMEGM. + +2010-04-03 Bruno Haible + timegm: Assume declaration if function exists. * m4/timegm.m4 (gl_FUNC_TIMEGM): Assume timegm is declared if and only if it exists. Don't clobber ac_cv_func_timegm. diff --git a/lib/time.in.h b/lib/time.in.h index 35610160c..aeea0b21c 100644 --- a/lib/time.in.h +++ b/lib/time.in.h @@ -187,6 +187,9 @@ _GL_CXXALIASWARN (strptime); _GL_FUNCDECL_RPL (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1))); _GL_CXXALIAS_RPL (timegm, time_t, (struct tm *__tm)); # else +# if ! @HAVE_TIMEGM@ +_GL_FUNCDECL_SYS (timegm, time_t, (struct tm *__tm) _GL_ARG_NONNULL ((1))); +# endif _GL_CXXALIAS_SYS (timegm, time_t, (struct tm *__tm)); # endif _GL_CXXALIASWARN (timegm); diff --git a/m4/time_h.m4 b/m4/time_h.m4 index ecab80790..f69038a59 100644 --- a/m4/time_h.m4 +++ b/m4/time_h.m4 @@ -79,6 +79,7 @@ AC_DEFUN([gl_HEADER_TIME_H_DEFAULTS], 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]) + HAVE_TIMEGM=0; AC_SUBST([HAVE_TIMEGM]) 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. diff --git a/m4/timegm.m4 b/m4/timegm.m4 index 010a6f20a..bdaafbff8 100644 --- a/m4/timegm.m4 +++ b/m4/timegm.m4 @@ -1,4 +1,4 @@ -# timegm.m4 serial 7 +# timegm.m4 serial 8 dnl Copyright (C) 2003, 2007, 2009, 2010 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,16 +9,16 @@ AC_DEFUN([gl_FUNC_TIMEGM], AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS]) AC_REQUIRE([gl_FUNC_MKTIME]) REPLACE_TIMEGM=0 - if test $ac_cv_func_working_mktime = no; then - # Assume that timegm is buggy if mktime is. - REPLACE_TIMEGM=1 - else - AC_CHECK_FUNCS([timegm]) - if test $ac_cv_func_timegm != yes; then + AC_CHECK_FUNCS_ONCE([timegm]) + if test $ac_cv_func_timegm = yes; then + if test $ac_cv_func_working_mktime = no; then + # Assume that timegm is buggy if mktime is. REPLACE_TIMEGM=1 fi + else + HAVE_TIMEGM=0 fi - if test $REPLACE_TIMEGM = 1; then + if test $HAVE_TIMEGM = 0 || test $REPLACE_TIMEGM = 1; then AC_LIBOBJ([timegm]) gl_PREREQ_TIMEGM fi diff --git a/modules/time b/modules/time index bfc208bfa..287dec193 100644 --- a/modules/time +++ b/modules/time @@ -33,6 +33,7 @@ time.h: time.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H) -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_TIMEGM''@|$(HAVE_TIMEGM)|g' \ -e 's|@''REPLACE_LOCALTIME_R''@|$(REPLACE_LOCALTIME_R)|g' \ -e 's|@''REPLACE_MKTIME''@|$(REPLACE_MKTIME)|g' \ -e 's|@''REPLACE_NANOSLEEP''@|$(REPLACE_NANOSLEEP)|g' \ -- 2.11.0