Commit | Line | Data |
---|---|---|
49114fd4 LC |
1 | /* Provide a more complete sys/time.h. |
2 | ||
af07e104 | 3 | Copyright (C) 2007-2013 Free Software Foundation, Inc. |
49114fd4 LC |
4 | |
5 | This program is free software; you can redistribute it and/or modify | |
6 | it under the terms of the GNU Lesser General Public License as published by | |
7 | the Free Software Foundation; either version 2, or (at your option) | |
8 | any later version. | |
9 | ||
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 Lesser General Public License for more details. | |
14 | ||
15 | You should have received a copy of the GNU Lesser General Public License | |
005de2e8 | 16 | along with this program; if not, see <http://www.gnu.org/licenses/>. */ |
49114fd4 LC |
17 | |
18 | /* Written by Paul Eggert. */ | |
19 | ||
af07e104 AW |
20 | #ifndef _@GUARD_PREFIX@_SYS_TIME_H |
21 | ||
49114fd4 LC |
22 | #if __GNUC__ >= 3 |
23 | @PRAGMA_SYSTEM_HEADER@ | |
24 | #endif | |
25 | @PRAGMA_COLUMNS@ | |
26 | ||
af07e104 AW |
27 | /* The include_next requires a split double-inclusion guard. */ |
28 | #if @HAVE_SYS_TIME_H@ | |
29 | # @INCLUDE_NEXT@ @NEXT_SYS_TIME_H@ | |
30 | #endif | |
49114fd4 | 31 | |
af07e104 AW |
32 | #ifndef _@GUARD_PREFIX@_SYS_TIME_H |
33 | #define _@GUARD_PREFIX@_SYS_TIME_H | |
49114fd4 | 34 | |
af07e104 AW |
35 | #if ! @HAVE_SYS_TIME_H@ |
36 | # include <time.h> | |
37 | #endif | |
49114fd4 | 38 | |
005de2e8 LC |
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'. */ | |
af07e104 AW |
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 | |
47 | #endif | |
35428fb6 | 48 | |
49114fd4 LC |
49 | /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ |
50 | ||
51 | /* The definition of _GL_ARG_NONNULL is copied here. */ | |
52 | ||
53 | /* The definition of _GL_WARN_ON_USE is copied here. */ | |
54 | ||
af07e104 | 55 | #ifdef __cplusplus |
49114fd4 | 56 | extern "C" { |
af07e104 | 57 | #endif |
49114fd4 | 58 | |
af07e104 | 59 | #if !@HAVE_STRUCT_TIMEVAL@ || @REPLACE_STRUCT_TIMEVAL@ |
005de2e8 | 60 | |
af07e104 AW |
61 | # if @REPLACE_STRUCT_TIMEVAL@ |
62 | # define timeval rpl_timeval | |
63 | # endif | |
49114fd4 | 64 | |
af07e104 | 65 | # if !GNULIB_defined_struct_timeval |
49114fd4 LC |
66 | struct timeval |
67 | { | |
68 | time_t tv_sec; | |
69 | long int tv_usec; | |
70 | }; | |
af07e104 | 71 | # define GNULIB_defined_struct_timeval 1 |
49114fd4 LC |
72 | # endif |
73 | ||
af07e104 AW |
74 | #endif |
75 | ||
76 | #ifdef __cplusplus | |
49114fd4 | 77 | } |
af07e104 | 78 | #endif |
49114fd4 | 79 | |
af07e104 AW |
80 | #if @GNULIB_GETTIMEOFDAY@ |
81 | # if @REPLACE_GETTIMEOFDAY@ | |
82 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
83 | # undef gettimeofday | |
84 | # define gettimeofday rpl_gettimeofday | |
85 | # endif | |
49114fd4 LC |
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)); | |
af07e104 AW |
91 | # else |
92 | # if !@HAVE_GETTIMEOFDAY@ | |
49114fd4 LC |
93 | _GL_FUNCDECL_SYS (gettimeofday, int, |
94 | (struct timeval *restrict, void *restrict) | |
95 | _GL_ARG_NONNULL ((1))); | |
af07e104 | 96 | # endif |
49114fd4 LC |
97 | /* Need to cast, because on glibc systems, by default, the second argument is |
98 | struct timezone *. */ | |
99 | _GL_CXXALIAS_SYS_CAST (gettimeofday, int, | |
100 | (struct timeval *restrict, void *restrict)); | |
af07e104 | 101 | # endif |
49114fd4 | 102 | _GL_CXXALIASWARN (gettimeofday); |
af07e104 AW |
103 | #elif defined GNULIB_POSIXCHECK |
104 | # undef gettimeofday | |
105 | # if HAVE_RAW_DECL_GETTIMEOFDAY | |
49114fd4 LC |
106 | _GL_WARN_ON_USE (gettimeofday, "gettimeofday is unportable - " |
107 | "use gnulib module gettimeofday for portability"); | |
49114fd4 | 108 | # endif |
af07e104 | 109 | #endif |
49114fd4 | 110 | |
35428fb6 LC |
111 | /* Hide some function declarations from <winsock2.h>. */ |
112 | ||
af07e104 AW |
113 | #if defined _MSC_VER && @HAVE_WINSOCK2_H@ |
114 | # if !defined _@GUARD_PREFIX@_UNISTD_H | |
115 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
116 | # undef close | |
117 | # define close close_used_without_including_unistd_h | |
118 | # else | |
35428fb6 LC |
119 | _GL_WARN_ON_USE (close, |
120 | "close() used without including <unistd.h>"); | |
af07e104 AW |
121 | # endif |
122 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
123 | # undef gethostname | |
124 | # define gethostname gethostname_used_without_including_unistd_h | |
125 | # else | |
35428fb6 LC |
126 | _GL_WARN_ON_USE (gethostname, |
127 | "gethostname() used without including <unistd.h>"); | |
35428fb6 | 128 | # endif |
af07e104 AW |
129 | # endif |
130 | # if !defined _@GUARD_PREFIX@_SYS_SOCKET_H | |
131 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
132 | # undef socket | |
133 | # define socket socket_used_without_including_sys_socket_h | |
134 | # undef connect | |
135 | # define connect connect_used_without_including_sys_socket_h | |
136 | # undef accept | |
137 | # define accept accept_used_without_including_sys_socket_h | |
138 | # undef bind | |
139 | # define bind bind_used_without_including_sys_socket_h | |
140 | # undef getpeername | |
141 | # define getpeername getpeername_used_without_including_sys_socket_h | |
142 | # undef getsockname | |
143 | # define getsockname getsockname_used_without_including_sys_socket_h | |
144 | # undef getsockopt | |
145 | # define getsockopt getsockopt_used_without_including_sys_socket_h | |
146 | # undef listen | |
147 | # define listen listen_used_without_including_sys_socket_h | |
148 | # undef recv | |
149 | # define recv recv_used_without_including_sys_socket_h | |
150 | # undef send | |
151 | # define send send_used_without_including_sys_socket_h | |
152 | # undef recvfrom | |
153 | # define recvfrom recvfrom_used_without_including_sys_socket_h | |
154 | # undef sendto | |
155 | # define sendto sendto_used_without_including_sys_socket_h | |
156 | # undef setsockopt | |
157 | # define setsockopt setsockopt_used_without_including_sys_socket_h | |
158 | # undef shutdown | |
159 | # define shutdown shutdown_used_without_including_sys_socket_h | |
160 | # else | |
35428fb6 LC |
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>"); | |
35428fb6 | 189 | # endif |
af07e104 AW |
190 | # endif |
191 | # if !defined _@GUARD_PREFIX@_SYS_SELECT_H | |
192 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | |
193 | # undef select | |
194 | # define select select_used_without_including_sys_select_h | |
195 | # else | |
35428fb6 LC |
196 | _GL_WARN_ON_USE (select, |
197 | "select() used without including <sys/select.h>"); | |
35428fb6 LC |
198 | # endif |
199 | # endif | |
af07e104 | 200 | #endif |
35428fb6 | 201 | |
3d458a81 | 202 | #endif /* _@GUARD_PREFIX@_SYS_TIME_H */ |
af07e104 | 203 | #endif /* _@GUARD_PREFIX@_SYS_TIME_H */ |