gettimeofday, tzset: Respect rules for use of AC_LIBOBJ.
[gnulib.git] / m4 / tzset.m4
1 # serial 6
2
3 # Copyright (C) 2003, 2007, 2009-2011 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_CACHE_CHECK([whether tzset clobbers localtime buffer],
24                  gl_cv_func_tzset_clobber,
25   [
26   AC_RUN_IFELSE([AC_LANG_SOURCE([[
27 #include <time.h>
28 #include <stdlib.h>
29
30 int
31 main ()
32 {
33   time_t t1 = 853958121;
34   struct tm *p, s;
35   putenv ("TZ=GMT0");
36   p = localtime (&t1);
37   s = *p;
38   putenv ("TZ=EST+3EDT+2,M10.1.0/00:00:00,M2.3.0/00:00:00");
39   tzset ();
40   return (p->tm_year != s.tm_year
41           || p->tm_mon != s.tm_mon
42           || p->tm_mday != s.tm_mday
43           || p->tm_hour != s.tm_hour
44           || p->tm_min != s.tm_min
45           || p->tm_sec != s.tm_sec);
46 }
47   ]])],
48        [gl_cv_func_tzset_clobber=no],
49        [gl_cv_func_tzset_clobber=yes],
50        [gl_cv_func_tzset_clobber=yes])])
51
52   AC_DEFINE([HAVE_RUN_TZSET_TEST], [1],
53     [Define to 1 if you have run the test for working tzset.])
54 ])