Debian Codegraph @

m4/time_rz.m4

raw
1 # time_rz.m4
2 # serial 3
3 dnl Copyright (C) 2015-2025 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
7 dnl This file is offered as-is, without any warranty.
8
9 dnl Time zone functions: tzalloc, localtime_rz, etc.
10
11 dnl Written by Paul Eggert.
12
13 AC_DEFUN([gl_TIME_RZ],
14 [
15 AC_REQUIRE([gl_TIME_H_DEFAULTS])
16 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
17 AC_REQUIRE([AC_CANONICAL_HOST])
18
19 # On Mac OS X 10.6, localtime loops forever with some time_t values.
20 # See Bug#27706, Bug#27736, and
21 # https://lists.gnu.org/r/bug-gnulib/2017-07/msg00142.html
22 AC_CACHE_CHECK([whether localtime works even near extrema],
23 [gl_cv_func_localtime_works],
24 [gl_cv_func_localtime_works=yes
25 AC_RUN_IFELSE(
26 [AC_LANG_PROGRAM(
27 [[#include <stdlib.h>
28 #include <string.h>
29 #include <unistd.h>
30 #include <time.h>
31 ]], [[
32 time_t t = -67768038400666600;
33 struct tm *tm;
34 char *tz = getenv ("TZ");
35 if (! (tz && strcmp (tz, "QQQ0") == 0))
36 return 0;
37 alarm (2);
38 tm = localtime (&t);
39 /* Use TM and *TM to suppress over-optimization. */
40 return tm && tm->tm_isdst;
41 ]])],
42 [(TZ=QQQ0 ./conftest$EXEEXT) >/dev/null 2>&1 ||
43 gl_cv_func_localtime_works=no],
44 [],
45 [gl_cv_func_localtime_works="guessing yes"])])
46 if test "$gl_cv_func_localtime_works" = no; then
47 AC_DEFINE([HAVE_LOCALTIME_INFLOOP_BUG], 1,
48 [Define if localtime-like functions can loop forever on
49 extreme arguments.])
50 fi
51
52 AC_CHECK_TYPES([timezone_t], [], [], [[#include <time.h>]])
53 if test "$ac_cv_type_timezone_t" = yes; then
54 HAVE_TIMEZONE_T=1
55 fi
56
57 gl_CHECK_FUNCS_ANDROID([tzalloc], [[#include <time.h>]])
58 if test $ac_cv_func_tzalloc = yes; then
59 HAVE_TZALLOC=1
60 fi
61 dnl Assume that tzalloc, localtime_rz, mktime_z are all defined together.
62 case "$gl_cv_onwards_func_tzalloc" in
63 yes)
64 case "$host_os" in
65 *-android*)
66 dnl The Android libc functions localtime_rz, mktime_z don't support
67 dnl a NULL timezone_t argument.
68 AC_DEFINE([NEED_TIMEZONE_NULL_SUPPORT], [1],
69 [Define to 1 if localtime_rz, mktime_z exist and can be used with
70 non-NULL timezone_t values.])
71 REPLACE_LOCALTIME_RZ=1
72 REPLACE_MKTIME_Z=1
73 ;;
74 esac
75 ;;
76 future*)
77 REPLACE_LOCALTIME_RZ=1
78 REPLACE_MKTIME_Z=1
79 ;;
80 esac
81 ])