1 /* Provide a more complete sys/time.h.
3 Copyright (C) 2007-2013 Free Software Foundation, Inc.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3, or (at your option)
10 This program 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 General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, see <http://www.gnu.org/licenses/>. */
18 /* Written by Paul Eggert. */
20 #ifndef _@GUARD_PREFIX@_SYS_TIME_H
23 @PRAGMA_SYSTEM_HEADER@
27 /* The include_next requires a split double-inclusion guard. */
29 # @INCLUDE_NEXT@ @NEXT_SYS_TIME_H@
32 #ifndef _@GUARD_PREFIX@_SYS_TIME_H
33 #define _@GUARD_PREFIX@_SYS_TIME_H
35 #if ! @HAVE_SYS_TIME_H@
39 /* On native Windows with MSVC, get the 'struct timeval' type.
40 Also, on native Windows with a 64-bit time_t, where we are overriding the
41 'struct timeval' type, get all declarations of system functions whose
42 signature contains 'struct timeval'. */
43 #if (defined _MSC_VER || @REPLACE_STRUCT_TIMEVAL@) && @HAVE_WINSOCK2_H@ && !defined _GL_INCLUDING_WINSOCK2_H
44 # define _GL_INCLUDING_WINSOCK2_H
45 # include <winsock2.h>
46 # undef _GL_INCLUDING_WINSOCK2_H
49 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
51 /* The definition of _GL_ARG_NONNULL is copied here. */
53 /* The definition of _GL_WARN_ON_USE is copied here. */
59 #if !@HAVE_STRUCT_TIMEVAL@ || @REPLACE_STRUCT_TIMEVAL@
61 # if @REPLACE_STRUCT_TIMEVAL@
62 # define timeval rpl_timeval
65 # if !GNULIB_defined_struct_timeval
71 # define GNULIB_defined_struct_timeval 1
80 #if @GNULIB_GETTIMEOFDAY@
81 # if @REPLACE_GETTIMEOFDAY@
82 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
84 # define gettimeofday rpl_gettimeofday
86 _GL_FUNCDECL_RPL (gettimeofday
, int,
87 (struct timeval
*restrict
, void *restrict
)
88 _GL_ARG_NONNULL ((1)));
89 _GL_CXXALIAS_RPL (gettimeofday
, int,
90 (struct timeval
*restrict
, void *restrict
));
92 # if !@HAVE_GETTIMEOFDAY@
93 _GL_FUNCDECL_SYS (gettimeofday
, int,
94 (struct timeval
*restrict
, void *restrict
)
95 _GL_ARG_NONNULL ((1)));
97 /* Need to cast, because on glibc systems, by default, the second argument is
99 _GL_CXXALIAS_SYS_CAST (gettimeofday
, int,
100 (struct timeval
*restrict
, void *restrict
));
102 _GL_CXXALIASWARN (gettimeofday
);
103 #elif defined GNULIB_POSIXCHECK
105 # if HAVE_RAW_DECL_GETTIMEOFDAY
106 _GL_WARN_ON_USE (gettimeofday
, "gettimeofday is unportable - "
107 "use gnulib module gettimeofday for portability");
111 /* Hide some function declarations from <winsock2.h>. */
113 #if defined _MSC_VER && @HAVE_WINSOCK2_H@
114 # if !defined _@GUARD_PREFIX@_UNISTD_H
115 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
117 # define close close_used_without_including_unistd_h
119 _GL_WARN_ON_USE (close
,
120 "close() used without including <unistd.h>");
122 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
124 # define gethostname gethostname_used_without_including_unistd_h
126 _GL_WARN_ON_USE (gethostname
,
127 "gethostname() used without including <unistd.h>");
130 # if !defined _@GUARD_PREFIX@_SYS_SOCKET_H
131 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
133 # define socket socket_used_without_including_sys_socket_h
135 # define connect connect_used_without_including_sys_socket_h
137 # define accept accept_used_without_including_sys_socket_h
139 # define bind bind_used_without_including_sys_socket_h
141 # define getpeername getpeername_used_without_including_sys_socket_h
143 # define getsockname getsockname_used_without_including_sys_socket_h
145 # define getsockopt getsockopt_used_without_including_sys_socket_h
147 # define listen listen_used_without_including_sys_socket_h
149 # define recv recv_used_without_including_sys_socket_h
151 # define send send_used_without_including_sys_socket_h
153 # define recvfrom recvfrom_used_without_including_sys_socket_h
155 # define sendto sendto_used_without_including_sys_socket_h
157 # define setsockopt setsockopt_used_without_including_sys_socket_h
159 # define shutdown shutdown_used_without_including_sys_socket_h
161 _GL_WARN_ON_USE (socket
,
162 "socket() used without including <sys/socket.h>");
163 _GL_WARN_ON_USE (connect
,
164 "connect() used without including <sys/socket.h>");
165 _GL_WARN_ON_USE (accept
,
166 "accept() used without including <sys/socket.h>");
167 _GL_WARN_ON_USE (bind
,
168 "bind() used without including <sys/socket.h>");
169 _GL_WARN_ON_USE (getpeername
,
170 "getpeername() used without including <sys/socket.h>");
171 _GL_WARN_ON_USE (getsockname
,
172 "getsockname() used without including <sys/socket.h>");
173 _GL_WARN_ON_USE (getsockopt
,
174 "getsockopt() used without including <sys/socket.h>");
175 _GL_WARN_ON_USE (listen
,
176 "listen() used without including <sys/socket.h>");
177 _GL_WARN_ON_USE (recv
,
178 "recv() used without including <sys/socket.h>");
179 _GL_WARN_ON_USE (send
,
180 "send() used without including <sys/socket.h>");
181 _GL_WARN_ON_USE (recvfrom
,
182 "recvfrom() used without including <sys/socket.h>");
183 _GL_WARN_ON_USE (sendto
,
184 "sendto() used without including <sys/socket.h>");
185 _GL_WARN_ON_USE (setsockopt
,
186 "setsockopt() used without including <sys/socket.h>");
187 _GL_WARN_ON_USE (shutdown
,
188 "shutdown() used without including <sys/socket.h>");
191 # if !defined _@GUARD_PREFIX@_SYS_SELECT_H
192 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
194 # define select select_used_without_including_sys_select_h
196 _GL_WARN_ON_USE (select
,
197 "select() used without including <sys/select.h>");
202 #endif /* _@GUARD_PREFIX@_SYS_TIME_H */
203 #endif /* _@GUARD_PREFIX@_SYS_TIME_H */