comparison lib/sys_time.in.h @ 17303:0e38241a3d05

sys_time: port to Solaris 2.6 There is a circularity problem on Solaris 2.6, where <time.h> includes <sys/time.h> for struct timespec. The include nesting is gnulib <time.h>, system <time.h>, gnulib <sys/time.h>, system <sys/time.h>, gnulib <sys/types.h>, system <sys/types.h>, gnulib <sys/select.h>, gnulib <signal.h>, system <sys/signal.h>, system <sys/siginfo.h>; the last, innermost file needs struct timestruc_t, which is defined in <sys/time.h>, which has not been fully parsed. Problem reported by Tom G. Christensen in <http://lists.gnu.org/archive/html/bug-gnulib/2013-01/msg00113.html>. * lib/sys_select.in.h: Treat Solaris 2.6's problem with <sys/time.h> and <sys/types.h> like OSF/1's similar problem. * lib/sys_time.in.h: Redo to resemble sys_select.in.h, which uses split double-inclusion guards.
author Paul Eggert <eggert@cs.ucla.edu>
date Wed, 30 Jan 2013 21:26:44 -0800
parents e542fd46ad6f
children 5a51fb7777a9
comparison
equal deleted inserted replaced
17302:0e5a583a2a8d 17303:0e38241a3d05
15 You should have received a copy of the GNU General Public License 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/>. */ 16 along with this program; if not, see <http://www.gnu.org/licenses/>. */
17 17
18 /* Written by Paul Eggert. */ 18 /* Written by Paul Eggert. */
19 19
20 #ifndef _@GUARD_PREFIX@_SYS_TIME_H
21
20 #if __GNUC__ >= 3 22 #if __GNUC__ >= 3
21 @PRAGMA_SYSTEM_HEADER@ 23 @PRAGMA_SYSTEM_HEADER@
22 #endif 24 #endif
23 @PRAGMA_COLUMNS@ 25 @PRAGMA_COLUMNS@
24 26
25 #if defined _@GUARD_PREFIX@_SYS_TIME_H 27 /* The include_next requires a split double-inclusion guard. */
26 28 #if @HAVE_SYS_TIME_H@
27 /* Simply delegate to the system's header, without adding anything. */ 29 # @INCLUDE_NEXT@ @NEXT_SYS_TIME_H@
28 # if @HAVE_SYS_TIME_H@ 30 #endif
29 # @INCLUDE_NEXT@ @NEXT_SYS_TIME_H@ 31
30 # endif 32 #ifndef _@GUARD_PREFIX@_SYS_TIME_H
31 33 #define _@GUARD_PREFIX@_SYS_TIME_H
32 #else 34
33 35 #if ! @HAVE_SYS_TIME_H@
34 # define _@GUARD_PREFIX@_SYS_TIME_H 36 # include <time.h>
35 37 #endif
36 # if @HAVE_SYS_TIME_H@
37 # @INCLUDE_NEXT@ @NEXT_SYS_TIME_H@
38 # else
39 # include <time.h>
40 # endif
41 38
42 /* On native Windows with MSVC, get the 'struct timeval' type. 39 /* 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 40 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 41 'struct timeval' type, get all declarations of system functions whose
45 signature contains 'struct timeval'. */ 42 signature contains 'struct timeval'. */
46 # if (defined _MSC_VER || @REPLACE_STRUCT_TIMEVAL@) && @HAVE_WINSOCK2_H@ && !defined _GL_INCLUDING_WINSOCK2_H 43 #if (defined _MSC_VER || @REPLACE_STRUCT_TIMEVAL@) && @HAVE_WINSOCK2_H@ && !defined _GL_INCLUDING_WINSOCK2_H
47 # define _GL_INCLUDING_WINSOCK2_H 44 # define _GL_INCLUDING_WINSOCK2_H
48 # include <winsock2.h> 45 # include <winsock2.h>
49 # undef _GL_INCLUDING_WINSOCK2_H 46 # undef _GL_INCLUDING_WINSOCK2_H
50 # endif 47 #endif
51 48
52 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ 49 /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
53 50
54 /* The definition of _GL_ARG_NONNULL is copied here. */ 51 /* The definition of _GL_ARG_NONNULL is copied here. */
55 52
56 /* The definition of _GL_WARN_ON_USE is copied here. */ 53 /* The definition of _GL_WARN_ON_USE is copied here. */
57 54
58 # ifdef __cplusplus 55 #ifdef __cplusplus
59 extern "C" { 56 extern "C" {
60 # endif 57 #endif
61 58
62 # if !@HAVE_STRUCT_TIMEVAL@ || @REPLACE_STRUCT_TIMEVAL@ 59 #if !@HAVE_STRUCT_TIMEVAL@ || @REPLACE_STRUCT_TIMEVAL@
63 60
64 # if @REPLACE_STRUCT_TIMEVAL@ 61 # if @REPLACE_STRUCT_TIMEVAL@
65 # define timeval rpl_timeval 62 # define timeval rpl_timeval
66 # endif 63 # endif
67 64
68 # if !GNULIB_defined_struct_timeval 65 # if !GNULIB_defined_struct_timeval
69 struct timeval 66 struct timeval
70 { 67 {
71 time_t tv_sec; 68 time_t tv_sec;
72 long int tv_usec; 69 long int tv_usec;
73 }; 70 };
74 # define GNULIB_defined_struct_timeval 1 71 # define GNULIB_defined_struct_timeval 1
75 # endif 72 # endif
76 73
77 # endif 74 #endif
78 75
79 # ifdef __cplusplus 76 #ifdef __cplusplus
80 } 77 }
81 # endif 78 #endif
82 79
83 # if @GNULIB_GETTIMEOFDAY@ 80 #if @GNULIB_GETTIMEOFDAY@
84 # if @REPLACE_GETTIMEOFDAY@ 81 # if @REPLACE_GETTIMEOFDAY@
85 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 82 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
86 # undef gettimeofday 83 # undef gettimeofday
87 # define gettimeofday rpl_gettimeofday 84 # define gettimeofday rpl_gettimeofday
88 # endif 85 # endif
89 _GL_FUNCDECL_RPL (gettimeofday, int, 86 _GL_FUNCDECL_RPL (gettimeofday, int,
90 (struct timeval *restrict, void *restrict) 87 (struct timeval *restrict, void *restrict)
91 _GL_ARG_NONNULL ((1))); 88 _GL_ARG_NONNULL ((1)));
92 _GL_CXXALIAS_RPL (gettimeofday, int, 89 _GL_CXXALIAS_RPL (gettimeofday, int,
93 (struct timeval *restrict, void *restrict)); 90 (struct timeval *restrict, void *restrict));
94 # else 91 # else
95 # if !@HAVE_GETTIMEOFDAY@ 92 # if !@HAVE_GETTIMEOFDAY@
96 _GL_FUNCDECL_SYS (gettimeofday, int, 93 _GL_FUNCDECL_SYS (gettimeofday, int,
97 (struct timeval *restrict, void *restrict) 94 (struct timeval *restrict, void *restrict)
98 _GL_ARG_NONNULL ((1))); 95 _GL_ARG_NONNULL ((1)));
99 # endif 96 # endif
100 /* Need to cast, because on glibc systems, by default, the second argument is 97 /* Need to cast, because on glibc systems, by default, the second argument is
101 struct timezone *. */ 98 struct timezone *. */
102 _GL_CXXALIAS_SYS_CAST (gettimeofday, int, 99 _GL_CXXALIAS_SYS_CAST (gettimeofday, int,
103 (struct timeval *restrict, void *restrict)); 100 (struct timeval *restrict, void *restrict));
104 # endif 101 # endif
105 _GL_CXXALIASWARN (gettimeofday); 102 _GL_CXXALIASWARN (gettimeofday);
106 # elif defined GNULIB_POSIXCHECK 103 #elif defined GNULIB_POSIXCHECK
107 # undef gettimeofday 104 # undef gettimeofday
108 # if HAVE_RAW_DECL_GETTIMEOFDAY 105 # if HAVE_RAW_DECL_GETTIMEOFDAY
109 _GL_WARN_ON_USE (gettimeofday, "gettimeofday is unportable - " 106 _GL_WARN_ON_USE (gettimeofday, "gettimeofday is unportable - "
110 "use gnulib module gettimeofday for portability"); 107 "use gnulib module gettimeofday for portability");
111 # endif 108 # endif
112 # endif 109 #endif
113 110
114 /* Hide some function declarations from <winsock2.h>. */ 111 /* Hide some function declarations from <winsock2.h>. */
115 112
116 # if defined _MSC_VER && @HAVE_WINSOCK2_H@ 113 #if defined _MSC_VER && @HAVE_WINSOCK2_H@
117 # if !defined _@GUARD_PREFIX@_UNISTD_H 114 # if !defined _@GUARD_PREFIX@_UNISTD_H
118 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 115 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
119 # undef close 116 # undef close
120 # define close close_used_without_including_unistd_h 117 # define close close_used_without_including_unistd_h
121 # else 118 # else
122 _GL_WARN_ON_USE (close, 119 _GL_WARN_ON_USE (close,
123 "close() used without including <unistd.h>"); 120 "close() used without including <unistd.h>");
124 # endif 121 # endif
125 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 122 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
126 # undef gethostname 123 # undef gethostname
127 # define gethostname gethostname_used_without_including_unistd_h 124 # define gethostname gethostname_used_without_including_unistd_h
128 # else 125 # else
129 _GL_WARN_ON_USE (gethostname, 126 _GL_WARN_ON_USE (gethostname,
130 "gethostname() used without including <unistd.h>"); 127 "gethostname() used without including <unistd.h>");
131 # endif 128 # endif
132 # endif 129 # endif
133 # if !defined _@GUARD_PREFIX@_SYS_SOCKET_H 130 # if !defined _@GUARD_PREFIX@_SYS_SOCKET_H
134 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 131 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
135 # undef socket 132 # undef socket
136 # define socket socket_used_without_including_sys_socket_h 133 # define socket socket_used_without_including_sys_socket_h
137 # undef connect 134 # undef connect
138 # define connect connect_used_without_including_sys_socket_h 135 # define connect connect_used_without_including_sys_socket_h
139 # undef accept 136 # undef accept
140 # define accept accept_used_without_including_sys_socket_h 137 # define accept accept_used_without_including_sys_socket_h
141 # undef bind 138 # undef bind
142 # define bind bind_used_without_including_sys_socket_h 139 # define bind bind_used_without_including_sys_socket_h
143 # undef getpeername 140 # undef getpeername
144 # define getpeername getpeername_used_without_including_sys_socket_h 141 # define getpeername getpeername_used_without_including_sys_socket_h
145 # undef getsockname 142 # undef getsockname
146 # define getsockname getsockname_used_without_including_sys_socket_h 143 # define getsockname getsockname_used_without_including_sys_socket_h
147 # undef getsockopt 144 # undef getsockopt
148 # define getsockopt getsockopt_used_without_including_sys_socket_h 145 # define getsockopt getsockopt_used_without_including_sys_socket_h
149 # undef listen 146 # undef listen
150 # define listen listen_used_without_including_sys_socket_h 147 # define listen listen_used_without_including_sys_socket_h
151 # undef recv 148 # undef recv
152 # define recv recv_used_without_including_sys_socket_h 149 # define recv recv_used_without_including_sys_socket_h
153 # undef send 150 # undef send
154 # define send send_used_without_including_sys_socket_h 151 # define send send_used_without_including_sys_socket_h
155 # undef recvfrom 152 # undef recvfrom
156 # define recvfrom recvfrom_used_without_including_sys_socket_h 153 # define recvfrom recvfrom_used_without_including_sys_socket_h
157 # undef sendto 154 # undef sendto
158 # define sendto sendto_used_without_including_sys_socket_h 155 # define sendto sendto_used_without_including_sys_socket_h
159 # undef setsockopt 156 # undef setsockopt
160 # define setsockopt setsockopt_used_without_including_sys_socket_h 157 # define setsockopt setsockopt_used_without_including_sys_socket_h
161 # undef shutdown 158 # undef shutdown
162 # define shutdown shutdown_used_without_including_sys_socket_h 159 # define shutdown shutdown_used_without_including_sys_socket_h
163 # else 160 # else
164 _GL_WARN_ON_USE (socket, 161 _GL_WARN_ON_USE (socket,
165 "socket() used without including <sys/socket.h>"); 162 "socket() used without including <sys/socket.h>");
166 _GL_WARN_ON_USE (connect, 163 _GL_WARN_ON_USE (connect,
167 "connect() used without including <sys/socket.h>"); 164 "connect() used without including <sys/socket.h>");
168 _GL_WARN_ON_USE (accept, 165 _GL_WARN_ON_USE (accept,
187 "sendto() used without including <sys/socket.h>"); 184 "sendto() used without including <sys/socket.h>");
188 _GL_WARN_ON_USE (setsockopt, 185 _GL_WARN_ON_USE (setsockopt,
189 "setsockopt() used without including <sys/socket.h>"); 186 "setsockopt() used without including <sys/socket.h>");
190 _GL_WARN_ON_USE (shutdown, 187 _GL_WARN_ON_USE (shutdown,
191 "shutdown() used without including <sys/socket.h>"); 188 "shutdown() used without including <sys/socket.h>");
192 # endif 189 # endif
193 # endif 190 # endif
194 # if !defined _@GUARD_PREFIX@_SYS_SELECT_H 191 # if !defined _@GUARD_PREFIX@_SYS_SELECT_H
195 # if !(defined __cplusplus && defined GNULIB_NAMESPACE) 192 # if !(defined __cplusplus && defined GNULIB_NAMESPACE)
196 # undef select 193 # undef select
197 # define select select_used_without_including_sys_select_h 194 # define select select_used_without_including_sys_select_h
198 # else 195 # else
199 _GL_WARN_ON_USE (select, 196 _GL_WARN_ON_USE (select,
200 "select() used without including <sys/select.h>"); 197 "select() used without including <sys/select.h>");
201 # endif 198 # endif
202 # endif 199 # endif
203 # endif 200 #endif
204 201
205 #endif /* _@GUARD_PREFIX@_SYS_TIME_H */ 202 #endif /* _@GUARD_PREFIX@_SYS_TIME_H */
203 #endif /* _@GUARD_PREFIX@_SYS_TIME_H */