5 dnl See if gettimeofday clobbers the static buffer that localtime uses
6 dnl for it's return value. The gettimeofday function from Mac OS X 10.0.4,
7 dnl i.e. Darwin 1.3.7 has this problem.
9 dnl If it does, then arrange to use gettimeofday and localtime only via
10 dnl the wrapper functions that work around the problem.
12 AC_DEFUN([AC_FUNC_GETTIMEOFDAY_CLOBBER],
14 AC_REQUIRE([AC_HEADER_TIME])
15 AC_CHECK_HEADERS_ONCE(stdlib.h string.h)
16 AC_CACHE_CHECK([whether gettimeofday clobbers localtime buffer],
17 jm_cv_func_gettimeofday_clobber,
24 #if TIME_WITH_SYS_TIME
25 # include <sys/time.h>
29 # include <sys/time.h>
48 gettimeofday (&tv, NULL);
49 if (memcmp (lt, &saved_lt, sizeof (struct tm)) != 0)
55 jm_cv_func_gettimeofday_clobber=no,
56 jm_cv_func_gettimeofday_clobber=yes,
57 dnl When crosscompiling, assume it is broken.
58 jm_cv_func_gettimeofday_clobber=yes)
60 if test $jm_cv_func_gettimeofday_clobber = yes; then
61 gl_GETTIMEOFDAY_REPLACE_LOCALTIME
63 AC_DEFINE(gettimeofday, rpl_gettimeofday,
64 [Define to rpl_gettimeofday if the replacement function should be used.])
65 AC_DEFINE(GETTIMEOFDAY_CLOBBERS_LOCALTIME_BUFFER, 1,
66 [Define if gettimeofday clobbers localtime's static buffer.])
67 gl_PREREQ_GETTIMEOFDAY
71 AC_DEFUN([gl_GETTIMEOFDAY_REPLACE_LOCALTIME], [
72 AC_LIBOBJ(gettimeofday)
73 AC_DEFINE(gmtime, rpl_gmtime,
74 [Define to rpl_gmtime if the replacement function should be used.])
75 AC_DEFINE(localtime, rpl_localtime,
76 [Define to rpl_localtime if the replacement function should be used.])
79 # Prerequisites of lib/gettimeofday.c.
80 AC_DEFUN([gl_PREREQ_GETTIMEOFDAY], [
81 AC_REQUIRE([AC_HEADER_TIME])