|
Packit Service |
4684c1 |
dnl Reentrant time functions: localtime_r, gmtime_r.
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
dnl Copyright (C) 2003, 2006-2020 Free Software Foundation, Inc.
|
|
Packit Service |
4684c1 |
dnl This file is free software; the Free Software Foundation
|
|
Packit Service |
4684c1 |
dnl gives unlimited permission to copy and/or distribute it,
|
|
Packit Service |
4684c1 |
dnl with or without modifications, as long as this notice is preserved.
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
dnl Written by Paul Eggert.
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
AC_DEFUN([gl_TIME_R],
|
|
Packit Service |
4684c1 |
[
|
|
Packit Service |
4684c1 |
dnl Persuade glibc and Solaris <time.h> to declare localtime_r.
|
|
Packit Service |
4684c1 |
AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS])
|
|
Packit Service |
4684c1 |
AC_REQUIRE([AC_C_RESTRICT])
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
dnl Some systems don't declare localtime_r() and gmtime_r() if _REENTRANT is
|
|
Packit Service |
4684c1 |
dnl not defined.
|
|
Packit Service |
4684c1 |
AC_CHECK_DECLS([localtime_r], [], [],
|
|
Packit Service |
4684c1 |
[[/* mingw's <time.h> provides the functions asctime_r, ctime_r,
|
|
Packit Service |
4684c1 |
gmtime_r, localtime_r only if <unistd.h> or <pthread.h> has
|
|
Packit Service |
4684c1 |
been included before. */
|
|
Packit Service |
4684c1 |
#if defined __MINGW32__
|
|
Packit Service |
4684c1 |
# include <unistd.h>
|
|
Packit Service |
4684c1 |
#endif
|
|
Packit Service |
4684c1 |
#include <time.h>
|
|
Packit Service |
4684c1 |
]])
|
|
Packit Service |
4684c1 |
if test $ac_cv_have_decl_localtime_r = no; then
|
|
Packit Service |
4684c1 |
HAVE_DECL_LOCALTIME_R=0
|
|
Packit Service |
4684c1 |
fi
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
AC_CHECK_FUNCS_ONCE([localtime_r])
|
|
Packit Service |
4684c1 |
if test $ac_cv_func_localtime_r = yes; then
|
|
Packit Service |
4684c1 |
HAVE_LOCALTIME_R=1
|
|
Packit Service |
4684c1 |
AC_CACHE_CHECK([whether localtime_r is compatible with its POSIX signature],
|
|
Packit Service |
4684c1 |
[gl_cv_time_r_posix],
|
|
Packit Service |
4684c1 |
[AC_COMPILE_IFELSE(
|
|
Packit Service |
4684c1 |
[AC_LANG_PROGRAM(
|
|
Packit Service |
4684c1 |
[[/* mingw's <time.h> provides the functions asctime_r, ctime_r,
|
|
Packit Service |
4684c1 |
gmtime_r, localtime_r only if <unistd.h> or <pthread.h> has
|
|
Packit Service |
4684c1 |
been included before. */
|
|
Packit Service |
4684c1 |
#if defined __MINGW32__
|
|
Packit Service |
4684c1 |
# include <unistd.h>
|
|
Packit Service |
4684c1 |
#endif
|
|
Packit Service |
4684c1 |
#include <time.h>
|
|
Packit Service |
4684c1 |
]],
|
|
Packit Service |
4684c1 |
[[/* We don't need to append 'restrict's to the argument types,
|
|
Packit Service |
4684c1 |
even though the POSIX signature has the 'restrict's,
|
|
Packit Service |
4684c1 |
since C99 says they can't affect type compatibility. */
|
|
Packit Service |
4684c1 |
struct tm * (*ptr) (time_t const *, struct tm *) = localtime_r;
|
|
Packit Service |
4684c1 |
if (ptr) return 0;
|
|
Packit Service |
4684c1 |
/* Check the return type is a pointer.
|
|
Packit Service |
4684c1 |
On HP-UX 10 it is 'int'. */
|
|
Packit Service |
4684c1 |
*localtime_r (0, 0);]])
|
|
Packit Service |
4684c1 |
],
|
|
Packit Service |
4684c1 |
[gl_cv_time_r_posix=yes],
|
|
Packit Service |
4684c1 |
[gl_cv_time_r_posix=no])
|
|
Packit Service |
4684c1 |
])
|
|
Packit Service |
4684c1 |
if test $gl_cv_time_r_posix = yes; then
|
|
Packit Service |
4684c1 |
REPLACE_LOCALTIME_R=0
|
|
Packit Service |
4684c1 |
else
|
|
Packit Service |
4684c1 |
REPLACE_LOCALTIME_R=1
|
|
Packit Service |
4684c1 |
fi
|
|
Packit Service |
4684c1 |
else
|
|
Packit Service |
4684c1 |
HAVE_LOCALTIME_R=0
|
|
Packit Service |
4684c1 |
dnl On mingw, localtime_r() is defined as an inline function; use through a
|
|
Packit Service |
4684c1 |
dnl direct function call works but the use as a function pointer leads to a
|
|
Packit Service |
4684c1 |
dnl link error.
|
|
Packit Service |
4684c1 |
AC_CACHE_CHECK([whether localtime_r exists as an inline function],
|
|
Packit Service |
4684c1 |
[gl_cv_func_localtime_r_inline],
|
|
Packit Service |
4684c1 |
[AC_LINK_IFELSE(
|
|
Packit Service |
4684c1 |
[AC_LANG_PROGRAM(
|
|
Packit Service |
4684c1 |
[[/* mingw's <time.h> provides the functions asctime_r, ctime_r,
|
|
Packit Service |
4684c1 |
gmtime_r, localtime_r only if <unistd.h> or <pthread.h> has
|
|
Packit Service |
4684c1 |
been included before. */
|
|
Packit Service |
4684c1 |
#if defined __MINGW32__
|
|
Packit Service |
4684c1 |
# include <unistd.h>
|
|
Packit Service |
4684c1 |
#endif
|
|
Packit Service |
4684c1 |
#include <time.h>
|
|
Packit Service |
4684c1 |
]],
|
|
Packit Service |
4684c1 |
[[time_t a;
|
|
Packit Service |
4684c1 |
struct tm r;
|
|
Packit Service |
4684c1 |
localtime_r (&a, &r);
|
|
Packit Service |
4684c1 |
]])
|
|
Packit Service |
4684c1 |
],
|
|
Packit Service |
4684c1 |
[gl_cv_func_localtime_r_inline=yes],
|
|
Packit Service |
4684c1 |
[gl_cv_func_localtime_r_inline=no])
|
|
Packit Service |
4684c1 |
])
|
|
Packit Service |
4684c1 |
if test $gl_cv_func_localtime_r_inline = yes; then
|
|
Packit Service |
4684c1 |
REPLACE_LOCALTIME_R=1
|
|
Packit Service |
4684c1 |
fi
|
|
Packit Service |
4684c1 |
fi
|
|
Packit Service |
4684c1 |
])
|
|
Packit Service |
4684c1 |
|
|
Packit Service |
4684c1 |
# Prerequisites of lib/time_r.c.
|
|
Packit Service |
4684c1 |
AC_DEFUN([gl_PREREQ_TIME_R], [
|
|
Packit Service |
4684c1 |
:
|
|
Packit Service |
4684c1 |
])
|