3 # Copyright (C) 2003, 2007, 2009-2018 Free Software Foundation, Inc.
4 # This file is free software; the Free Software Foundation
5 # gives unlimited permission to copy and/or distribute it,
6 # with or without modifications, as long as this notice is preserved.
8 # See if we have a working tzset function.
9 # If so, arrange to compile the wrapper function.
10 # For at least Solaris 2.5.1 and 2.6, this is necessary
11 # because tzset can clobber the contents of the buffer
14 # Written by Paul Eggert and Jim Meyering.
16 AC_DEFUN([gl_FUNC_TZSET],
18 AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS])
19 AC_REQUIRE([gl_LOCALTIME_BUFFER_DEFAULTS])
20 AC_REQUIRE([AC_CANONICAL_HOST])
21 AC_CHECK_FUNCS_ONCE([tzset])
22 if test $ac_cv_func_tzset = no; then
27 case "$gl_cv_func_tzset_clobber" in
30 AC_DEFINE([TZSET_CLOBBERS_LOCALTIME], [1],
31 [Define if tzset clobbers localtime's static buffer.])
32 gl_LOCALTIME_BUFFER_NEEDED
36 mingw*) REPLACE_TZSET=1 ;;
40 # Set gl_cv_func_tzset_clobber.
41 AC_DEFUN([gl_FUNC_TZSET_CLOBBER],
43 AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
44 AC_CACHE_CHECK([whether tzset clobbers localtime buffer],
45 [gl_cv_func_tzset_clobber],
46 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
53 time_t t1 = 853958121;
58 putenv ("TZ=EST+3EDT+2,M10.1.0/00:00:00,M2.3.0/00:00:00");
60 return (p->tm_year != s.tm_year
61 || p->tm_mon != s.tm_mon
62 || p->tm_mday != s.tm_mday
63 || p->tm_hour != s.tm_hour
64 || p->tm_min != s.tm_min
65 || p->tm_sec != s.tm_sec);
68 [gl_cv_func_tzset_clobber=no],
69 [gl_cv_func_tzset_clobber=yes],
71 # Guess all is fine on glibc systems.
72 *-gnu* | gnu*) gl_cv_func_tzset_clobber="guessing no" ;;
73 # Guess no on native Windows.
74 mingw*) gl_cv_func_tzset_clobber="guessing no" ;;
75 # If we don't know, assume the worst.
76 *) gl_cv_func_tzset_clobber="guessing yes" ;;
81 AC_DEFINE([HAVE_RUN_TZSET_TEST], [1],
82 [Define to 1 if you have run the test for working tzset.])