summaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2019-11-26 13:14:42 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2019-11-26 13:15:41 -0800
commit1b9dbca826ad8a742ab22719279f5ce3c5888a67 (patch)
treeafd37873182a84f6708c19105fedca1b4d58ddd2 /m4
parent50b52390ee5894e91965bd37f2d0c571df1e2e89 (diff)
downloademacs-1b9dbca826ad8a742ab22719279f5ce3c5888a67.tar.gz
Update from Gnulib
This incorporates: 2019-11-24 Fix errors in C++ mode on mingw 2019-11-24 time_r: Fix for mingw (regression from 2019-11-16) 2019-11-24 sys_time: Fix errors in C++ mode on mingw 2019-11-22 intprops: INT_MULTIPLY_WRAPV speedup for GCC 8.4+ 2019-11-21 Disable many _GL_CXXALIASWARN on non-glibc 2019-11-21 Fix various errors in _GL_CXXALIAS_SYS invocations 2019-11-19 intprops: INT_MULTIPLY_WRAPV speedup for GCC 9.3+ 2019-11-18 stdint: Define [u]intptr_t correctly on 64-bit native Windows 2019-11-18 stdint: Fix value of WINT_MAX when we override wint_t 2019-11-18 stdint: Avoid "conflicting types" error on mingw 5.22 2019-11-16 time_r: Fix for mingw 2019-11-06 regex: now back in sync with glibc * lib/intprops.h, lib/regexec.c, lib/signal.in.h: * lib/stdint.in.h, lib/stdio.in.h, lib/stdlib.in.h: * lib/string.in.h, lib/sys_select.in.h, lib/sys_time.in.h: * lib/time.in.h, lib/unistd.in.h, m4/time_r.m4: Copy from Gnulib.
Diffstat (limited to 'm4')
-rw-r--r--m4/time_r.m445
1 files changed, 43 insertions, 2 deletions
diff --git a/m4/time_r.m4 b/m4/time_r.m4
index 5caeca75093..cc4b3e009b9 100644
--- a/m4/time_r.m4
+++ b/m4/time_r.m4
@@ -17,7 +17,15 @@ AC_DEFUN([gl_TIME_R],
dnl Some systems don't declare localtime_r() and gmtime_r() if _REENTRANT is
dnl not defined.
- AC_CHECK_DECLS([localtime_r], [], [], [[#include <time.h>]])
+ AC_CHECK_DECLS([localtime_r], [], [],
+ [[/* 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>
+ ]])
if test $ac_cv_have_decl_localtime_r = no; then
HAVE_DECL_LOCALTIME_R=0
fi
@@ -29,7 +37,14 @@ AC_DEFUN([gl_TIME_R],
[gl_cv_time_r_posix],
[AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
- [[#include <time.h>]],
+ [[/* 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>
+ ]],
[[/* 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. */
@@ -49,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
])