maint: update copyright
[gnulib.git] / m4 / tzset.m4
1 # serial 7
2
3 # Copyright (C) 2003, 2007, 2009-2014 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
16 # A placeholder to ensure that this m4 file gets included by aclocal.
17 AC_DEFUN([gl_FUNC_TZSET], [])
18
19 # Set gl_cv_func_tzset_clobber.
20 AC_DEFUN([gl_FUNC_TZSET_CLOBBER],
21 [
22   AC_REQUIRE([gl_HEADER_SYS_TIME_H])
23   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
24   AC_CACHE_CHECK([whether tzset clobbers localtime buffer],
25                  gl_cv_func_tzset_clobber,
26   [
27   AC_RUN_IFELSE([AC_LANG_SOURCE([[
28 #include <time.h>
29 #include <stdlib.h>
30
31 int
32 main ()
33 {
34   time_t t1 = 853958121;
35   struct tm *p, s;
36   putenv ("TZ=GMT0");
37   p = localtime (&t1);
38   s = *p;
39   putenv ("TZ=EST+3EDT+2,M10.1.0/00:00:00,M2.3.0/00:00:00");
40   tzset ();
41   return (p->tm_year != s.tm_year
42           || p->tm_mon != s.tm_mon
43           || p->tm_mday != s.tm_mday
44           || p->tm_hour != s.tm_hour
45           || p->tm_min != s.tm_min
46           || p->tm_sec != s.tm_sec);
47 }
48   ]])],
49        [gl_cv_func_tzset_clobber=no],
50        [gl_cv_func_tzset_clobber=yes],
51        [case "$host_os" in
52                   # Guess all is fine on glibc systems.
53           *-gnu*) gl_cv_func_tzset_clobber="guessing no" ;;
54                   # If we don't know, assume the worst.
55           *)      gl_cv_func_tzset_clobber="guessing yes" ;;
56         esac
57        ])])
58
59   AC_DEFINE([HAVE_RUN_TZSET_TEST], [1],
60     [Define to 1 if you have run the test for working tzset.])
61 ])