AC_DEFUN([AC_FUNC_GETTIMEOFDAY_CLOBBER],
[
AC_REQUIRE([AC_HEADER_TIME])
AC_CACHE_CHECK([whether gettimeofday clobbers localtime buffer],
jm_cv_func_gettimeofday_clobber,
[AC_TRY_RUN([
int
main ()
{
time_t t = 0;
struct tm *lt;
struct tm saved_lt;
struct timeval tv;
lt = localtime (&t);
saved_lt = *lt;
gettimeofday (&tv, NULL);
if (memcmp (lt, &saved_lt, sizeof (struct tm)) != 0)
exit (1);
exit (0);
}
],
jm_cv_func_gettimeofday_clobber=no,
jm_cv_func_gettimeofday_clobber=yes,
jm_cv_func_gettimeofday_clobber=yes)
])
if test $jm_cv_func_gettimeofday_clobber = yes; then
gl_GETTIMEOFDAY_REPLACE_LOCALTIME
AC_DEFINE(gettimeofday, rpl_gettimeofday,
[Define to rpl_gettimeofday if the replacement function should be used.])
AC_DEFINE(GETTIMEOFDAY_CLOBBERS_LOCALTIME_BUFFER, 1,
[Define if gettimeofday clobbers localtime's static buffer.])
gl_PREREQ_GETTIMEOFDAY
fi
])
AC_DEFUN([gl_GETTIMEOFDAY_REPLACE_LOCALTIME], [
AC_LIBOBJ(gettimeofday)
AC_DEFINE(gmtime, rpl_gmtime,
[Define to rpl_gmtime if the replacement function should be used.])
AC_DEFINE(localtime, rpl_localtime,
[Define to rpl_localtime if the replacement function should be used.])
])
AC_DEFUN([gl_PREREQ_GETTIMEOFDAY], [
AC_REQUIRE([AC_HEADER_TIME])
])