Fix compilation error on mingw when module 'time_r' is not used.
authorBruno Haible <bruno@clisp.org>
Sun, 14 Mar 2010 18:55:44 +0000 (19:55 +0100)
committerBruno Haible <bruno@clisp.org>
Sun, 14 Mar 2010 18:55:44 +0000 (19:55 +0100)
ChangeLog
lib/time.in.h
m4/time_h.m4
modules/time
modules/time_r
tests/test-time-c++.cc

index 305a835..129dd8a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2010-03-14  Bruno Haible  <bruno@clisp.org>
 
+       Fix compilation error on mingw when module 'time_r' is not used.
+       * lib/time.in.h (localtime_r, gmtime_r): Declare only if GNULIB_TIME_R
+       is 1.
+       * tests/test-time-c++.cc (localtime_r, gmtime_r): Likewise.
+       * modules/time_r (configure.ac): Invoke gl_TIME_MODULE_INDICATOR.
+       * modules/time (Makefile.am): Substitute GNULIB_TIME_R.
+       * m4/time_h.m4 (gl_HEADER_TIME_H_DEFAULTS): Initialize GNULIB_TIME_R.
+
+2010-03-14  Bruno Haible  <bruno@clisp.org>
+
        Fix compilation error with Sun C.
        * lib/strtol.c: Use LLONG_MIN instead of GCC specific LONG_LONG_MIN.
        Use LLONG_MAX instead of GCC specific LONG_LONG_MAX. Use ULLONG_MAX
index d2cf84b..a5d3ae4 100644 (file)
@@ -108,36 +108,38 @@ _GL_CXXALIASWARN (mktime);
 /* Convert TIMER to RESULT, assuming local time and UTC respectively.  See
    <http://www.opengroup.org/susv3xsh/localtime_r.html> and
    <http://www.opengroup.org/susv3xsh/gmtime_r.html>.  */
-# if @REPLACE_LOCALTIME_R@
-#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-#   undef localtime_r
-#   define localtime_r rpl_localtime_r
-#  endif
+# if @GNULIB_TIME_R@
+#  if @REPLACE_LOCALTIME_R@
+#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#    undef localtime_r
+#    define localtime_r rpl_localtime_r
+#   endif
 _GL_FUNCDECL_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
                                              struct tm *restrict __result)
                                             _GL_ARG_NONNULL ((1, 2)));
 _GL_CXXALIAS_RPL (localtime_r, struct tm *, (time_t const *restrict __timer,
                                              struct tm *restrict __result));
-# else
+#  else
 _GL_CXXALIAS_SYS (localtime_r, struct tm *, (time_t const *restrict __timer,
                                              struct tm *restrict __result));
-# endif
-_GL_CXXALIASWARN (localtime_r);
-# if @REPLACE_LOCALTIME_R@
-#  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
-#   undef gmtime_r
-#   define gmtime_r rpl_gmtime_r
 #  endif
+_GL_CXXALIASWARN (localtime_r);
+#  if @REPLACE_LOCALTIME_R@
+#   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
+#    undef gmtime_r
+#    define gmtime_r rpl_gmtime_r
+#   endif
 _GL_FUNCDECL_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
                                           struct tm *restrict __result)
                                          _GL_ARG_NONNULL ((1, 2)));
 _GL_CXXALIAS_RPL (gmtime_r, struct tm *, (time_t const *restrict __timer,
                                           struct tm *restrict __result));
-# else
+#  else
 _GL_CXXALIAS_SYS (gmtime_r, struct tm *, (time_t const *restrict __timer,
                                           struct tm *restrict __result));
-# endif
+#  endif
 _GL_CXXALIASWARN (gmtime_r);
+# endif
 
 /* Parse BUF as a time stamp, assuming FORMAT specifies its layout, and store
    the resulting broken-down time into TM.  See
index ba2e194..f572b85 100644 (file)
@@ -76,6 +76,7 @@ AC_DEFUN([gl_HEADER_TIME_H_DEFAULTS],
   GNULIB_NANOSLEEP=0;                    AC_SUBST([GNULIB_NANOSLEEP])
   GNULIB_STRPTIME=0;                     AC_SUBST([GNULIB_STRPTIME])
   GNULIB_TIMEGM=0;                       AC_SUBST([GNULIB_TIMEGM])
+  GNULIB_TIME_R=0;                       AC_SUBST([GNULIB_TIME_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.
index 02c7a20..733c969 100644 (file)
@@ -31,6 +31,7 @@ time.h: time.in.h $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
              -e 's|@''GNULIB_NANOSLEEP''@|$(GNULIB_NANOSLEEP)|g' \
              -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|@''REPLACE_LOCALTIME_R''@|$(REPLACE_LOCALTIME_R)|g' \
              -e 's|@''REPLACE_MKTIME''@|$(REPLACE_MKTIME)|g' \
              -e 's|@''REPLACE_NANOSLEEP''@|$(REPLACE_NANOSLEEP)|g' \
index 8349bcf..f181b5d 100644 (file)
@@ -11,6 +11,7 @@ time
 
 configure.ac:
 gl_TIME_R
+gl_TIME_MODULE_INDICATOR([time_r])
 
 Makefile.am:
 
index 501345f..bb6fd20 100644 (file)
@@ -33,11 +33,13 @@ SIGNATURE_CHECK (GNULIB_NAMESPACE::nanosleep, int,
 SIGNATURE_CHECK (GNULIB_NAMESPACE::mktime, time_t, (struct tm *));
 #endif
 
+#if GNULIB_TIME_R
 SIGNATURE_CHECK (GNULIB_NAMESPACE::localtime_r, struct tm *,
                  (time_t const *, struct tm *));
 
 SIGNATURE_CHECK (GNULIB_NAMESPACE::gmtime_r, struct tm *,
                  (time_t const *, struct tm *));
+#endif
 
 #if GNULIB_STRPTIME
 SIGNATURE_CHECK (GNULIB_NAMESPACE::strptime, char *,