1 # Configure a more-standard replacement for <time.h>.
3 # Copyright (C) 2000-2001, 2003-2007, 2009-2010 Free Software Foundation, Inc.
5 # This file is free software; the Free Software Foundation
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
9 # Written by Paul Eggert and Jim Meyering.
11 AC_DEFUN([gl_HEADER_TIME_H],
13 dnl Use AC_REQUIRE here, so that the default behavior below is expanded
14 dnl once only, before all statements that occur in other macros.
15 AC_REQUIRE([gl_HEADER_TIME_H_BODY])
18 AC_DEFUN([gl_HEADER_TIME_H_BODY],
20 AC_REQUIRE([AC_C_RESTRICT])
21 AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS])
22 gl_CHECK_NEXT_HEADERS([time.h])
23 AC_REQUIRE([gl_CHECK_TYPE_STRUCT_TIMESPEC])
26 dnl Define HAVE_STRUCT_TIMESPEC if `struct timespec' is declared
27 dnl in time.h or sys/time.h.
29 AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC],
31 AC_CHECK_HEADERS_ONCE([sys/time.h])
32 AC_CACHE_CHECK([for struct timespec in <time.h>],
33 [gl_cv_sys_struct_timespec_in_time_h],
38 [[static struct timespec x; x.tv_sec = x.tv_nsec;]])],
39 [gl_cv_sys_struct_timespec_in_time_h=yes],
40 [gl_cv_sys_struct_timespec_in_time_h=no])])
42 TIME_H_DEFINES_STRUCT_TIMESPEC=0
43 SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=0
44 if test $gl_cv_sys_struct_timespec_in_time_h = yes; then
45 TIME_H_DEFINES_STRUCT_TIMESPEC=1
47 AC_CACHE_CHECK([for struct timespec in <sys/time.h>],
48 [gl_cv_sys_struct_timespec_in_sys_time_h],
51 [[#include <sys/time.h>
53 [[static struct timespec x; x.tv_sec = x.tv_nsec;]])],
54 [gl_cv_sys_struct_timespec_in_sys_time_h=yes],
55 [gl_cv_sys_struct_timespec_in_sys_time_h=no])])
56 if test $gl_cv_sys_struct_timespec_in_sys_time_h = yes; then
57 SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=1
60 AC_SUBST([TIME_H_DEFINES_STRUCT_TIMESPEC])
61 AC_SUBST([SYS_TIME_H_DEFINES_STRUCT_TIMESPEC])
64 AC_DEFUN([gl_TIME_MODULE_INDICATOR],
66 dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
67 AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS])
68 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
69 dnl Define it also as a C macro, for the benefit of the unit tests.
70 gl_MODULE_INDICATOR([$1])
73 AC_DEFUN([gl_HEADER_TIME_H_DEFAULTS],
75 GNULIB_MKTIME=0; AC_SUBST([GNULIB_MKTIME])
76 GNULIB_NANOSLEEP=0; AC_SUBST([GNULIB_NANOSLEEP])
77 GNULIB_STRPTIME=0; AC_SUBST([GNULIB_STRPTIME])
78 GNULIB_TIMEGM=0; AC_SUBST([GNULIB_TIMEGM])
79 GNULIB_TIME_R=0; AC_SUBST([GNULIB_TIME_R])
80 dnl If another module says to replace or to not replace, do that.
81 dnl Otherwise, replace only if someone compiles with -DGNULIB_PORTCHECK;
82 dnl this lets maintainers check for portability.
83 REPLACE_LOCALTIME_R=GNULIB_PORTCHECK; AC_SUBST([REPLACE_LOCALTIME_R])
84 REPLACE_MKTIME=GNULIB_PORTCHECK; AC_SUBST([REPLACE_MKTIME])
85 REPLACE_NANOSLEEP=GNULIB_PORTCHECK; AC_SUBST([REPLACE_NANOSLEEP])
86 REPLACE_STRPTIME=GNULIB_PORTCHECK; AC_SUBST([REPLACE_STRPTIME])
87 REPLACE_TIMEGM=GNULIB_PORTCHECK; AC_SUBST([REPLACE_TIMEGM])