Use an all-permissive copyright notice, recommended by RMS.
[gnulib.git] / m4 / tzset.m4
1 #serial 2
2
3 # Copyright (C) 2003 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 AC_DEFUN([gl_FUNC_TZSET_CLOBBER],
17 [
18   AC_REQUIRE([AC_HEADER_TIME])
19   AC_CACHE_CHECK([whether tzset clobbers localtime buffer],
20                  gl_cv_func_tzset_clobber,
21   [
22   AC_RUN_IFELSE([AC_LANG_SOURCE([[
23 #if TIME_WITH_SYS_TIME
24 # include <sys/time.h>
25 # include <time.h>
26 #else
27 # if HAVE_SYS_TIME_H
28 #  include <sys/time.h>
29 # else
30 #  include <time.h>
31 # endif
32 #endif
33 #include <stdlib.h>
34
35 int
36 main ()
37 {
38   time_t t1 = 853958121;
39   struct tm *p, s;
40   putenv ("TZ=GMT0");
41   p = localtime (&t1);
42   s = *p;
43   putenv ("TZ=EST+3EDT+2,M10.1.0/00:00:00,M2.3.0/00:00:00");
44   tzset ();
45   exit (p->tm_year != s.tm_year
46         || p->tm_mon != s.tm_mon
47         || p->tm_mday != s.tm_mday
48         || p->tm_hour != s.tm_hour
49         || p->tm_min != s.tm_min
50         || p->tm_sec != s.tm_sec);
51 }
52   ]])],
53        [gl_cv_func_tzset_clobber=no],
54        [gl_cv_func_tzset_clobber=yes],
55        [gl_cv_func_tzset_clobber=yes])])
56
57   AC_DEFINE(HAVE_RUN_TZSET_TEST, 1,
58     [Define to 1 if you have run the test for working tzset.])
59
60   if test $gl_cv_func_tzset_clobber = yes; then
61     gl_GETTIMEOFDAY_REPLACE_LOCALTIME
62
63     AC_DEFINE(tzset, rpl_tzset,
64       [Define to rpl_tzset if the wrapper function should be used.])
65     AC_DEFINE(TZSET_CLOBBERS_LOCALTIME_BUFFER, 1,
66       [Define if tzset clobbers localtime's static buffer.])
67   fi
68 ])