Convert emit-linear-dispatch to use match
[bpt/guile.git] / lib / sys_time.in.h
CommitLineData
49114fd4
LC
1/* Provide a more complete sys/time.h.
2
5e69ceb7 3 Copyright (C) 2007-2014 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
5e69ceb7
MW
27/* On Cygwin and on many BSDish systems, <sys/time.h> includes itself
28 recursively via <sys/select.h>.
29 Simply delegate to the system's header in this case; it is a no-op.
30 Without this extra ifdef, the C++ gettimeofday declaration below
31 would be a forward declaration in gnulib's nested <sys/time.h>. */
32#if defined _CYGWIN_SYS_TIME_H || defined _SYS_TIME_H || defined _SYS_TIME_H_
33# @INCLUDE_NEXT@ @NEXT_SYS_TIME_H@
34#else
35
af07e104
AW
36/* The include_next requires a split double-inclusion guard. */
37#if @HAVE_SYS_TIME_H@
38# @INCLUDE_NEXT@ @NEXT_SYS_TIME_H@
39#endif
49114fd4 40
af07e104
AW
41#ifndef _@GUARD_PREFIX@_SYS_TIME_H
42#define _@GUARD_PREFIX@_SYS_TIME_H
49114fd4 43
af07e104
AW
44#if ! @HAVE_SYS_TIME_H@
45# include <time.h>
46#endif
49114fd4 47
005de2e8
LC
48/* On native Windows with MSVC, get the 'struct timeval' type.
49 Also, on native Windows with a 64-bit time_t, where we are overriding the
50 'struct timeval' type, get all declarations of system functions whose
51 signature contains 'struct timeval'. */
af07e104
AW
52#if (defined _MSC_VER || @REPLACE_STRUCT_TIMEVAL@) && @HAVE_WINSOCK2_H@ && !defined _GL_INCLUDING_WINSOCK2_H
53# define _GL_INCLUDING_WINSOCK2_H
54# include <winsock2.h>
55# undef _GL_INCLUDING_WINSOCK2_H
56#endif
35428fb6 57
49114fd4
LC
58/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
59
60/* The definition of _GL_ARG_NONNULL is copied here. */
61
62/* The definition of _GL_WARN_ON_USE is copied here. */
63
af07e104 64#ifdef __cplusplus
49114fd4 65extern "C" {
af07e104 66#endif
49114fd4 67
af07e104 68#if !@HAVE_STRUCT_TIMEVAL@ || @REPLACE_STRUCT_TIMEVAL@
005de2e8 69
af07e104
AW
70# if @REPLACE_STRUCT_TIMEVAL@
71# define timeval rpl_timeval
72# endif
49114fd4 73
af07e104 74# if !GNULIB_defined_struct_timeval
49114fd4
LC
75struct timeval
76{
77 time_t tv_sec;
78 long int tv_usec;
79};
af07e104 80# define GNULIB_defined_struct_timeval 1
49114fd4
LC
81# endif
82
af07e104
AW
83#endif
84
85#ifdef __cplusplus
49114fd4 86}
af07e104 87#endif
49114fd4 88
af07e104
AW
89#if @GNULIB_GETTIMEOFDAY@
90# if @REPLACE_GETTIMEOFDAY@
91# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
92# undef gettimeofday
93# define gettimeofday rpl_gettimeofday
94# endif
49114fd4
LC
95_GL_FUNCDECL_RPL (gettimeofday, int,
96 (struct timeval *restrict, void *restrict)
97 _GL_ARG_NONNULL ((1)));
98_GL_CXXALIAS_RPL (gettimeofday, int,
99 (struct timeval *restrict, void *restrict));
af07e104
AW
100# else
101# if !@HAVE_GETTIMEOFDAY@
49114fd4
LC
102_GL_FUNCDECL_SYS (gettimeofday, int,
103 (struct timeval *restrict, void *restrict)
104 _GL_ARG_NONNULL ((1)));
af07e104 105# endif
49114fd4
LC
106/* Need to cast, because on glibc systems, by default, the second argument is
107 struct timezone *. */
108_GL_CXXALIAS_SYS_CAST (gettimeofday, int,
109 (struct timeval *restrict, void *restrict));
af07e104 110# endif
49114fd4 111_GL_CXXALIASWARN (gettimeofday);
af07e104
AW
112#elif defined GNULIB_POSIXCHECK
113# undef gettimeofday
114# if HAVE_RAW_DECL_GETTIMEOFDAY
49114fd4
LC
115_GL_WARN_ON_USE (gettimeofday, "gettimeofday is unportable - "
116 "use gnulib module gettimeofday for portability");
49114fd4 117# endif
af07e104 118#endif
49114fd4 119
35428fb6
LC
120/* Hide some function declarations from <winsock2.h>. */
121
af07e104
AW
122#if defined _MSC_VER && @HAVE_WINSOCK2_H@
123# if !defined _@GUARD_PREFIX@_UNISTD_H
124# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
125# undef close
126# define close close_used_without_including_unistd_h
127# else
35428fb6
LC
128 _GL_WARN_ON_USE (close,
129 "close() used without including <unistd.h>");
af07e104
AW
130# endif
131# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
132# undef gethostname
133# define gethostname gethostname_used_without_including_unistd_h
134# else
35428fb6
LC
135 _GL_WARN_ON_USE (gethostname,
136 "gethostname() used without including <unistd.h>");
35428fb6 137# endif
af07e104
AW
138# endif
139# if !defined _@GUARD_PREFIX@_SYS_SOCKET_H
140# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
141# undef socket
142# define socket socket_used_without_including_sys_socket_h
143# undef connect
144# define connect connect_used_without_including_sys_socket_h
145# undef accept
146# define accept accept_used_without_including_sys_socket_h
147# undef bind
148# define bind bind_used_without_including_sys_socket_h
149# undef getpeername
150# define getpeername getpeername_used_without_including_sys_socket_h
151# undef getsockname
152# define getsockname getsockname_used_without_including_sys_socket_h
153# undef getsockopt
154# define getsockopt getsockopt_used_without_including_sys_socket_h
155# undef listen
156# define listen listen_used_without_including_sys_socket_h
157# undef recv
158# define recv recv_used_without_including_sys_socket_h
159# undef send
160# define send send_used_without_including_sys_socket_h
161# undef recvfrom
162# define recvfrom recvfrom_used_without_including_sys_socket_h
163# undef sendto
164# define sendto sendto_used_without_including_sys_socket_h
165# undef setsockopt
166# define setsockopt setsockopt_used_without_including_sys_socket_h
167# undef shutdown
168# define shutdown shutdown_used_without_including_sys_socket_h
169# else
35428fb6
LC
170 _GL_WARN_ON_USE (socket,
171 "socket() used without including <sys/socket.h>");
172 _GL_WARN_ON_USE (connect,
173 "connect() used without including <sys/socket.h>");
174 _GL_WARN_ON_USE (accept,
175 "accept() used without including <sys/socket.h>");
176 _GL_WARN_ON_USE (bind,
177 "bind() used without including <sys/socket.h>");
178 _GL_WARN_ON_USE (getpeername,
179 "getpeername() used without including <sys/socket.h>");
180 _GL_WARN_ON_USE (getsockname,
181 "getsockname() used without including <sys/socket.h>");
182 _GL_WARN_ON_USE (getsockopt,
183 "getsockopt() used without including <sys/socket.h>");
184 _GL_WARN_ON_USE (listen,
185 "listen() used without including <sys/socket.h>");
186 _GL_WARN_ON_USE (recv,
187 "recv() used without including <sys/socket.h>");
188 _GL_WARN_ON_USE (send,
189 "send() used without including <sys/socket.h>");
190 _GL_WARN_ON_USE (recvfrom,
191 "recvfrom() used without including <sys/socket.h>");
192 _GL_WARN_ON_USE (sendto,
193 "sendto() used without including <sys/socket.h>");
194 _GL_WARN_ON_USE (setsockopt,
195 "setsockopt() used without including <sys/socket.h>");
196 _GL_WARN_ON_USE (shutdown,
197 "shutdown() used without including <sys/socket.h>");
35428fb6 198# endif
af07e104
AW
199# endif
200# if !defined _@GUARD_PREFIX@_SYS_SELECT_H
201# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
202# undef select
203# define select select_used_without_including_sys_select_h
204# else
35428fb6
LC
205 _GL_WARN_ON_USE (select,
206 "select() used without including <sys/select.h>");
35428fb6
LC
207# endif
208# endif
af07e104 209#endif
35428fb6 210
3d458a81 211#endif /* _@GUARD_PREFIX@_SYS_TIME_H */
5e69ceb7 212#endif /* _CYGWIN_SYS_TIME_H */
af07e104 213#endif /* _@GUARD_PREFIX@_SYS_TIME_H */