1 /* Provide a more complete sys/time.h.
3 Copyright (C) 2007-2012 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. */
21 @PRAGMA_SYSTEM_HEADER@
25 #if defined _@GUARD_PREFIX@_SYS_TIME_H
27 /* Simply delegate to the system's header, without adding anything. */
28 # if @HAVE_SYS_TIME_H@
29 # @INCLUDE_NEXT@ @NEXT_SYS_TIME_H@
34 # define _@GUARD_PREFIX@_SYS_TIME_H
36 # if @HAVE_SYS_TIME_H@
37 # @INCLUDE_NEXT@ @NEXT_SYS_TIME_H@
42 /* On native Windows with MSVC, get the 'struct timeval' type.
43 Also, on native Windows with a 64-bit time_t, where we are overriding the
44 'struct timeval' type, get all declarations of system functions whose
45 signature contains 'struct timeval'. */
46 # if (defined _MSC_VER || @REPLACE_STRUCT_TIMEVAL@) && @HAVE_WINSOCK2_H@ && !defined _GL_INCLUDING_WINSOCK2_H
47 # define _GL_INCLUDING_WINSOCK2_H
48 # include <winsock2.h>
49 # undef _GL_INCLUDING_WINSOCK2_H
52 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
54 /* The definition of _GL_ARG_NONNULL is copied here. */
56 /* The definition of _GL_WARN_ON_USE is copied here. */
62 # if !@HAVE_STRUCT_TIMEVAL@ || @REPLACE_STRUCT_TIMEVAL@
64 # if @REPLACE_STRUCT_TIMEVAL@
65 # define timeval rpl_timeval
68 # if !GNULIB_defined_struct_timeval
74 # define GNULIB_defined_struct_timeval 1
83 # if @GNULIB_GETTIMEOFDAY@
84 # if @REPLACE_GETTIMEOFDAY@
85 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
87 # define gettimeofday rpl_gettimeofday
89 _GL_FUNCDECL_RPL (gettimeofday, int,
90 (struct timeval *restrict, void *restrict)
91 _GL_ARG_NONNULL ((1)));
92 _GL_CXXALIAS_RPL (gettimeofday, int,
93 (struct timeval *restrict, void *restrict));
95 # if !@HAVE_GETTIMEOFDAY@
96 _GL_FUNCDECL_SYS (gettimeofday, int,
97 (struct timeval *restrict, void *restrict)
98 _GL_ARG_NONNULL ((1)));
100 /* Need to cast, because on glibc systems, by default, the second argument is
101 struct timezone *. */
102 _GL_CXXALIAS_SYS_CAST (gettimeofday, int,
103 (struct timeval *restrict, void *restrict));
105 _GL_CXXALIASWARN (gettimeofday);
106 # elif defined GNULIB_POSIXCHECK
108 # if HAVE_RAW_DECL_GETTIMEOFDAY
109 _GL_WARN_ON_USE (gettimeofday, "gettimeofday is unportable - "
110 "use gnulib module gettimeofday for portability");
114 /* Hide some function declarations from <winsock2.h>. */
116 # if defined _MSC_VER && @HAVE_WINSOCK2_H@
117 # if !defined _@GUARD_PREFIX@_UNISTD_H
118 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
120 # define close close_used_without_including_unistd_h
122 _GL_WARN_ON_USE (close,
123 "close() used without including <unistd.h>");
125 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
127 # define gethostname gethostname_used_without_including_unistd_h
129 _GL_WARN_ON_USE (gethostname,
130 "gethostname() used without including <unistd.h>");
133 # if !defined _@GUARD_PREFIX@_SYS_SOCKET_H
134 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
136 # define socket socket_used_without_including_sys_socket_h
138 # define connect connect_used_without_including_sys_socket_h
140 # define accept accept_used_without_including_sys_socket_h
142 # define bind bind_used_without_including_sys_socket_h
144 # define getpeername getpeername_used_without_including_sys_socket_h
146 # define getsockname getsockname_used_without_including_sys_socket_h
148 # define getsockopt getsockopt_used_without_including_sys_socket_h
150 # define listen listen_used_without_including_sys_socket_h
152 # define recv recv_used_without_including_sys_socket_h
154 # define send send_used_without_including_sys_socket_h
156 # define recvfrom recvfrom_used_without_including_sys_socket_h
158 # define sendto sendto_used_without_including_sys_socket_h
160 # define setsockopt setsockopt_used_without_including_sys_socket_h
162 # define shutdown shutdown_used_without_including_sys_socket_h
164 _GL_WARN_ON_USE (socket,
165 "socket() used without including <sys/socket.h>");
166 _GL_WARN_ON_USE (connect,
167 "connect() used without including <sys/socket.h>");
168 _GL_WARN_ON_USE (accept,
169 "accept() used without including <sys/socket.h>");
170 _GL_WARN_ON_USE (bind,
171 "bind() used without including <sys/socket.h>");
172 _GL_WARN_ON_USE (getpeername,
173 "getpeername() used without including <sys/socket.h>");
174 _GL_WARN_ON_USE (getsockname,
175 "getsockname() used without including <sys/socket.h>");
176 _GL_WARN_ON_USE (getsockopt,
177 "getsockopt() used without including <sys/socket.h>");
178 _GL_WARN_ON_USE (listen,
179 "listen() used without including <sys/socket.h>");
180 _GL_WARN_ON_USE (recv,
181 "recv() used without including <sys/socket.h>");
182 _GL_WARN_ON_USE (send,
183 "send() used without including <sys/socket.h>");
184 _GL_WARN_ON_USE (recvfrom,
185 "recvfrom() used without including <sys/socket.h>");
186 _GL_WARN_ON_USE (sendto,
187 "sendto() used without including <sys/socket.h>");
188 _GL_WARN_ON_USE (setsockopt,
189 "setsockopt() used without including <sys/socket.h>");
190 _GL_WARN_ON_USE (shutdown,
191 "shutdown() used without including <sys/socket.h>");
194 # if !defined _@GUARD_PREFIX@_SYS_SELECT_H
195 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
197 # define select select_used_without_including_sys_select_h
199 _GL_WARN_ON_USE (select,
200 "select() used without including <sys/select.h>");
205 #endif /* _@GUARD_PREFIX@_SYS_TIME_H */