canonicalize-lgpl: fix // handling
[gnulib.git] / lib / sys_time.in.h
1 /* Provide a more complete sys/time.h.
2
3    Copyright (C) 2007-2012 Free Software Foundation, Inc.
4
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 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 General Public License for more details.
14
15    You should have received a copy of the GNU General Public License
16    along with this program; if not, write to the Free Software Foundation,
17    Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
18
19 /* Written by Paul Eggert.  */
20
21 #if __GNUC__ >= 3
22 @PRAGMA_SYSTEM_HEADER@
23 #endif
24 @PRAGMA_COLUMNS@
25
26 #if defined _@GUARD_PREFIX@_SYS_TIME_H
27
28 /* Simply delegate to the system's header, without adding anything.  */
29 # if @HAVE_SYS_TIME_H@
30 #  @INCLUDE_NEXT@ @NEXT_SYS_TIME_H@
31 # endif
32
33 #else
34
35 # define _@GUARD_PREFIX@_SYS_TIME_H
36
37 # if @HAVE_SYS_TIME_H@
38 #  @INCLUDE_NEXT@ @NEXT_SYS_TIME_H@
39 # else
40 #  include <time.h>
41 # endif
42
43 /* On native Windows with MSVC, get the 'struct timeval' type.
44    Also, on native Windows with a 64-bit time_t, where we are overriding the
45    'struct timeval' type, get all declarations of system functions whose
46    signature contains 'struct timeval'.  */
47 # if (defined _MSC_VER || @REPLACE_STRUCT_TIMEVAL@) && @HAVE_WINSOCK2_H@ && !defined _GL_INCLUDING_WINSOCK2_H
48 #  define _GL_INCLUDING_WINSOCK2_H
49 #  include <winsock2.h>
50 #  undef _GL_INCLUDING_WINSOCK2_H
51 # endif
52
53 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here.  */
54
55 /* The definition of _GL_ARG_NONNULL is copied here.  */
56
57 /* The definition of _GL_WARN_ON_USE is copied here.  */
58
59 # ifdef __cplusplus
60 extern "C" {
61 # endif
62
63 # if !@HAVE_STRUCT_TIMEVAL@ || @REPLACE_STRUCT_TIMEVAL@
64
65 #  if @REPLACE_STRUCT_TIMEVAL@
66 #   define timeval rpl_timeval
67 #  endif
68
69 #  if !GNULIB_defined_struct_timeval
70 struct timeval
71 {
72   time_t tv_sec;
73   long int tv_usec;
74 };
75 #   define GNULIB_defined_struct_timeval 1
76 #  endif
77
78 # endif
79
80 # ifdef __cplusplus
81 }
82 # endif
83
84 # if @GNULIB_GETTIMEOFDAY@
85 #  if @REPLACE_GETTIMEOFDAY@
86 #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
87 #    undef gettimeofday
88 #    define gettimeofday rpl_gettimeofday
89 #   endif
90 _GL_FUNCDECL_RPL (gettimeofday, int,
91                   (struct timeval *restrict, void *restrict)
92                   _GL_ARG_NONNULL ((1)));
93 _GL_CXXALIAS_RPL (gettimeofday, int,
94                   (struct timeval *restrict, void *restrict));
95 #  else
96 #   if !@HAVE_GETTIMEOFDAY@
97 _GL_FUNCDECL_SYS (gettimeofday, int,
98                   (struct timeval *restrict, void *restrict)
99                   _GL_ARG_NONNULL ((1)));
100 #   endif
101 /* Need to cast, because on glibc systems, by default, the second argument is
102                                                   struct timezone *.  */
103 _GL_CXXALIAS_SYS_CAST (gettimeofday, int,
104                        (struct timeval *restrict, void *restrict));
105 #  endif
106 _GL_CXXALIASWARN (gettimeofday);
107 # elif defined GNULIB_POSIXCHECK
108 #  undef gettimeofday
109 #  if HAVE_RAW_DECL_GETTIMEOFDAY
110 _GL_WARN_ON_USE (gettimeofday, "gettimeofday is unportable - "
111                  "use gnulib module gettimeofday for portability");
112 #  endif
113 # endif
114
115 /* Hide some function declarations from <winsock2.h>.  */
116
117 # if defined _MSC_VER && @HAVE_WINSOCK2_H@
118 #  if !defined _@GUARD_PREFIX@_UNISTD_H
119 #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
120 #    undef close
121 #    define close close_used_without_including_unistd_h
122 #   else
123      _GL_WARN_ON_USE (close,
124                       "close() used without including <unistd.h>");
125 #   endif
126 #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
127 #    undef gethostname
128 #    define gethostname gethostname_used_without_including_unistd_h
129 #   else
130      _GL_WARN_ON_USE (gethostname,
131                       "gethostname() used without including <unistd.h>");
132 #   endif
133 #  endif
134 #  if !defined _@GUARD_PREFIX@_SYS_SOCKET_H
135 #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
136 #    undef socket
137 #    define socket              socket_used_without_including_sys_socket_h
138 #    undef connect
139 #    define connect             connect_used_without_including_sys_socket_h
140 #    undef accept
141 #    define accept              accept_used_without_including_sys_socket_h
142 #    undef bind
143 #    define bind                bind_used_without_including_sys_socket_h
144 #    undef getpeername
145 #    define getpeername         getpeername_used_without_including_sys_socket_h
146 #    undef getsockname
147 #    define getsockname         getsockname_used_without_including_sys_socket_h
148 #    undef getsockopt
149 #    define getsockopt          getsockopt_used_without_including_sys_socket_h
150 #    undef listen
151 #    define listen              listen_used_without_including_sys_socket_h
152 #    undef recv
153 #    define recv                recv_used_without_including_sys_socket_h
154 #    undef send
155 #    define send                send_used_without_including_sys_socket_h
156 #    undef recvfrom
157 #    define recvfrom            recvfrom_used_without_including_sys_socket_h
158 #    undef sendto
159 #    define sendto              sendto_used_without_including_sys_socket_h
160 #    undef setsockopt
161 #    define setsockopt          setsockopt_used_without_including_sys_socket_h
162 #    undef shutdown
163 #    define shutdown            shutdown_used_without_including_sys_socket_h
164 #   else
165      _GL_WARN_ON_USE (socket,
166                       "socket() used without including <sys/socket.h>");
167      _GL_WARN_ON_USE (connect,
168                       "connect() used without including <sys/socket.h>");
169      _GL_WARN_ON_USE (accept,
170                       "accept() used without including <sys/socket.h>");
171      _GL_WARN_ON_USE (bind,
172                       "bind() used without including <sys/socket.h>");
173      _GL_WARN_ON_USE (getpeername,
174                       "getpeername() used without including <sys/socket.h>");
175      _GL_WARN_ON_USE (getsockname,
176                       "getsockname() used without including <sys/socket.h>");
177      _GL_WARN_ON_USE (getsockopt,
178                       "getsockopt() used without including <sys/socket.h>");
179      _GL_WARN_ON_USE (listen,
180                       "listen() used without including <sys/socket.h>");
181      _GL_WARN_ON_USE (recv,
182                       "recv() used without including <sys/socket.h>");
183      _GL_WARN_ON_USE (send,
184                       "send() used without including <sys/socket.h>");
185      _GL_WARN_ON_USE (recvfrom,
186                       "recvfrom() used without including <sys/socket.h>");
187      _GL_WARN_ON_USE (sendto,
188                       "sendto() used without including <sys/socket.h>");
189      _GL_WARN_ON_USE (setsockopt,
190                       "setsockopt() used without including <sys/socket.h>");
191      _GL_WARN_ON_USE (shutdown,
192                       "shutdown() used without including <sys/socket.h>");
193 #   endif
194 #  endif
195 #  if !defined _@GUARD_PREFIX@_SYS_SELECT_H
196 #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
197 #    undef select
198 #    define select select_used_without_including_sys_select_h
199 #   else
200      _GL_WARN_ON_USE (select,
201                       "select() used without including <sys/select.h>");
202 #   endif
203 #  endif
204 # endif
205
206 #endif /* _@GUARD_PREFIX@_SYS_TIME_H */