Debian Codegraph @

lib/sys_time.in.h

raw
1 /* Provide a more complete sys/time.h.
2
3 Copyright (C) 2007-2026 Free Software Foundation, Inc.
4
5 This file is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as
7 published by the Free Software Foundation; either version 2.1 of the
8 License, or (at your option) any later version.
9
10 This file is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
17
18 /* Written by Paul Eggert. */
19
20 #ifndef _@GUARD_PREFIX@_SYS_TIME_H
21
22 #if __GNUC__ >= 3
23 @PRAGMA_SYSTEM_HEADER@
24 #endif
25 @PRAGMA_COLUMNS@
26
27 /* This file uses #include_next of a system file that defines time_t.
28 For the 'year2038' module to work right, <config.h> needs to have been
29 included before. */
30 #if !_GL_CONFIG_H_INCLUDED
31 #error "Please include config.h first."
32 #endif
33
34 /* On Cygwin and on many BSDish systems, <sys/time.h> includes itself
35 recursively via <sys/select.h>.
36 Simply delegate to the system's header in this case; it is a no-op.
37 Without this extra ifdef, the C++ gettimeofday declaration below
38 would be a forward declaration in gnulib's nested <sys/time.h>. */
39 #if defined _CYGWIN_SYS_TIME_H || defined _SYS_TIME_H || defined _SYS_TIME_H_
40 # @INCLUDE_NEXT@ @NEXT_SYS_TIME_H@
41 #else
42
43 /* The include_next requires a split double-inclusion guard. */
44 #if @HAVE_SYS_TIME_H@
45 # @INCLUDE_NEXT@ @NEXT_SYS_TIME_H@
46 #endif
47
48 #ifndef _@GUARD_PREFIX@_SYS_TIME_H
49 #define _@GUARD_PREFIX@_SYS_TIME_H
50
51 /* This file uses GNULIB_POSIXCHECK, HAVE_RAW_DECL_*. */
52 #if !_GL_CONFIG_H_INCLUDED
53 #error "Please include config.h first."
54 #endif
55
56 #if ! @HAVE_SYS_TIME_H@
57 # include <time.h>
58 #endif
59
60 /* On native Windows with MSVC, get the 'struct timeval' type.
61 Also, on native Windows with a 64-bit time_t, where we are overriding the
62 'struct timeval' type, get all declarations of system functions whose
63 signature contains 'struct timeval'. */
64 #if (defined _MSC_VER || @REPLACE_STRUCT_TIMEVAL@) && @HAVE_WINSOCK2_H@ && !defined _GL_INCLUDING_WINSOCK2_H
65 # define _GL_INCLUDING_WINSOCK2_H
66 # include <winsock2.h>
67 # undef _GL_INCLUDING_WINSOCK2_H
68 #endif
69
70 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
71
72 /* The definition of _GL_ARG_NONNULL is copied here. */
73
74 /* The definition of _GL_WARN_ON_USE is copied here. */
75
76 #ifdef __cplusplus
77 extern "C" {
78 #endif
79
80 #if !@HAVE_STRUCT_TIMEVAL@ || @REPLACE_STRUCT_TIMEVAL@
81
82 # if @REPLACE_STRUCT_TIMEVAL@
83 # define timeval rpl_timeval
84 # endif
85
86 # if !GNULIB_defined_struct_timeval
87 struct timeval
88 {
89 time_t tv_sec;
90 long int tv_usec;
91 };
92 # define GNULIB_defined_struct_timeval 1
93 # endif
94
95 #endif
96
97 #ifdef __cplusplus
98 }
99 #endif
100
101 #if @GNULIB_GETTIMEOFDAY@
102 # if @REPLACE_GETTIMEOFDAY@
103 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
104 # undef gettimeofday
105 # define gettimeofday rpl_gettimeofday
106 # endif
107 _GL_FUNCDECL_RPL (gettimeofday, int,
108 (struct timeval *restrict, void *restrict),
109 _GL_ARG_NONNULL ((1)));
110 _GL_CXXALIAS_RPL (gettimeofday, int,
111 (struct timeval *restrict, void *restrict));
112 # else
113 # if !@HAVE_GETTIMEOFDAY@
114 _GL_FUNCDECL_SYS (gettimeofday, int,
115 (struct timeval *restrict, void *restrict),
116 _GL_ARG_NONNULL ((1)));
117 # endif
118 /* Need to cast, because on glibc systems, by default, the second argument is
119 struct timezone *. */
120 _GL_CXXALIAS_SYS_CAST (gettimeofday, int,
121 (struct timeval *restrict, void *restrict));
122 # endif
123 _GL_CXXALIASWARN (gettimeofday);
124 # if defined __cplusplus && defined GNULIB_NAMESPACE
125 namespace GNULIB_NAMESPACE {
126 typedef ::timeval
127 # undef timeval
128 timeval;
129 # if @REPLACE_STRUCT_TIMEVAL@
130 # define timeval rpl_timeval
131 typedef ::timeval timeval;
132 # endif
133 }
134 # endif
135 #elif defined GNULIB_POSIXCHECK
136 # if HAVE_RAW_DECL_GETTIMEOFDAY
137 _GL_WARN_ON_USE (gettimeofday, "gettimeofday is unportable - "
138 "use gnulib module gettimeofday for portability");
139 # endif
140 #endif
141
142 /* Hide some function declarations from <winsock2.h>. */
143
144 #if defined _MSC_VER && @HAVE_WINSOCK2_H@
145 # if !defined _@GUARD_PREFIX@_UNISTD_H
146 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
147 # undef close
148 # define close close_used_without_including_unistd_h
149 # elif !defined __clang__
150 _GL_WARN_ON_USE (close,
151 "close() used without including <unistd.h>");
152 # endif
153 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
154 # undef gethostname
155 # define gethostname gethostname_used_without_including_unistd_h
156 # else
157 _GL_WARN_ON_USE (gethostname,
158 "gethostname() used without including <unistd.h>");
159 # endif
160 # endif
161 # if !defined _@GUARD_PREFIX@_SYS_SOCKET_H
162 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
163 # undef socket
164 # define socket socket_used_without_including_sys_socket_h
165 # undef connect
166 # define connect connect_used_without_including_sys_socket_h
167 # undef accept
168 # define accept accept_used_without_including_sys_socket_h
169 # undef bind
170 # define bind bind_used_without_including_sys_socket_h
171 # undef getpeername
172 # define getpeername getpeername_used_without_including_sys_socket_h
173 # undef getsockname
174 # define getsockname getsockname_used_without_including_sys_socket_h
175 # undef getsockopt
176 # define getsockopt getsockopt_used_without_including_sys_socket_h
177 # undef listen
178 # define listen listen_used_without_including_sys_socket_h
179 # undef recv
180 # define recv recv_used_without_including_sys_socket_h
181 # undef send
182 # define send send_used_without_including_sys_socket_h
183 # undef recvfrom
184 # define recvfrom recvfrom_used_without_including_sys_socket_h
185 # undef sendto
186 # define sendto sendto_used_without_including_sys_socket_h
187 # undef setsockopt
188 # define setsockopt setsockopt_used_without_including_sys_socket_h
189 # undef shutdown
190 # define shutdown shutdown_used_without_including_sys_socket_h
191 # else
192 _GL_WARN_ON_USE (socket,
193 "socket() used without including <sys/socket.h>");
194 _GL_WARN_ON_USE (connect,
195 "connect() used without including <sys/socket.h>");
196 _GL_WARN_ON_USE (accept,
197 "accept() used without including <sys/socket.h>");
198 _GL_WARN_ON_USE (bind,
199 "bind() used without including <sys/socket.h>");
200 _GL_WARN_ON_USE (getpeername,
201 "getpeername() used without including <sys/socket.h>");
202 _GL_WARN_ON_USE (getsockname,
203 "getsockname() used without including <sys/socket.h>");
204 _GL_WARN_ON_USE (getsockopt,
205 "getsockopt() used without including <sys/socket.h>");
206 _GL_WARN_ON_USE (listen,
207 "listen() used without including <sys/socket.h>");
208 _GL_WARN_ON_USE (recv,
209 "recv() used without including <sys/socket.h>");
210 _GL_WARN_ON_USE (send,
211 "send() used without including <sys/socket.h>");
212 _GL_WARN_ON_USE (recvfrom,
213 "recvfrom() used without including <sys/socket.h>");
214 _GL_WARN_ON_USE (sendto,
215 "sendto() used without including <sys/socket.h>");
216 _GL_WARN_ON_USE (setsockopt,
217 "setsockopt() used without including <sys/socket.h>");
218 _GL_WARN_ON_USE (shutdown,
219 "shutdown() used without including <sys/socket.h>");
220 # endif
221 # endif
222 # if !defined _@GUARD_PREFIX@_SYS_SELECT_H
223 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
224 # undef select
225 # define select select_used_without_including_sys_select_h
226 # else
227 _GL_WARN_ON_USE (select,
228 "select() used without including <sys/select.h>");
229 # endif
230 # endif
231 #endif
232
233 #endif /* _@GUARD_PREFIX@_SYS_TIME_H */
234 #endif /* _CYGWIN_SYS_TIME_H */
235 #endif /* _@GUARD_PREFIX@_SYS_TIME_H */