Blame m4/time_h.m4

Packit Service a2489d
# Configure a more-standard replacement for <time.h>.
Packit Service a2489d
Packit Service a2489d
# Copyright (C) 2000-2001, 2003-2007, 2009-2018 Free Software Foundation, Inc.
Packit Service a2489d
Packit Service a2489d
# serial 11
Packit Service a2489d
Packit Service a2489d
# This file is free software; the Free Software Foundation
Packit Service a2489d
# gives unlimited permission to copy and/or distribute it,
Packit Service a2489d
# with or without modifications, as long as this notice is preserved.
Packit Service a2489d
Packit Service a2489d
# Written by Paul Eggert and Jim Meyering.
Packit Service a2489d
Packit Service a2489d
AC_DEFUN([gl_HEADER_TIME_H],
Packit Service a2489d
[
Packit Service a2489d
  dnl Use AC_REQUIRE here, so that the default behavior below is expanded
Packit Service a2489d
  dnl once only, before all statements that occur in other macros.
Packit Service a2489d
  AC_REQUIRE([gl_HEADER_TIME_H_BODY])
Packit Service a2489d
])
Packit Service a2489d
Packit Service a2489d
AC_DEFUN([gl_HEADER_TIME_H_BODY],
Packit Service a2489d
[
Packit Service a2489d
  AC_REQUIRE([AC_C_RESTRICT])
Packit Service a2489d
  AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS])
Packit Service a2489d
  gl_NEXT_HEADERS([time.h])
Packit Service a2489d
  AC_REQUIRE([gl_CHECK_TYPE_STRUCT_TIMESPEC])
