1# serial 13 2 3# Copyright (C) 2003, 2007, 2009-2020 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. 7 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 12# used by localtime. 13 14# Written by Paul Eggert and Jim Meyering. 15 16AC_DEFUN([gl_FUNC_TZSET], 17[ 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 23 HAVE_TZSET=0 24 fi 25 gl_FUNC_TZSET_CLOBBER 26 REPLACE_TZSET=0 27 case "$gl_cv_func_tzset_clobber" in 28 *yes) 29 REPLACE_TZSET=1 30 AC_DEFINE([TZSET_CLOBBERS_LOCALTIME], [1], 31 [Define if tzset clobbers localtime's static buffer.]) 32 gl_LOCALTIME_BUFFER_NEEDED 33 ;; 34 esac 35 case "$host_os" in 36 mingw*) REPLACE_TZSET=1 ;; 37 esac 38]) 39 40# Set gl_cv_func_tzset_clobber. 41AC_DEFUN([gl_FUNC_TZSET_CLOBBER], 42[ 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([[ 47#include <time.h> 48#include <stdlib.h> 49 50int 51main () 52{ 53 time_t t1 = 853958121; 54 struct tm *p, s; 55 putenv ("TZ=GMT0"); 56 p = localtime (&t1); 57 s = *p; 58 putenv ("TZ=EST+3EDT+2,M10.1.0/00:00:00,M2.3.0/00:00:00"); 59 tzset (); 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); 66} 67 ]])], 68 [gl_cv_func_tzset_clobber=no], 69 [gl_cv_func_tzset_clobber=yes], 70 [case "$host_os" in 71 # Guess all is fine on glibc systems. 72 *-gnu* | gnu*) gl_cv_func_tzset_clobber="guessing no" ;; 73 # Guess all is fine on musl systems. 74 *-musl*) gl_cv_func_tzset_clobber="guessing no" ;; 75 # Guess no on native Windows. 76 mingw*) gl_cv_func_tzset_clobber="guessing no" ;; 77 # If we don't know, obey --enable-cross-guesses. 78 *) gl_cv_func_tzset_clobber="$gl_cross_guess_inverted" ;; 79 esac 80 ]) 81 ]) 82 83 AC_DEFINE([HAVE_RUN_TZSET_TEST], [1], 84 [Define to 1 if you have run the test for working tzset.]) 85]) 86