mkfifoat: Work around trailing slash bug in mknodat() on AIX 7.2.
[gnulib.git] / m4 / time_rz.m4
blob34ef0bab4b943c4fcb58cabac6cb4e874892847b
1 dnl Time zone functions: tzalloc, localtime_rz, etc.
3 dnl Copyright (C) 2015-2021 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.
8 dnl Written by Paul Eggert.
10 AC_DEFUN([gl_TIME_RZ],
12   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
13   AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS])
14   AC_REQUIRE([AC_STRUCT_TIMEZONE])
16   # On Mac OS X 10.6, localtime loops forever with some time_t values.
17   # See Bug#27706, Bug#27736, and
18   # https://lists.gnu.org/r/bug-gnulib/2017-07/msg00142.html
19   AC_CACHE_CHECK([whether localtime works even near extrema],
20     [gl_cv_func_localtime_works],
21     [gl_cv_func_localtime_works=yes
22      AC_RUN_IFELSE(
23        [AC_LANG_PROGRAM(
24           [[#include <stdlib.h>
25             #include <string.h>
26             #include <unistd.h>
27             #include <time.h>
28           ]], [[
29             time_t t = -67768038400666600;
30             struct tm *tm;
31             char *tz = getenv ("TZ");
32             if (! (tz && strcmp (tz, "QQQ0") == 0))
33               return 0;
34             alarm (2);
35             tm = localtime (&t);
36             /* Use TM and *TM to suppress over-optimization.  */
37             return tm && tm->tm_isdst;
38           ]])],
39        [(TZ=QQQ0 ./conftest$EXEEXT) >/dev/null 2>&1 ||
40            gl_cv_func_localtime_works=no],
41        [],
42        [gl_cv_func_localtime_works="guessing yes"])])
43   if test "$gl_cv_func_localtime_works" = no; then
44       AC_DEFINE([HAVE_LOCALTIME_INFLOOP_BUG], 1,
45         [Define if localtime-like functions can loop forever on
46          extreme arguments.])
47   fi
49   AC_CHECK_TYPES([timezone_t], [], [], [[#include <time.h>]])
50   if test "$ac_cv_type_timezone_t" = yes; then
51     HAVE_TIMEZONE_T=1
52   fi