Packit Service a2489d
])
Packit Service a2489d
Packit Service a2489d
dnl Check whether 'struct timespec' is declared
Packit Service a2489d
dnl in time.h, sys/time.h, pthread.h, or unistd.h.
Packit Service a2489d
Packit Service a2489d
AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC],
Packit Service a2489d
[
Packit Service a2489d
  AC_CHECK_HEADERS_ONCE([sys/time.h])
Packit Service a2489d
  AC_CACHE_CHECK([for struct timespec in <time.h>],
Packit Service a2489d
    [gl_cv_sys_struct_timespec_in_time_h],
Packit Service a2489d
    [AC_COMPILE_IFELSE(
Packit Service a2489d
       [AC_LANG_PROGRAM(
Packit Service a2489d
          [[#include <time.h>
Packit Service a2489d
          ]],
Packit Service a2489d
          [[static struct timespec x; x.tv_sec = x.tv_nsec;]])],
Packit Service a2489d
       [gl_cv_sys_struct_timespec_in_time_h=yes],
Packit Service a2489d
       [gl_cv_sys_struct_timespec_in_time_h=no])])
Packit Service a2489d
Packit Service a2489d
  TIME_H_DEFINES_STRUCT_TIMESPEC=0
Packit Service a2489d
  SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=0
Packit Service a2489d
  PTHREAD_H_DEFINES_STRUCT_TIMESPEC=0
Packit Service a2489d
  UNISTD_H_DEFINES_STRUCT_TIMESPEC=0
Packit Service a2489d
  if test $gl_cv_sys_struct_timespec_in_time_h = yes; then
Packit Service a2489d
    TIME_H_DEFINES_STRUCT_TIMESPEC=1
Packit Service a2489d
  else
Packit Service a2489d
    AC_CACHE_CHECK([for struct timespec in <sys/time.h>],
Packit Service a2489d
      [gl_cv_sys_struct_timespec_in_sys_time_h],
Packit Service a2489d
      [AC_COMPILE_IFELSE(
Packit Service a2489d
         [AC_LANG_PROGRAM(
Packit Service a2489d
            [[#include <sys/time.h>
Packit Service a2489d
            ]],
Packit Service a2489d
            [[static struct timespec x; x.tv_sec = x.tv_nsec;]])],
Packit Service a2489d
         [gl_cv_sys_struct_timespec_in_sys_time_h=yes],
Packit Service a2489d
         [gl_cv_sys_struct_timespec_in_sys_time_h=no])])
Packit Service a2489d
    if test $gl_cv_sys_struct_timespec_in_sys_time_h = yes; then
Packit Service a2489d
      SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=1
Packit Service a2489d
    else
Packit Service a2489d
      AC_CACHE_CHECK([for struct timespec in <pthread.h>],
Packit Service a2489d
        [gl_cv_sys_struct_timespec_in_pthread_h],
Packit Service a2489d
        [AC_COMPILE_IFELSE(
Packit Service a2489d
           [AC_LANG_PROGRAM(
Packit Service a2489d
              [[#include <pthread.h>
Packit Service a2489d
              ]],
Packit Service a2489d
              [[static struct timespec x; x.tv_sec = x.tv_nsec;]])],
Packit Service a2489d
           [gl_cv_sys_struct_timespec_in_pthread_h=yes],
Packit Service a2489d
           [gl_cv_sys_struct_timespec_in_pthread_h=no])])
Packit Service a2489d
      if test $gl_cv_sys_struct_timespec_in_pthread_h = yes; then
Packit Service a2489d
        PTHREAD_H_DEFINES_STRUCT_TIMESPEC=1
Packit Service a2489d
      else
Packit Service a2489d
        AC_CACHE_CHECK([for struct timespec in <unistd.h>],
Packit Service a2489d
          [gl_cv_sys_struct_timespec_in_unistd_h],
Packit Service a2489d
          [AC_COMPILE_IFELSE(
Packit Service a2489d
             [AC_LANG_PROGRAM(
Packit Service a2489d
                [[#include <unistd.h>
Packit Service a2489d
                ]],
Packit Service a2489d
                [[static struct timespec x; x.tv_sec = x.tv_nsec;]])],
Packit Service a2489d
             [gl_cv_sys_struct_timespec_in_unistd_h=yes],
Packit Service a2489d
             [gl_cv_sys_struct_timespec_in_unistd_h=no])])
Packit Service a2489d
        if test $gl_cv_sys_struct_timespec_in_unistd_h = yes; then
Packit Service a2489d
          UNISTD_H_DEFINES_STRUCT_TIMESPEC=1
Packit Service a2489d
        fi
Packit Service a2489d
      fi
Packit Service a2489d
    fi
Packit Service a2489d
  fi
Packit Service a2489d
  AC_SUBST([TIME_H_DEFINES_STRUCT_TIMESPEC])
Packit Service a2489d
  AC_SUBST([SYS_TIME_H_DEFINES_STRUCT_TIMESPEC])
Packit Service a2489d
  AC_SUBST([PTHREAD_H_DEFINES_STRUCT_TIMESPEC])
Packit Service a2489d
  AC_SUBST([UNISTD_H_DEFINES_STRUCT_TIMESPEC])
Packit Service a2489d
])
Packit Service a2489d
Packit Service a2489d
AC_DEFUN([gl_TIME_MODULE_INDICATOR],
Packit Service a2489d
[
Packit Service a2489d
  dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
Packit Service a2489d
  AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS])
Packit Service a2489d
  gl_MODULE_INDICATOR_SET_VARIABLE([$1])
Packit Service a2489d
  dnl Define it also as a C macro, for the benefit of the unit tests.
Packit Service a2489d
  gl_MODULE_INDICATOR_FOR_TESTS([$1])
