[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
localtime_r on mingw
From: |
Bruno Haible |
Subject: |
localtime_r on mingw |
Date: |
Sat, 3 Apr 2010 17:53:08 +0100 |
User-agent: |
KMail/1.9.9 |
Still on mingw, I'm seeing these errors:
../gllib/time.h:394: error: `localtime_r' was not declared in this scope
../gllib/time.h:409: error: `gmtime_r' was not declared in this scope
Same problem: The m4 macros don't distinguish a missing function from a broken
system function. This fixes it.
2010-04-03 Bruno Haible <address@hidden>
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.
--- lib/time.in.h.orig Sat Apr 3 18:50:43 2010
+++ lib/time.in.h Sat Apr 3 18:50:11 2010
@@ -122,6 +122,11 @@
_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
@@ -137,6 +142,11 @@
_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
--- m4/time_h.m4.orig Sat Apr 3 18:50:43 2010
+++ m4/time_h.m4 Sat Apr 3 18:50:11 2010
@@ -77,6 +77,8 @@
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.
--- m4/time_r.m4.orig Sat Apr 3 18:50:43 2010
+++ m4/time_r.m4 Sat Apr 3 18:50:11 2010
@@ -9,29 +9,40 @@
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
--- modules/time.orig Sat Apr 3 18:50:43 2010
+++ modules/time Sat Apr 3 18:50:11 2010
@@ -32,6 +32,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|@''REPLACE_LOCALTIME_R''@|$(REPLACE_LOCALTIME_R)|g' \
-e 's|@''REPLACE_MKTIME''@|$(REPLACE_MKTIME)|g' \
-e 's|@''REPLACE_NANOSLEEP''@|$(REPLACE_NANOSLEEP)|g' \
- ftello on mingw, (continued)
- ftello on mingw, Bruno Haible, 2010/04/03
- getline on mingw, Bruno Haible, 2010/04/03
- getpagesize on mingw, Bruno Haible, 2010/04/03
- fchdir on mingw, Bruno Haible, 2010/04/03
- nanosleep on mingw, Bruno Haible, 2010/04/03
- Re: nanosleep on mingw, Bruno Haible, 2010/04/04
- Re: nanosleep on mingw, Jim Meyering, 2010/04/04
- Re: nanosleep on mingw, Bruno Haible, 2010/04/04
localtime_r on mingw,
Bruno Haible <=
timegm on mingw, Bruno Haible, 2010/04/03
strptime on mingw, Bruno Haible, 2010/04/03
wcwidth on mingw, Bruno Haible, 2010/04/03
ioctl on mingw, Bruno Haible, 2010/04/04