Blame m4/time_r.m4

Packit 8f70b4
dnl Reentrant time functions: localtime_r, gmtime_r.
Packit 8f70b4
Packit 8f70b4
dnl Copyright (C) 2003, 2006-2018 Free Software Foundation, Inc.
Packit 8f70b4
dnl This file is free software; the Free Software Foundation
Packit 8f70b4
dnl gives unlimited permission to copy and/or distribute it,
Packit 8f70b4
dnl with or without modifications, as long as this notice is preserved.
Packit 8f70b4
Packit 8f70b4
dnl Written by Paul Eggert.
Packit 8f70b4
Packit 8f70b4
AC_DEFUN([gl_TIME_R],
Packit 8f70b4
[
Packit 8f70b4
  dnl Persuade glibc and Solaris <time.h> to declare localtime_r.
Packit 8f70b4
  AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
Packit 8f70b4
Packit 8f70b4
  AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS])
Packit 8f70b4
  AC_REQUIRE([AC_C_RESTRICT])
Packit 8f70b4
Packit 8f70b4
  dnl Some systems don't declare localtime_r() and gmtime_r() if _REENTRANT is
Packit 8f70b4
  dnl not defined.
Packit 8f70b4
  AC_CHECK_DECLS([localtime_r], [], [], [[#include <time.h>]])
Packit 8f70b4
  if test $ac_cv_have_decl_localtime_r = no; then
Packit 8f70b4
    HAVE_DECL_LOCALTIME_R=0
Packit 8f70b4
  fi
Packit 8f70b4
Packit 8f70b4
  AC_CHECK_FUNCS_ONCE([localtime_r])
Packit 8f70b4
  if test $ac_cv_func_localtime_r = yes; then
Packit 8f70b4
    HAVE_LOCALTIME_R=1
Packit 8f70b4
    AC_CACHE_CHECK([whether localtime_r is compatible with its POSIX signature],
Packit 8f70b4
      [gl_cv_time_r_posix],
Packit 8f70b4
      [AC_COMPILE_IFELSE(
Packit 8f70b4
         [AC_LANG_PROGRAM(
Packit 8f70b4
            [[#include <time.h>]],
Packit 8f70b4
            [[/* We don't need to append 'restrict's to the argument types,
Packit 8f70b4
                 even though the POSIX signature has the 'restrict's,
Packit 8f70b4
                 since C99 says they can't affect type compatibility.  */
Packit 8f70b4
              struct tm * (*ptr) (time_t const *, struct tm *) = localtime_r;
Packit 8f70b4
              if (ptr) return 0;
Packit 8f70b4
              /* Check the return type is a pointer.
Packit 8f70b4
                 On HP-UX 10 it is 'int'.  */
Packit 8f70b4
              *localtime_r (0, 0);]])
Packit 8f70b4
         ],
Packit 8f70b4
         [gl_cv_time_r_posix=yes],
Packit 8f70b4
         [gl_cv_time_r_posix=no])
Packit 8f70b4
      ])
Packit 8f70b4
    if test $gl_cv_time_r_posix = yes; then
Packit 8f70b4
      REPLACE_LOCALTIME_R=0
Packit 8f70b4
    else
Packit 8f70b4
      REPLACE_LOCALTIME_R=1
Packit 8f70b4
    fi
Packit 8f70b4
  else
Packit 8f70b4
    HAVE_LOCALTIME_R=0
Packit 8f70b4
  fi
Packit 8f70b4
])
Packit 8f70b4
Packit 8f70b4
# Prerequisites of lib/time_r.c.
Packit 8f70b4
AC_DEFUN([gl_PREREQ_TIME_R], [
Packit 8f70b4
  :
Packit 8f70b4
])