Packit Service a2489d
])
Packit Service a2489d
Packit Service a2489d
AC_DEFUN([gl_HEADER_TIME_H_DEFAULTS],
Packit Service a2489d
[
Packit Service a2489d
  GNULIB_CTIME=0;                        AC_SUBST([GNULIB_CTIME])
Packit Service a2489d
  GNULIB_MKTIME=0;                       AC_SUBST([GNULIB_MKTIME])
Packit Service a2489d
  GNULIB_LOCALTIME=0;                    AC_SUBST([GNULIB_LOCALTIME])
Packit Service a2489d
  GNULIB_NANOSLEEP=0;                    AC_SUBST([GNULIB_NANOSLEEP])
Packit Service a2489d
  GNULIB_STRFTIME=0;                     AC_SUBST([GNULIB_STRFTIME])
Packit Service a2489d
  GNULIB_STRPTIME=0;                     AC_SUBST([GNULIB_STRPTIME])
Packit Service a2489d
  GNULIB_TIMEGM=0;                       AC_SUBST([GNULIB_TIMEGM])
Packit Service a2489d
  GNULIB_TIME_R=0;                       AC_SUBST([GNULIB_TIME_R])
Packit Service a2489d
  GNULIB_TIME_RZ=0;                      AC_SUBST([GNULIB_TIME_RZ])
Packit Service a2489d
  GNULIB_TZSET=0;                        AC_SUBST([GNULIB_TZSET])
Packit Service a2489d
  dnl Assume proper GNU behavior unless another module says otherwise.
Packit Service a2489d
  HAVE_DECL_LOCALTIME_R=1;               AC_SUBST([HAVE_DECL_LOCALTIME_R])
Packit Service a2489d
  HAVE_NANOSLEEP=1;                      AC_SUBST([HAVE_NANOSLEEP])
Packit Service a2489d
  HAVE_STRPTIME=1;                       AC_SUBST([HAVE_STRPTIME])
Packit Service a2489d
  HAVE_TIMEGM=1;                         AC_SUBST([HAVE_TIMEGM])
Packit Service a2489d
  HAVE_TZSET=1;                          AC_SUBST([HAVE_TZSET])
Packit Service a2489d
  dnl Even GNU libc does not have timezone_t yet.
Packit Service a2489d
  HAVE_TIMEZONE_T=0;                     AC_SUBST([HAVE_TIMEZONE_T])
Packit Service a2489d
  dnl If another module says to replace or to not replace, do that.
Packit Service a2489d
  dnl Otherwise, replace only if someone compiles with -DGNULIB_PORTCHECK;
Packit Service a2489d
  dnl this lets maintainers check for portability.
Packit Service a2489d
  REPLACE_CTIME=GNULIB_PORTCHECK;        AC_SUBST([REPLACE_CTIME])
Packit Service a2489d
  REPLACE_LOCALTIME_R=GNULIB_PORTCHECK;  AC_SUBST([REPLACE_LOCALTIME_R])
Packit Service a2489d
  REPLACE_MKTIME=GNULIB_PORTCHECK;       AC_SUBST([REPLACE_MKTIME])
Packit Service a2489d
  REPLACE_NANOSLEEP=GNULIB_PORTCHECK;    AC_SUBST([REPLACE_NANOSLEEP])
Packit Service a2489d
  REPLACE_STRFTIME=GNULIB_PORTCHECK;     AC_SUBST([REPLACE_STRFTIME])
Packit Service a2489d
  REPLACE_TIMEGM=GNULIB_PORTCHECK;       AC_SUBST([REPLACE_TIMEGM])
Packit Service a2489d
  REPLACE_TZSET=GNULIB_PORTCHECK;        AC_SUBST([REPLACE_TZSET])
Packit Service a2489d
Packit Service a2489d
  dnl Hack so that the time module doesn't depend on the sys_time module.
Packit Service a2489d
  dnl First, default GNULIB_GETTIMEOFDAY to 0 if sys_time is absent.
Packit Service a2489d
  : ${GNULIB_GETTIMEOFDAY=0};            AC_SUBST([GNULIB_GETTIMEOFDAY])
Packit Service a2489d
  dnl Second, it's OK to not use GNULIB_PORTCHECK for REPLACE_GMTIME
Packit Service a2489d
  dnl and REPLACE_LOCALTIME, as portability to Solaris 2.6 and earlier
Packit Service a2489d
  dnl is no longer a big deal.
Packit Service a2489d
  REPLACE_GMTIME=0;                      AC_SUBST([REPLACE_GMTIME])
Packit Service a2489d
  REPLACE_LOCALTIME=0;                   AC_SUBST([REPLACE_LOCALTIME])
Packit Service a2489d
])