aboutsummaryrefslogtreecommitdiffstats
path: root/aclocal.m4
diff options
context:
space:
mode:
authorDave Love2000-04-14 11:22:13 +0000
committerDave Love2000-04-14 11:22:13 +0000
commit4487f86d427a42ee0302dec0bf7bee4e283d5859 (patch)
tree03827141a7b58073021abef246b2ed94f937351f /aclocal.m4
parent38c44a9161ee5e5d149743bc5fb6458f65184de0 (diff)
downloademacs-4487f86d427a42ee0302dec0bf7bee4e283d5859.tar.gz
emacs-4487f86d427a42ee0302dec0bf7bee4e283d5859.zip
(AC_FUNC_MKTIME): New.
Diffstat (limited to 'aclocal.m4')
-rw-r--r--aclocal.m4163
1 files changed, 162 insertions, 1 deletions
diff --git a/aclocal.m4 b/aclocal.m4
index 8dfc4b98a0d..3780894bd5e 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -1,5 +1,5 @@
1dnl The following are from prerelease autoconf 2.14a. When 2.14 is 1dnl The following are from prerelease autoconf 2.14a. When 2.14 is
2dnl released, we should be able to zap them and AC_PREREQ(2.14). 2dnl released, we should be able to zap them and just use AC_PREREQ(2.14).
3 3
4 4
5# AC_PROG_CC_STDC 5# AC_PROG_CC_STDC
@@ -76,6 +76,167 @@ case "x$ac_cv_prog_cc_stdc" in
76esac 76esac
77])# AC_PROG_CC_STDC 77])# AC_PROG_CC_STDC
78 78
79# AC_FUNC_MKTIME
80# --------------
81AC_DEFUN(AC_FUNC_MKTIME,
82[AC_REQUIRE([AC_HEADER_TIME])dnl
83AC_CHECK_HEADERS(sys/time.h unistd.h)
84AC_CHECK_FUNCS(alarm)
85AC_CACHE_CHECK([for working mktime], ac_cv_func_working_mktime,
86[AC_TRY_RUN(
87[/* Test program from Paul Eggert (eggert@twinsun.com)
88 and Tony Leneis (tony@plaza.ds.adp.com). */
89#if TIME_WITH_SYS_TIME
90# include <sys/time.h>
91# include <time.h>
92#else
93# if HAVE_SYS_TIME_H
94# include <sys/time.h>
95# else
96# include <time.h>
97# endif
98#endif
99
100#if HAVE_UNISTD_H
101# include <unistd.h>
102#endif
103
104#if !HAVE_ALARM
105# define alarm(X) /* empty */
106#endif
107
108/* Work around redefinition to rpl_putenv by other config tests. */
109#undef putenv
110
111static time_t time_t_max;
112
113/* Values we'll use to set the TZ environment variable. */
114static const char *const tz_strings[] = {
115 (const char *) 0, "TZ=GMT0", "TZ=JST-9",
116 "TZ=EST+3EDT+2,M10.1.0/00:00:00,M2.3.0/00:00:00"
117};
118#define N_STRINGS (sizeof (tz_strings) / sizeof (tz_strings[0]))
119
120/* Fail if mktime fails to convert a date in the spring-forward gap.
121 Based on a problem report from Andreas Jaeger. */
122static void
123spring_forward_gap ()
124{
125 /* glibc (up to about 1998-10-07) failed this test) */
126 struct tm tm;
127
128 /* Use the portable POSIX.1 specification "TZ=PST8PDT,M4.1.0,M10.5.0"
129 instead of "TZ=America/Vancouver" in order to detect the bug even
130 on systems that don't support the Olson extension, or don't have the
131 full zoneinfo tables installed. */
132 putenv ("TZ=PST8PDT,M4.1.0,M10.5.0");
133
134 tm.tm_year = 98;
135 tm.tm_mon = 3;
136 tm.tm_mday = 5;
137 tm.tm_hour = 2;
138 tm.tm_min = 0;
139 tm.tm_sec = 0;
140 tm.tm_isdst = -1;
141 if (mktime (&tm) == (time_t)-1)
142 exit (1);
143}
144
145static void
146mktime_test (now)
147 time_t now;
148{
149 struct tm *lt;
150 if ((lt = localtime (&now)) && mktime (lt) != now)
151 exit (1);
152 now = time_t_max - now;
153 if ((lt = localtime (&now)) && mktime (lt) != now)
154 exit (1);
155}
156
157static void
158irix_6_4_bug ()
159{
160 /* Based on code from Ariel Faigon. */
161 struct tm tm;
162 tm.tm_year = 96;
163 tm.tm_mon = 3;
164 tm.tm_mday = 0;
165 tm.tm_hour = 0;
166 tm.tm_min = 0;
167 tm.tm_sec = 0;
168 tm.tm_isdst = -1;
169 mktime (&tm);
170 if (tm.tm_mon != 2 || tm.tm_mday != 31)
171 exit (1);
172}
173
174static void
175bigtime_test (j)
176 int j;
177{
178 struct tm tm;
179 time_t now;
180 tm.tm_year = tm.tm_mon = tm.tm_mday = tm.tm_hour = tm.tm_min = tm.tm_sec = j;
181 now = mktime (&tm);
182 if (now != (time_t) -1)
183 {
184 struct tm *lt = localtime (&now);
185 if (! (lt
186 && lt->tm_year == tm.tm_year
187 && lt->tm_mon == tm.tm_mon
188 && lt->tm_mday == tm.tm_mday
189 && lt->tm_hour == tm.tm_hour
190 && lt->tm_min == tm.tm_min
191 && lt->tm_sec == tm.tm_sec
192 && lt->tm_yday == tm.tm_yday
193 && lt->tm_wday == tm.tm_wday
194 && ((lt->tm_isdst < 0 ? -1 : 0 < lt->tm_isdst)
195 == (tm.tm_isdst < 0 ? -1 : 0 < tm.tm_isdst))))
196 exit (1);
197 }
198}
199
200int
201main ()
202{
203 time_t t, delta;
204 int i, j;
205
206 /* This test makes some buggy mktime implementations loop.
207 Give up after 60 seconds; a mktime slower than that
208 isn't worth using anyway. */
209 alarm (60);
210
211 for (time_t_max = 1; 0 < time_t_max; time_t_max *= 2)
212 continue;
213 time_t_max--;
214 delta = time_t_max / 997; /* a suitable prime number */
215 for (i = 0; i < N_STRINGS; i++)
216 {
217 if (tz_strings[i])
218 putenv (tz_strings[i]);
219
220 for (t = 0; t <= time_t_max - delta; t += delta)
221 mktime_test (t);
222 mktime_test ((time_t) 60 * 60);
223 mktime_test ((time_t) 60 * 60 * 24);
224
225 for (j = 1; 0 < j; j *= 2)
226 bigtime_test (j);
227 bigtime_test (j - 1);
228 }
229 irix_6_4_bug ();
230 spring_forward_gap ();
231 exit (0);
232}],
233ac_cv_func_working_mktime=yes, ac_cv_func_working_mktime=no,
234ac_cv_func_working_mktime=no)])
235if test $ac_cv_func_working_mktime = no; then
236 LIBOBJS="$LIBOBJS mktime.${ac_objext}"
237fi
238])# AC_FUNC_MKTIME
239
79# AC_C_VOLATILE 240# AC_C_VOLATILE
80# ------------- 241# -------------
81# Note that, unlike const, #defining volatile to be the empty string can 242# Note that, unlike const, #defining volatile to be the empty string can