3 dnl Copyright (C) 2003, 2006-2024 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
8 dnl Reentrant time functions: localtime_r, gmtime_r.
10 dnl Written by Paul Eggert.
14 dnl Persuade glibc and Solaris <time.h> to declare localtime_r.
15 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
17 AC_REQUIRE([gl_TIME_H_DEFAULTS])
18 AC_REQUIRE([AC_C_RESTRICT])
20 dnl Some systems don't declare localtime_r() and gmtime_r() if _REENTRANT is
22 AC_CHECK_DECLS([localtime_r], [], [],
23 [[/* mingw's <time.h> provides the functions asctime_r, ctime_r,
24 gmtime_r, localtime_r only if <unistd.h> or <pthread.h> has
25 been included before. */
26 #if defined __MINGW32__
31 if test $ac_cv_have_decl_localtime_r = no; then
32 HAVE_DECL_LOCALTIME_R=0
35 AC_CHECK_FUNCS_ONCE([localtime_r])
36 if test $ac_cv_func_localtime_r = yes; then
38 AC_CACHE_CHECK([whether localtime_r is compatible with its POSIX signature],
42 [[/* mingw's <time.h> provides the functions asctime_r, ctime_r,
43 gmtime_r, localtime_r only if <unistd.h> or <pthread.h> has
44 been included before. */
45 #if defined __MINGW32__
50 [[/* We don't need to append 'restrict's to the argument types,
51 even though the POSIX signature has the 'restrict's,
52 since C99 says they can't affect type compatibility. */
53 struct tm * (*ptr) (time_t const *, struct tm *) = localtime_r;
55 /* Check the return type is a pointer.
56 On HP-UX 10 it is 'int'. */
57 *localtime_r (0, 0);]])
59 [gl_cv_time_r_posix=yes],
60 [gl_cv_time_r_posix=no])
62 if test $gl_cv_time_r_posix != yes; then
67 dnl On mingw, localtime_r() is defined as an inline function; use through a
68 dnl direct function call works but the use as a function pointer leads to a
70 AC_CACHE_CHECK([whether localtime_r exists as an inline function],
71 [gl_cv_func_localtime_r_inline],
74 [[/* mingw's <time.h> provides the functions asctime_r, ctime_r,
75 gmtime_r, localtime_r only if <unistd.h> or <pthread.h> has
76 been included before. */
77 #if defined __MINGW32__
87 [gl_cv_func_localtime_r_inline=yes],
88 [gl_cv_func_localtime_r_inline=no])
90 if test $gl_cv_func_localtime_r_inline = yes; then
96 # Prerequisites of lib/time_r.c.
97 AC_DEFUN([gl_PREREQ_TIME_R], [