diff options
author | Lorenz <12514511+RincewindsHat@users.noreply.github.com> | 2023-02-10 10:43:20 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-10 10:43:20 (GMT) |
commit | c07206f2ccc2356aa74bc6813a94c2190017d44e (patch) | |
tree | 1677e5fdca5c3ce544e92c5484e16a0b68df1cc9 /gl/m4/time_h.m4 | |
parent | e92046f810658016b7c373677efefda3b21400e4 (diff) | |
parent | d2fcf49ad4afc15f37d082d7bc96a808369ec2d4 (diff) | |
download | monitoring-plugins-c07206f.tar.gz |
Merge pull request #1832 from RincewindsHat/gnulib_update_2023
Gnulib update 2023 and attendant fixes
Diffstat (limited to 'gl/m4/time_h.m4')
-rw-r--r-- | gl/m4/time_h.m4 | 114 |
1 files changed, 94 insertions, 20 deletions
diff --git a/gl/m4/time_h.m4 b/gl/m4/time_h.m4 index 3b83900..f6bf3a4 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-2023 Free Software Foundation, Inc. |
4 | 4 | ||
5 | # serial 7 | 5 | # serial 20 |
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,42 @@ | |||
10 | 10 | ||
11 | # Written by Paul Eggert and Jim Meyering. | 11 | # Written by Paul Eggert and Jim Meyering. |
12 | 12 | ||
13 | AC_DEFUN([gl_HEADER_TIME_H], | 13 | AC_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 | ||
20 | AC_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 | dnl Check for declarations of anything we want to poison if the | ||
23 | dnl corresponding gnulib module is not in use. | ||
24 | gl_WARN_ON_USE_PREPARE([[ | ||
25 | #include <time.h> | ||
26 | ]], [asctime_r ctime_r]) | ||
27 | |||
28 | AC_REQUIRE([AC_C_RESTRICT]) | ||
29 | |||
30 | AC_CACHE_CHECK([for TIME_UTC in <time.h>], | ||
31 | [gl_cv_time_h_has_TIME_UTC], | ||
32 | [AC_COMPILE_IFELSE( | ||
33 | [AC_LANG_PROGRAM( | ||
34 | [[#include <time.h> | ||
35 | ]], | ||
36 | [[static int x = TIME_UTC; x++;]])], | ||
37 | [gl_cv_time_h_has_TIME_UTC=yes], | ||
38 | [gl_cv_time_h_has_TIME_UTC=no])]) | ||
39 | if test $gl_cv_time_h_has_TIME_UTC = yes; then | ||
40 | TIME_H_DEFINES_TIME_UTC=1 | ||
41 | else | ||
42 | TIME_H_DEFINES_TIME_UTC=0 | ||
43 | fi | ||
44 | AC_SUBST([TIME_H_DEFINES_TIME_UTC]) | ||
26 | ]) | 45 | ]) |
27 | 46 | ||
28 | dnl Check whether 'struct timespec' is declared | 47 | dnl Check whether 'struct timespec' is declared |
29 | dnl in time.h, sys/time.h, or pthread.h. | 48 | dnl in time.h, sys/time.h, pthread.h, or unistd.h. |
30 | 49 | ||
31 | AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC], | 50 | AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC], |
32 | [ | 51 | [ |
@@ -44,6 +63,7 @@ AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC], | |||
44 | TIME_H_DEFINES_STRUCT_TIMESPEC=0 | 63 | TIME_H_DEFINES_STRUCT_TIMESPEC=0 |
45 | SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=0 | 64 | SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=0 |
46 | PTHREAD_H_DEFINES_STRUCT_TIMESPEC=0 | 65 | PTHREAD_H_DEFINES_STRUCT_TIMESPEC=0 |
66 | UNISTD_H_DEFINES_STRUCT_TIMESPEC=0 | ||
47 | if test $gl_cv_sys_struct_timespec_in_time_h = yes; then | 67 | if test $gl_cv_sys_struct_timespec_in_time_h = yes; then |
48 | TIME_H_DEFINES_STRUCT_TIMESPEC=1 | 68 | TIME_H_DEFINES_STRUCT_TIMESPEC=1 |
49 | else | 69 | else |
@@ -70,40 +90,94 @@ AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC], | |||
70 | [gl_cv_sys_struct_timespec_in_pthread_h=no])]) | 90 | [gl_cv_sys_struct_timespec_in_pthread_h=no])]) |
71 | if test $gl_cv_sys_struct_timespec_in_pthread_h = yes; then | 91 | if test $gl_cv_sys_struct_timespec_in_pthread_h = yes; then |
72 | PTHREAD_H_DEFINES_STRUCT_TIMESPEC=1 | 92 | PTHREAD_H_DEFINES_STRUCT_TIMESPEC=1 |
93 | else | ||
94 | AC_CACHE_CHECK([for struct timespec in <unistd.h>], | ||
95 | [gl_cv_sys_struct_timespec_in_unistd_h], | ||
96 | [AC_COMPILE_IFELSE( | ||
97 | [AC_LANG_PROGRAM( | ||
98 | [[#include <unistd.h> | ||
99 | ]], | ||
100 | [[static struct timespec x; x.tv_sec = x.tv_nsec;]])], | ||
101 | [gl_cv_sys_struct_timespec_in_unistd_h=yes], | ||
102 | [gl_cv_sys_struct_timespec_in_unistd_h=no])]) | ||
103 | if test $gl_cv_sys_struct_timespec_in_unistd_h = yes; then | ||
104 | UNISTD_H_DEFINES_STRUCT_TIMESPEC=1 | ||
105 | fi | ||
73 | fi | 106 | fi |
74 | fi | 107 | fi |
75 | fi | 108 | fi |
76 | AC_SUBST([TIME_H_DEFINES_STRUCT_TIMESPEC]) | 109 | AC_SUBST([TIME_H_DEFINES_STRUCT_TIMESPEC]) |
77 | AC_SUBST([SYS_TIME_H_DEFINES_STRUCT_TIMESPEC]) | 110 | AC_SUBST([SYS_TIME_H_DEFINES_STRUCT_TIMESPEC]) |
78 | AC_SUBST([PTHREAD_H_DEFINES_STRUCT_TIMESPEC]) | 111 | AC_SUBST([PTHREAD_H_DEFINES_STRUCT_TIMESPEC]) |
112 | AC_SUBST([UNISTD_H_DEFINES_STRUCT_TIMESPEC]) | ||
79 | ]) | 113 | ]) |
80 | 114 | ||
115 | # gl_TIME_MODULE_INDICATOR([modulename]) | ||
116 | # sets the shell variable that indicates the presence of the given module | ||
117 | # to a C preprocessor expression that will evaluate to 1. | ||
118 | # This macro invocation must not occur in macros that are AC_REQUIREd. | ||
81 | AC_DEFUN([gl_TIME_MODULE_INDICATOR], | 119 | AC_DEFUN([gl_TIME_MODULE_INDICATOR], |
82 | [ | 120 | [ |
83 | dnl Use AC_REQUIRE here, so that the default settings are expanded once only. | 121 | dnl Ensure to expand the default settings once only. |
84 | AC_REQUIRE([gl_HEADER_TIME_H_DEFAULTS]) | 122 | gl_TIME_H_REQUIRE_DEFAULTS |
85 | gl_MODULE_INDICATOR_SET_VARIABLE([$1]) | 123 | gl_MODULE_INDICATOR_SET_VARIABLE([$1]) |
86 | dnl Define it also as a C macro, for the benefit of the unit tests. | 124 | dnl Define it also as a C macro, for the benefit of the unit tests. |
87 | gl_MODULE_INDICATOR_FOR_TESTS([$1]) | 125 | gl_MODULE_INDICATOR_FOR_TESTS([$1]) |
88 | ]) | 126 | ]) |
89 | 127 | ||
90 | AC_DEFUN([gl_HEADER_TIME_H_DEFAULTS], | 128 | # Initializes the default values for AC_SUBSTed shell variables. |
129 | # This macro must not be AC_REQUIREd. It must only be invoked, and only | ||
130 | # outside of macros or in macros that are not AC_REQUIREd. | ||
131 | AC_DEFUN([gl_TIME_H_REQUIRE_DEFAULTS], | ||
132 | [ | ||
133 | m4_defun(GL_MODULE_INDICATOR_PREFIX[_TIME_H_MODULE_INDICATOR_DEFAULTS], [ | ||
134 | gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_CTIME]) | ||
135 | gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MKTIME]) | ||
136 | gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_LOCALTIME]) | ||
137 | gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_NANOSLEEP]) | ||
138 | gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRFTIME]) | ||
139 | gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_STRPTIME]) | ||
140 | gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TIMEGM]) | ||
141 | gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TIMESPEC_GET]) | ||
142 | gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TIMESPEC_GETRES]) | ||
143 | gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TIME_R]) | ||
144 | gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TIME_RZ]) | ||
145 | gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_TZSET]) | ||
146 | dnl Support Microsoft deprecated alias function names by default. | ||
147 | gl_MODULE_INDICATOR_INIT_VARIABLE([GNULIB_MDA_TZSET], [1]) | ||
148 | ]) | ||
149 | m4_require(GL_MODULE_INDICATOR_PREFIX[_TIME_H_MODULE_INDICATOR_DEFAULTS]) | ||
150 | AC_REQUIRE([gl_TIME_H_DEFAULTS]) | ||
151 | ]) | ||
152 | |||
153 | AC_DEFUN([gl_TIME_H_DEFAULTS], | ||
91 | [ | 154 | [ |
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. | 155 | dnl Assume proper GNU behavior unless another module says otherwise. |
98 | HAVE_DECL_LOCALTIME_R=1; AC_SUBST([HAVE_DECL_LOCALTIME_R]) | 156 | HAVE_DECL_LOCALTIME_R=1; AC_SUBST([HAVE_DECL_LOCALTIME_R]) |
99 | HAVE_NANOSLEEP=1; AC_SUBST([HAVE_NANOSLEEP]) | 157 | HAVE_NANOSLEEP=1; AC_SUBST([HAVE_NANOSLEEP]) |
100 | HAVE_STRPTIME=1; AC_SUBST([HAVE_STRPTIME]) | 158 | HAVE_STRPTIME=1; AC_SUBST([HAVE_STRPTIME]) |
101 | HAVE_TIMEGM=1; AC_SUBST([HAVE_TIMEGM]) | 159 | HAVE_TIMEGM=1; AC_SUBST([HAVE_TIMEGM]) |
160 | HAVE_TIMESPEC_GET=1; AC_SUBST([HAVE_TIMESPEC_GET]) | ||
161 | HAVE_TIMESPEC_GETRES=1; AC_SUBST([HAVE_TIMESPEC_GETRES]) | ||
162 | dnl Even GNU libc does not have timezone_t yet. | ||
163 | HAVE_TIMEZONE_T=0; AC_SUBST([HAVE_TIMEZONE_T]) | ||
102 | dnl If another module says to replace or to not replace, do that. | 164 | dnl If another module says to replace or to not replace, do that. |
103 | dnl Otherwise, replace only if someone compiles with -DGNULIB_PORTCHECK; | 165 | dnl Otherwise, replace only if someone compiles with -DGNULIB_PORTCHECK; |
104 | dnl this lets maintainers check for portability. | 166 | dnl this lets maintainers check for portability. |
167 | REPLACE_CTIME=GNULIB_PORTCHECK; AC_SUBST([REPLACE_CTIME]) | ||
105 | REPLACE_LOCALTIME_R=GNULIB_PORTCHECK; AC_SUBST([REPLACE_LOCALTIME_R]) | 168 | REPLACE_LOCALTIME_R=GNULIB_PORTCHECK; AC_SUBST([REPLACE_LOCALTIME_R]) |
106 | REPLACE_MKTIME=GNULIB_PORTCHECK; AC_SUBST([REPLACE_MKTIME]) | 169 | REPLACE_MKTIME=GNULIB_PORTCHECK; AC_SUBST([REPLACE_MKTIME]) |
107 | REPLACE_NANOSLEEP=GNULIB_PORTCHECK; AC_SUBST([REPLACE_NANOSLEEP]) | 170 | REPLACE_NANOSLEEP=GNULIB_PORTCHECK; AC_SUBST([REPLACE_NANOSLEEP]) |
171 | REPLACE_STRFTIME=GNULIB_PORTCHECK; AC_SUBST([REPLACE_STRFTIME]) | ||
108 | REPLACE_TIMEGM=GNULIB_PORTCHECK; AC_SUBST([REPLACE_TIMEGM]) | 172 | REPLACE_TIMEGM=GNULIB_PORTCHECK; AC_SUBST([REPLACE_TIMEGM]) |
173 | REPLACE_TZSET=GNULIB_PORTCHECK; AC_SUBST([REPLACE_TZSET]) | ||
174 | |||
175 | dnl Hack so that the time module doesn't depend on the sys_time module. | ||
176 | dnl First, default GNULIB_GETTIMEOFDAY to 0 if sys_time is absent. | ||
177 | : ${GNULIB_GETTIMEOFDAY=0}; AC_SUBST([GNULIB_GETTIMEOFDAY]) | ||
178 | dnl Second, it's OK to not use GNULIB_PORTCHECK for REPLACE_GMTIME | ||
179 | dnl and REPLACE_LOCALTIME, as portability to Solaris 2.6 and earlier | ||
180 | dnl is no longer a big deal. | ||
181 | REPLACE_GMTIME=0; AC_SUBST([REPLACE_GMTIME]) | ||
182 | REPLACE_LOCALTIME=0; AC_SUBST([REPLACE_LOCALTIME]) | ||
109 | ]) | 183 | ]) |