Blame m4/time_rz.m4

Packit Service a2489d
dnl Time zone functions: tzalloc, localtime_rz, etc.
Packit Service a2489d
Packit Service a2489d
dnl Copyright (C) 2015-2018 Free Software Foundation, Inc.
Packit Service a2489d
dnl This file is free software; the Free Software Foundation
Packit Service a2489d
dnl gives unlimited permission to copy and/or distribute it,
Packit Service a2489d
dnl with or without modifications, as long as this notice is preserved.
Packit Service a2489d
Packit Service a2489d
dnl Written by Paul Eggert.
Packit Service a2489d
Packit Service a2489d
AC_DEFUN([gl_TIME_RZ],
Packit Service a2489d
[
Packit Service a2489d
  AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
Packit Service a2489d
  AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS])
Packit Service a2489d
  AC_REQUIRE([AC_STRUCT_TIMEZONE])
Packit Service a2489d
Packit Service a2489d
  # Mac OS X 10.6 loops forever with some time_t values.
Packit Service a2489d
  # See Bug#27706, Bug#27736, and
Packit Service a2489d
  # https://lists.gnu.org/r/bug-gnulib/2017-07/msg00142.html
Packit Service a2489d
  AC_CACHE_CHECK([whether localtime loops forever near extrema],
Packit Service a2489d
    [gl_cv_func_localtime_infloop_bug],
Packit Service a2489d
    [gl_cv_func_localtime_infloop_bug=no
Packit Service a2489d
     AC_RUN_IFELSE(
Packit Service a2489d
       [AC_LANG_PROGRAM(
Packit Service a2489d
          [[#include <stdlib.h>
Packit Service a2489d
            #include <string.h>
Packit Service a2489d
            #include <unistd.h>
Packit Service a2489d
            #include <time.h>
Packit Service a2489d
          ]], [[
Packit Service a2489d
            time_t t = -67768038400666600;
Packit Service a2489d
            struct tm *tm;
Packit Service a2489d
            char *tz = getenv ("TZ");
Packit Service a2489d
            if (! (tz && strcmp (tz, "QQQ0") == 0))
Packit Service a2489d
              return 0;
Packit Service a2489d
            alarm (2);
Packit Service a2489d
            tm = localtime (&t);
Packit Service a2489d
            /* Use TM and *TM to suppress over-optimization.  */
Packit Service a2489d
            return tm && tm->tm_isdst;
Packit Service a2489d
          ]])],
Packit Service a2489d
       [(TZ=QQQ0 ./conftest$EXEEXT) >/dev/null 2>&1 ||
Packit Service a2489d
           gl_cv_func_localtime_infloop_bug=yes],
Packit Service a2489d
       [],
Packit Service a2489d
       [gl_cv_func_localtime_infloop_bug="guessing no"])])
Packit Service a2489d
  if test "$gl_cv_func_localtime_infloop_bug" = yes; then
Packit Service a2489d
      AC_DEFINE([HAVE_LOCALTIME_INFLOOP_BUG], 1,
Packit Service a2489d
        [Define if localtime-like functions can loop forever on
Packit Service a2489d
         extreme arguments.])
Packit Service a2489d
  fi
Packit Service a2489d
Packit Service a2489d
  AC_CHECK_TYPES([timezone_t], [], [], [[#include <time.h>]])
Packit Service a2489d
  if test "$ac_cv_type_timezone_t" = yes; then
Packit Service a2489d
    HAVE_TIMEZONE_T=1
Packit Service a2489d
  fi
Packit Service a2489d
])