summaryrefslogtreecommitdiffstats
path: root/gl/m4/time_h.m4
diff options
context:
space:
mode:
Diffstat (limited to 'gl/m4/time_h.m4')
-rw-r--r--gl/m4/time_h.m4108
1 files changed, 88 insertions, 20 deletions
diff --git a/gl/m4/time_h.m4 b/gl/m4/time_h.m4
index 3b83900..98d7b6e 100644
--- a/gl/m4/time_h.m4
+++ b/gl/m4/time_h.m4
@@ -1,8 +1,8 @@
1# Configure a more-standard replacement for <time.h>. 1# Configure a more-standard replacement for <time.h>.
2 2
3# Copyright (C) 2000-2001, 2003-2007, 2009-2013 Free Software Foundation, Inc. 3# Copyright (C) 2000-2001, 2003-2007, 2009-2022 Free Software Foundation, Inc.
4 4
5# serial 7 5# serial 19
6 6
7# This file is free software; the Free Software Foundation 7# This file is free software; the Free Software Foundation
8# gives unlimited permission to copy and/or distribute it, 8# gives unlimited permission to copy and/or distribute it,
@@ -10,23 +10,36 @@
10 10
11# Written by Paul Eggert and Jim Meyering. 11# Written by Paul Eggert and Jim Meyering.
12 12
13AC_DEFUN([gl_HEADER_TIME_H], 13AC_DEFUN_ONCE([gl_TIME_H],
14[ 14[
15 dnl Use AC_REQUIRE here, so that the default behavior below is expanded 15 dnl Ensure to expand the default settings once only, before all statements
16 dnl once only, before all statements that occur in other macros. 16 dnl that occur in other macros.
17 AC_REQUIRE([gl_HEADER_TIME_H_BODY]) 17 AC_REQUIRE([gl_TIME_H_DEFAULTS])
18])
19 18
20AC_DEFUN([gl_HEADER_TIME_H_BODY],
21[
22 AC_REQUIRE([AC_C_RESTRICT])
23 AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS])
24 gl_NEXT_HEADERS([time.h]) 19 gl_NEXT_HEADERS([time.h])
25 AC_REQUIRE([gl_CHECK_TYPE_STRUCT_TIMESPEC]) 20 AC_REQUIRE([gl_CHECK_TYPE_STRUCT_TIMESPEC])
21
22 AC_REQUIRE([AC_C_RESTRICT])
23
24 AC_CACHE_CHECK([for TIME_UTC in <time.h>],
25 [gl_cv_time_h_has_TIME_UTC],
26 [AC_COMPILE_IFELSE(
27 [AC_LANG_PROGRAM(
28 [[#include <time.h>
29 ]],
30 [[static int x = TIME_UTC; x++;]])],
31 [gl_cv_time_h_has_TIME_UTC=yes],
32 [gl_cv_time_h_has_TIME_UTC=no])])
33 if test $gl_cv_time_h_has_TIME_UTC = yes; then
34 TIME_H_DEFINES_TIME_UTC=1
35 else
36 TIME_H_DEFINES_TIME_UTC=0
37 fi
38 AC_SUBST([TIME_H_DEFINES_TIME_UTC])
26]) 39])
27 40
28dnl Check whether 'struct timespec' is declared 41dnl Check whether 'struct timespec' is declared
29dnl in time.h, sys/time.h, or pthread.h. 42dnl in time.h, sys/time.h, pthread.h, or unistd.h.
30 43
31AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC], 44AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC],
32[ 45[
@@ -44,6 +57,7 @@ AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC],
44 TIME_H_DEFINES_STRUCT_TIMESPEC=0 57 TIME_H_DEFINES_STRUCT_TIMESPEC=0
45 SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=0 58 SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=0
46 PTHREAD_H_DEFINES_STRUCT_TIMESPEC=0 59 PTHREAD_H_DEFINES_STRUCT_TIMESPEC=0
60 UNISTD_H_DEFINES_STRUCT_TIMESPEC=0
47 if test $gl_cv_sys_struct_timespec_in_time_h = yes; then 61 if test $gl_cv_sys_struct_timespec_in_time_h = yes; then
48 TIME_H_DEFINES_STRUCT_TIMESPEC=1 62 TIME_H_DEFINES_STRUCT_TIMESPEC=1
49 else 63 else
@@ -70,40 +84,94 @@ AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC],
70 [gl_cv_sys_struct_timespec_in_pthread_h=no])]) 84 [gl_cv_sys_struct_timespec_in_pthread_h=no])])
71 if test $gl_cv_sys_struct_timespec_in_pthread_h = yes; then 85 if test $gl_cv_sys_struct_timespec_in_pthread_h = yes; then
72 PTHREAD_H_DEFINES_STRUCT_TIMESPEC=1 86 PTHREAD_H_DEFINES_STRUCT_TIMESPEC=1
87 else
88 AC_CACHE_CHECK([for struct timespec in <unistd.h>],
89 [gl_cv_sys_struct_timespec_in_unistd_h],
90 [AC_COMPILE_IFELSE(
91 [AC_LANG_PROGRAM(
92 [[#include <unistd.h>
93 ]],
94 [[static struct timespec x; x.tv_sec = x.tv_nsec;]])],
95 [gl_cv_sys_struct_timespec_in_unistd_h=yes],
96 [gl_cv_sys_struct_timespec_in_unistd_h=no])])
97 if test $gl_cv_sys_struct_timespec_in_unistd_h = yes; then
98 UNISTD_H_DEFINES_STRUCT_TIMESPEC=1
99 fi
73 fi 100 fi
74 fi 101 fi
75 fi 102 fi
76 AC_SUBST([TIME_H_DEFINES_STRUCT_TIMESPEC]) 103 AC_SUBST([TIME_H_DEFINES_STRUCT_TIMESPEC])
77 AC_SUBST([SYS_TIME_H_DEFINES_STRUCT_TIMESPEC]) 104 AC_SUBST([SYS_TIME_H_DEFINES_STRUCT_TIMESPEC])
78 AC_SUBST([PTHREAD_H_DEFINES_STRUCT_TIMESPEC]) 105 AC_SUBST([PTHREAD_H_DEFINES_STRUCT_TIMESPEC])
106 AC_SUBST([UNISTD_H_DEFINES_STRUCT_TIMESPEC])
79]) 107])
80 108
109# gl_TIME_MODULE_INDICATOR([modulename])
110# sets the shell variable that indicates the presence of the given module
111# to a C preprocessor expression that will evaluate to 1.
112# This macro invocation must not occur in macros that are AC_REQUIREd.
81AC_DEFUN([gl_TIME_MODULE_INDICATOR], 113AC_DEFUN([gl_TIME_MODULE_INDICATOR],
82[ 114[
83 dnl Use AC_REQUIRE here, so that the default settings are expanded once only. 115 dnl Ensure to expand the default settings once only.
84 AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS]) 116 gl_TIME_H_REQUIRE_DEFAULTS
85 gl_MODULE_INDICATOR_SET_VARIABLE([$1]) 117 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
86 dnl Define it also as a C macro, for the benefit of the unit tests. 118 dnl Define it also as a C macro, for the benefit of the unit tests.
87 gl_MODULE_INDICATOR_FOR_TESTS([$1]) 119 gl_MODULE_INDICATOR_FOR_TESTS([$1])
88]) 120])
89 121
90AC_DEFUN([gl_HEADER_TIME_H_DEFAULTS], 122# Initializes the default values for AC_SUBSTed shell variables.
123# This macro must not be AC_REQUIREd. It must only be invoked, and only
124# outside of macros or in macros that are not AC_REQUIREd.
125AC_DEFUN([gl_TIME_H_REQUIRE_DEFAULTS],
126[
127 m4_defun(GL_MODULE_INDICATOR_PREFIX[_TIME_H_MODULE_INDICATOR_DEFAULTS], [
128 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CTIME])
129 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKTIME])
130 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOCALTIME])
131 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_NANOSLEEP])
132 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRFTIME])
133 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRPTIME])
134 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TIMEGM])
135 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TIMESPEC_GET])
136 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TIMESPEC_GETRES])
137 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TIME_R])
138 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TIME_RZ])
139 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TZSET])
140 dnl Support Microsoft deprecated alias function names by default.
141 gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_TZSET], [1])
142 ])
143 m4_require(GL_MODULE_INDICATOR_PREFIX[_TIME_H_MODULE_INDICATOR_DEFAULTS])
144 AC_REQUIRE([gl_TIME_H_DEFAULTS])
145])
146
147AC_DEFUN([gl_TIME_H_DEFAULTS],
91[ 148[
92 GNULIB_MKTIME=0; AC_SUBST([GNULIB_MKTIME])
93 GNULIB_NANOSLEEP=0; AC_SUBST([GNULIB_NANOSLEEP])
94 GNULIB_STRPTIME=0; AC_SUBST([GNULIB_STRPTIME])
95 GNULIB_TIMEGM=0; AC_SUBST([GNULIB_TIMEGM])
96 GNULIB_TIME_R=0; AC_SUBST([GNULIB_TIME_R])
97 dnl Assume proper GNU behavior unless another module says otherwise. 149 dnl Assume proper GNU behavior unless another module says otherwise.
98 HAVE_DECL_LOCALTIME_R=1; AC_SUBST([HAVE_DECL_LOCALTIME_R]) 150 HAVE_DECL_LOCALTIME_R=1; AC_SUBST([HAVE_DECL_LOCALTIME_R])
99 HAVE_NANOSLEEP=1; AC_SUBST([HAVE_NANOSLEEP]) 151 HAVE_NANOSLEEP=1; AC_SUBST([HAVE_NANOSLEEP])
100 HAVE_STRPTIME=1; AC_SUBST([HAVE_STRPTIME]) 152 HAVE_STRPTIME=1; AC_SUBST([HAVE_STRPTIME])
101 HAVE_TIMEGM=1; AC_SUBST([HAVE_TIMEGM]) 153 HAVE_TIMEGM=1; AC_SUBST([HAVE_TIMEGM])
154 HAVE_TIMESPEC_GET=1; AC_SUBST([HAVE_TIMESPEC_GET])
155 HAVE_TIMESPEC_GETRES=1; AC_SUBST([HAVE_TIMESPEC_GETRES])
156 dnl Even GNU libc does not have timezone_t yet.
157 HAVE_TIMEZONE_T=0; AC_SUBST([HAVE_TIMEZONE_T])
102 dnl If another module says to replace or to not replace, do that. 158 dnl If another module says to replace or to not replace, do that.
103 dnl Otherwise, replace only if someone compiles with -DGNULIB_PORTCHECK; 159 dnl Otherwise, replace only if someone compiles with -DGNULIB_PORTCHECK;
104 dnl this lets maintainers check for portability. 160 dnl this lets maintainers check for portability.
161 REPLACE_CTIME=GNULIB_PORTCHECK; AC_SUBST([REPLACE_CTIME])
105 REPLACE_LOCALTIME_R=GNULIB_PORTCHECK; AC_SUBST([REPLACE_LOCALTIME_R]) 162 REPLACE_LOCALTIME_R=GNULIB_PORTCHECK; AC_SUBST([REPLACE_LOCALTIME_R])
106 REPLACE_MKTIME=GNULIB_PORTCHECK; AC_SUBST([REPLACE_MKTIME]) 163 REPLACE_MKTIME=GNULIB_PORTCHECK; AC_SUBST([REPLACE_MKTIME])
107 REPLACE_NANOSLEEP=GNULIB_PORTCHECK; AC_SUBST([REPLACE_NANOSLEEP]) 164 REPLACE_NANOSLEEP=GNULIB_PORTCHECK; AC_SUBST([REPLACE_NANOSLEEP])
165 REPLACE_STRFTIME=GNULIB_PORTCHECK; AC_SUBST([REPLACE_STRFTIME])
108 REPLACE_TIMEGM=GNULIB_PORTCHECK; AC_SUBST([REPLACE_TIMEGM]) 166 REPLACE_TIMEGM=GNULIB_PORTCHECK; AC_SUBST([REPLACE_TIMEGM])
167 REPLACE_TZSET=GNULIB_PORTCHECK; AC_SUBST([REPLACE_TZSET])
168
169 dnl Hack so that the time module doesn't depend on the sys_time module.
170 dnl First, default GNULIB_GETTIMEOFDAY to 0 if sys_time is absent.
171 : ${GNULIB_GETTIMEOFDAY=0}; AC_SUBST([GNULIB_GETTIMEOFDAY])
172 dnl Second, it's OK to not use GNULIB_PORTCHECK for REPLACE_GMTIME
173 dnl and REPLACE_LOCALTIME, as portability to Solaris 2.6 and earlier
174 dnl is no longer a big deal.
175 REPLACE_GMTIME=0; AC_SUBST([REPLACE_GMTIME])
176 REPLACE_LOCALTIME=0; AC_SUBST([REPLACE_LOCALTIME])
109]) 177])