[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: time_r module does not work on MingW
From: |
Bruno Haible |
Subject: |
Re: time_r module does not work on MingW |
Date: |
Sun, 24 Nov 2019 15:06:02 +0100 |
User-agent: |
KMail/5.1.3 (Linux/4.4.0-166-generic; KDE/5.18.0; x86_64; ; ) |
This patch introduced a regression:
> 2019-11-16 Bruno Haible <address@hidden>
>
> time_r: Fix for mingw.
> Reported by Christian Biesinger <address@hidden> in
> <https://lists.gnu.org/archive/html/bug-gnulib/2019-11/msg00014.html>.
> * lib/time.in.h: On mingw, include <unistd.h>.
> * m4/time_r.m4 (gl_TIME_R): On mingw, include <unistd.h> before
> <time.h>. Test for localtime_r in a way that works when it is defined
> as an inline function.
Namely a link error in mktime:
../gllib/libgnu.a(mktime.o): In function `rpl_mktime':
/home/bruno/testdir3/build-mingw64/gllib/../../gllib/mktime.c:533: undefined
reference to `localtime_r'
2019-11-24 Bruno Haible <address@hidden>
time_r: Fix for mingw (regression from 2019-11-16).
* m4/time_r.m4 (gl_TIME_R): Revert to using AC_CHECK_FUNCS_ONCE. Use the
AC_LINK_IFELSE test only if the function does not appear to exist.
diff --git a/m4/time_r.m4 b/m4/time_r.m4
index 72cc975..cc4b3e0 100644
--- a/m4/time_r.m4
+++ b/m4/time_r.m4
@@ -30,28 +30,8 @@ AC_DEFUN([gl_TIME_R],
HAVE_DECL_LOCALTIME_R=0
fi
- dnl We can't use AC_CHECK_FUNC here, because localtime_r() is defined as an
- dnl inline function on mingw.
- AC_CACHE_CHECK([for localtime_r], [gl_cv_func_localtime_r],
- [AC_LINK_IFELSE(
- [AC_LANG_PROGRAM(
- [[/* mingw's <time.h> provides the functions asctime_r, ctime_r,
- gmtime_r, localtime_r only if <unistd.h> or <pthread.h> has
- been included before. */
- #if defined __MINGW32__
- # include <unistd.h>
- #endif
- #include <time.h>
- ]],
- [[time_t a;
- struct tm r;
- localtime_r (&a, &r);
- ]])
- ],
- [gl_cv_func_localtime_r=yes],
- [gl_cv_func_localtime_r=no])
- ])
- if test $gl_cv_func_localtime_r = yes; then
+ 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],
@@ -84,6 +64,32 @@ AC_DEFUN([gl_TIME_R],
fi
else
HAVE_LOCALTIME_R=0
+ dnl On mingw, localtime_r() is defined as an inline function; use through a
+ dnl direct function call works but the use as a function pointer leads to a
+ dnl link error.
+ AC_CACHE_CHECK([whether localtime_r exists as an inline function],
+ [gl_cv_func_localtime_r_inline],
+ [AC_LINK_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[/* mingw's <time.h> provides the functions asctime_r, ctime_r,
+ gmtime_r, localtime_r only if <unistd.h> or <pthread.h> has
+ been included before. */
+ #if defined __MINGW32__
+ # include <unistd.h>
+ #endif
+ #include <time.h>
+ ]],
+ [[time_t a;
+ struct tm r;
+ localtime_r (&a, &r);
+ ]])
+ ],
+ [gl_cv_func_localtime_r_inline=yes],
+ [gl_cv_func_localtime_r_inline=no])
+ ])
+ if test $gl_cv_func_localtime_r_inline = yes; then
+ REPLACE_LOCALTIME_R=1
+ fi
fi
])
- Re: time_r module does not work on MingW, (continued)
- Re: time_r module does not work on MingW, Bruno Haible, 2019/11/11
- Re: time_r module does not work on MingW, Christian Biesinger, 2019/11/11
- Re: time_r module does not work on MingW, Bruno Haible, 2019/11/11
- Re: time_r module does not work on MingW, Bruno Haible, 2019/11/16
- wctype.h compile error on mingw with GNULIB_NAMESPACE, Christian Biesinger, 2019/11/16
- Re: wctype.h compile error on mingw with GNULIB_NAMESPACE, Bruno Haible, 2019/11/16
- Re: wctype.h compile error on mingw with GNULIB_NAMESPACE, Christian Biesinger, 2019/11/16
- Re: wctype.h compile error on mingw with GNULIB_NAMESPACE, Bruno Haible, 2019/11/24
- Re: wctype.h compile error on mingw with GNULIB_NAMESPACE, Christian Biesinger, 2019/11/25
- Re: wctype.h compile error on mingw with GNULIB_NAMESPACE, Bruno Haible, 2019/11/25
- Re: time_r module does not work on MingW,
Bruno Haible <=