VirtualBox

source: kBuild/vendor/sed/current/m4/time_h.m4@ 3611

Last change on this file since 3611 was 3611, checked in by bird, 7 months ago

vendor/sed/current: GNU sed 4.9 (sed-4.9.tar.xz sha256:6e226b732e1cd739464ad6862bd1a1aba42d7982922da7a53519631d24975181)

File size: 7.3 KB
Line 
1# Configure a more-standard replacement for <time.h>.
2
3# Copyright (C) 2000-2001, 2003-2007, 2009-2022 Free Software Foundation, Inc.
4
5# serial 20
6
7# This file is free software; the Free Software Foundation
8# gives unlimited permission to copy and/or distribute it,
9# with or without modifications, as long as this notice is preserved.
10
11# Written by Paul Eggert and Jim Meyering.
12
13AC_DEFUN_ONCE([gl_TIME_H],
14[
15 dnl Ensure to expand the default settings once only, before all statements
16 dnl that occur in other macros.
17 AC_REQUIRE([gl_TIME_H_DEFAULTS])
18
19 gl_NEXT_HEADERS([time.h])
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])
45])
46
47dnl Check whether 'struct timespec' is declared
48dnl in time.h, sys/time.h, pthread.h, or unistd.h.
49
50AC_DEFUN([gl_CHECK_TYPE_STRUCT_TIMESPEC],
51[
52 AC_CHECK_HEADERS_ONCE([sys/time.h])
53 AC_CACHE_CHECK([for struct timespec in <time.h>],
54 [gl_cv_sys_struct_timespec_in_time_h],
55 [AC_COMPILE_IFELSE(
56 [AC_LANG_PROGRAM(
57 [[#include <time.h>
58 ]],
59 [[static struct timespec x; x.tv_sec = x.tv_nsec;]])],
60 [gl_cv_sys_struct_timespec_in_time_h=yes],
61 [gl_cv_sys_struct_timespec_in_time_h=no])])
62
63 TIME_H_DEFINES_STRUCT_TIMESPEC=0
64 SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=0
65 PTHREAD_H_DEFINES_STRUCT_TIMESPEC=0
66 UNISTD_H_DEFINES_STRUCT_TIMESPEC=0
67 if test $gl_cv_sys_struct_timespec_in_time_h = yes; then
68 TIME_H_DEFINES_STRUCT_TIMESPEC=1
69 else
70 AC_CACHE_CHECK([for struct timespec in <sys/time.h>],
71 [gl_cv_sys_struct_timespec_in_sys_time_h],
72 [AC_COMPILE_IFELSE(
73 [AC_LANG_PROGRAM(
74 [[#include <sys/time.h>
75 ]],
76 [[static struct timespec x; x.tv_sec = x.tv_nsec;]])],
77 [gl_cv_sys_struct_timespec_in_sys_time_h=yes],
78 [gl_cv_sys_struct_timespec_in_sys_time_h=no])])
79 if test $gl_cv_sys_struct_timespec_in_sys_time_h = yes; then
80 SYS_TIME_H_DEFINES_STRUCT_TIMESPEC=1
81 else
82 AC_CACHE_CHECK([for struct timespec in <pthread.h>],
83 [gl_cv_sys_struct_timespec_in_pthread_h],
84 [AC_COMPILE_IFELSE(
85 [AC_LANG_PROGRAM(
86 [[#include <pthread.h>
87 ]],
88 [[static struct timespec x; x.tv_sec = x.tv_nsec;]])],
89 [gl_cv_sys_struct_timespec_in_pthread_h=yes],
90 [gl_cv_sys_struct_timespec_in_pthread_h=no])])
91 if test $gl_cv_sys_struct_timespec_in_pthread_h = yes; then
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
106 fi
107 fi
108 fi
109 AC_SUBST([TIME_H_DEFINES_STRUCT_TIMESPEC])
110 AC_SUBST([SYS_TIME_H_DEFINES_STRUCT_TIMESPEC])
111 AC_SUBST([PTHREAD_H_DEFINES_STRUCT_TIMESPEC])
112 AC_SUBST([UNISTD_H_DEFINES_STRUCT_TIMESPEC])
113])
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.
119AC_DEFUN([gl_TIME_MODULE_INDICATOR],
120[
121 dnl Ensure to expand the default settings once only.
122 gl_TIME_H_REQUIRE_DEFAULTS
123 gl_MODULE_INDICATOR_SET_VARIABLE([$1])
124 dnl Define it also as a C macro, for the benefit of the unit tests.
125 gl_MODULE_INDICATOR_FOR_TESTS([$1])
126])
127
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.
131AC_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
153AC_DEFUN([gl_TIME_H_DEFAULTS],
154[
155 dnl Assume proper GNU behavior unless another module says otherwise.
156 HAVE_DECL_LOCALTIME_R=1; AC_SUBST([HAVE_DECL_LOCALTIME_R])
157 HAVE_NANOSLEEP=1; AC_SUBST([HAVE_NANOSLEEP])
158 HAVE_STRPTIME=1; AC_SUBST([HAVE_STRPTIME])
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])
164 dnl If another module says to replace or to not replace, do that.
165 dnl Otherwise, replace only if someone compiles with -DGNULIB_PORTCHECK;
166 dnl this lets maintainers check for portability.
167 REPLACE_CTIME=GNULIB_PORTCHECK; AC_SUBST([REPLACE_CTIME])
168 REPLACE_LOCALTIME_R=GNULIB_PORTCHECK; AC_SUBST([REPLACE_LOCALTIME_R])
169 REPLACE_MKTIME=GNULIB_PORTCHECK; AC_SUBST([REPLACE_MKTIME])
170 REPLACE_NANOSLEEP=GNULIB_PORTCHECK; AC_SUBST([REPLACE_NANOSLEEP])
171 REPLACE_STRFTIME=GNULIB_PORTCHECK; AC_SUBST([REPLACE_STRFTIME])
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])
183])
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette