diff options
| author | Paul Eggert | 2012-06-22 14:26:37 -0700 |
|---|---|---|
| committer | Paul Eggert | 2012-06-22 14:26:37 -0700 |
| commit | c8fff8630133fea7c4e279458d10d825e5028c62 (patch) | |
| tree | f8b8261fdf3596e1306a3d072e13ec572c9e3e65 /lib/sys_select.in.h | |
| parent | 36cec983d4e680e28e7066fda505910cd549f509 (diff) | |
| download | emacs-c8fff8630133fea7c4e279458d10d825e5028c62.tar.gz emacs-c8fff8630133fea7c4e279458d10d825e5028c62.zip | |
Add gnulib files to support higher-resolution time stamps.
Fixes: debbugs:9000
Diffstat (limited to 'lib/sys_select.in.h')
| -rw-r--r-- | lib/sys_select.in.h | 298 |
1 files changed, 298 insertions, 0 deletions
diff --git a/lib/sys_select.in.h b/lib/sys_select.in.h new file mode 100644 index 00000000000..0aee2a16cbf --- /dev/null +++ b/lib/sys_select.in.h | |||
| @@ -0,0 +1,298 @@ | |||
| 1 | /* Substitute for <sys/select.h>. | ||
| 2 | Copyright (C) 2007-2012 Free Software Foundation, Inc. | ||
| 3 | |||
| 4 | This program is free software; you can redistribute it and/or modify | ||
| 5 | it under the terms of the GNU General Public License as published by | ||
| 6 | the Free Software Foundation; either version 3, or (at your option) | ||
| 7 | any later version. | ||
| 8 | |||
| 9 | This program is distributed in the hope that it will be useful, | ||
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | GNU General Public License for more details. | ||
| 13 | |||
| 14 | You should have received a copy of the GNU General Public License | ||
| 15 | along with this program; if not, see <http://www.gnu.org/licenses/>. */ | ||
| 16 | |||
| 17 | # if __GNUC__ >= 3 | ||
| 18 | @PRAGMA_SYSTEM_HEADER@ | ||
| 19 | # endif | ||
| 20 | @PRAGMA_COLUMNS@ | ||
| 21 | |||
| 22 | /* On OSF/1, <sys/types.h> and <sys/time.h> include <sys/select.h>. | ||
| 23 | Simply delegate to the system's header in this case. */ | ||
| 24 | #if @HAVE_SYS_SELECT_H@ && defined __osf__ && (defined _SYS_TYPES_H_ && !defined _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TYPES_H) && defined _OSF_SOURCE | ||
| 25 | |||
| 26 | # define _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TYPES_H | ||
| 27 | # @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@ | ||
| 28 | |||
| 29 | #elif @HAVE_SYS_SELECT_H@ && defined __osf__ && (defined _SYS_TIME_H_ && !defined _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TIME_H) && defined _OSF_SOURCE | ||
| 30 | |||
| 31 | # define _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_TIME_H | ||
| 32 | # @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@ | ||
| 33 | |||
| 34 | /* On IRIX 6.5, <sys/timespec.h> includes <sys/types.h>, which includes | ||
| 35 | <sys/bsd_types.h>, which includes <sys/select.h>. At this point we cannot | ||
| 36 | include <signal.h>, because that includes <internal/signal_core.h>, which | ||
| 37 | gives a syntax error because <sys/timespec.h> has not been completely | ||
| 38 | processed. Simply delegate to the system's header in this case. */ | ||
| 39 | #elif @HAVE_SYS_SELECT_H@ && defined __sgi && (defined _SYS_BSD_TYPES_H && !defined _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_BSD_TYPES_H) | ||
| 40 | |||
| 41 | # define _GL_SYS_SELECT_H_REDIRECT_FROM_SYS_BSD_TYPES_H | ||
| 42 | # @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@ | ||
| 43 | |||
| 44 | /* On OpenBSD 5.0, <pthread.h> includes <sys/types.h>, which includes | ||
| 45 | <sys/select.h>. At this point we cannot include <signal.h>, because that | ||
| 46 | includes gnulib's pthread.h override, which gives a syntax error because | ||
| 47 | /usr/include/pthread.h has not been completely processed. Simply delegate | ||
| 48 | to the system's header in this case. */ | ||
| 49 | #elif @HAVE_SYS_SELECT_H@ && defined __OpenBSD__ && (defined _PTHREAD_H_ && !defined PTHREAD_MUTEX_INITIALIZER) | ||
| 50 | |||
| 51 | # @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@ | ||
| 52 | |||
| 53 | #else | ||
| 54 | |||
| 55 | #ifndef _@GUARD_PREFIX@_SYS_SELECT_H | ||
| 56 | |||
| 57 | /* On many platforms, <sys/select.h> assumes prior inclusion of | ||
| 58 | <sys/types.h>. Also, mingw defines sigset_t there, instead of | ||
| 59 | in <signal.h> where it belongs. */ | ||
| 60 | #include <sys/types.h> | ||
| 61 | |||
| 62 | #if @HAVE_SYS_SELECT_H@ | ||
| 63 | |||
| 64 | /* On OSF/1 4.0, <sys/select.h> provides only a forward declaration | ||
| 65 | of 'struct timeval', and no definition of this type. | ||
| 66 | Also, Mac OS X, AIX, HP-UX, IRIX, Solaris, Interix declare select() | ||
| 67 | in <sys/time.h>. | ||
| 68 | But avoid namespace pollution on glibc systems. */ | ||
| 69 | # ifndef __GLIBC__ | ||
| 70 | # include <sys/time.h> | ||
| 71 | # endif | ||
| 72 | |||
| 73 | /* On AIX 7 and Solaris 10, <sys/select.h> provides an FD_ZERO implementation | ||
| 74 | that relies on memset(), but without including <string.h>. | ||
| 75 | But in any case avoid namespace pollution on glibc systems. */ | ||
| 76 | # if (defined __OpenBSD__ || defined _AIX || defined __sun || defined __osf__ || defined __BEOS__) \ | ||
| 77 | && ! defined __GLIBC__ | ||
| 78 | # include <string.h> | ||
| 79 | # endif | ||
| 80 | |||
| 81 | /* The include_next requires a split double-inclusion guard. */ | ||
| 82 | # @INCLUDE_NEXT@ @NEXT_SYS_SELECT_H@ | ||
| 83 | |||
| 84 | #endif | ||
| 85 | |||
| 86 | /* Get definition of 'sigset_t'. | ||
| 87 | But avoid namespace pollution on glibc systems. | ||
| 88 | Do this after the include_next (for the sake of OpenBSD 5.0) but before | ||
| 89 | the split double-inclusion guard (for the sake of Solaris). */ | ||
| 90 | #if !(defined __GLIBC__ && !defined __UCLIBC__) | ||
| 91 | # include <signal.h> | ||
| 92 | #endif | ||
| 93 | |||
| 94 | #ifndef _@GUARD_PREFIX@_SYS_SELECT_H | ||
| 95 | #define _@GUARD_PREFIX@_SYS_SELECT_H | ||
| 96 | |||
| 97 | #if !@HAVE_SYS_SELECT_H@ | ||
| 98 | /* A platform that lacks <sys/select.h>. */ | ||
| 99 | /* Get the 'struct timeval' and 'fd_set' types and the FD_* macros | ||
| 100 | on most platforms. */ | ||
| 101 | # include <sys/time.h> | ||
| 102 | /* On HP-UX 11, <sys/time.h> provides an FD_ZERO implementation | ||
| 103 | that relies on memset(), but without including <string.h>. */ | ||
| 104 | # if defined __hpux | ||
| 105 | # include <string.h> | ||
| 106 | # endif | ||
| 107 | /* On native Windows platforms: | ||
| 108 | Get the 'fd_set' type. | ||
| 109 | Get the close() declaration before we override it. */ | ||
| 110 | # if @HAVE_WINSOCK2_H@ | ||
| 111 | # if !defined _GL_INCLUDING_WINSOCK2_H | ||
| 112 | # define _GL_INCLUDING_WINSOCK2_H | ||
| 113 | # include <winsock2.h> | ||
| 114 | # undef _GL_INCLUDING_WINSOCK2_H | ||
| 115 | # endif | ||
| 116 | # include <io.h> | ||
| 117 | # endif | ||
| 118 | #endif | ||
| 119 | |||
| 120 | /* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */ | ||
| 121 | |||
| 122 | /* The definition of _GL_WARN_ON_USE is copied here. */ | ||
| 123 | |||
| 124 | |||
| 125 | /* Fix some definitions from <winsock2.h>. */ | ||
| 126 | |||
| 127 | #if @HAVE_WINSOCK2_H@ | ||
| 128 | |||
| 129 | # if !GNULIB_defined_rpl_fd_isset | ||
| 130 | |||
| 131 | /* Re-define FD_ISSET to avoid a WSA call while we are not using | ||
| 132 | network sockets. */ | ||
| 133 | static inline int | ||
| 134 | rpl_fd_isset (SOCKET fd, fd_set * set) | ||
| 135 | { | ||
| 136 | u_int i; | ||
| 137 | if (set == NULL) | ||
| 138 | return 0; | ||
| 139 | |||
| 140 | for (i = 0; i < set->fd_count; i++) | ||
| 141 | if (set->fd_array[i] == fd) | ||
| 142 | return 1; | ||
| 143 | |||
| 144 | return 0; | ||
| 145 | } | ||
| 146 | |||
| 147 | # define GNULIB_defined_rpl_fd_isset 1 | ||
| 148 | # endif | ||
| 149 | |||
| 150 | # undef FD_ISSET | ||
| 151 | # define FD_ISSET(fd, set) rpl_fd_isset(fd, set) | ||
| 152 | |||
| 153 | #endif | ||
| 154 | |||
| 155 | /* Hide some function declarations from <winsock2.h>. */ | ||
| 156 | |||
| 157 | #if @HAVE_WINSOCK2_H@ | ||
| 158 | # if !defined _@GUARD_PREFIX@_UNISTD_H | ||
| 159 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
| 160 | # undef close | ||
| 161 | # define close close_used_without_including_unistd_h | ||
| 162 | # else | ||
| 163 | _GL_WARN_ON_USE (close, | ||
| 164 | "close() used without including <unistd.h>"); | ||
| 165 | # endif | ||
| 166 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
| 167 | # undef gethostname | ||
| 168 | # define gethostname gethostname_used_without_including_unistd_h | ||
| 169 | # else | ||
| 170 | _GL_WARN_ON_USE (gethostname, | ||
| 171 | "gethostname() used without including <unistd.h>"); | ||
| 172 | # endif | ||
| 173 | # endif | ||
| 174 | # if !defined _@GUARD_PREFIX@_SYS_SOCKET_H | ||
| 175 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
| 176 | # undef socket | ||
| 177 | # define socket socket_used_without_including_sys_socket_h | ||
| 178 | # undef connect | ||
| 179 | # define connect connect_used_without_including_sys_socket_h | ||
| 180 | # undef accept | ||
| 181 | # define accept accept_used_without_including_sys_socket_h | ||
| 182 | # undef bind | ||
| 183 | # define bind bind_used_without_including_sys_socket_h | ||
| 184 | # undef getpeername | ||
| 185 | # define getpeername getpeername_used_without_including_sys_socket_h | ||
| 186 | # undef getsockname | ||
| 187 | # define getsockname getsockname_used_without_including_sys_socket_h | ||
| 188 | # undef getsockopt | ||
| 189 | # define getsockopt getsockopt_used_without_including_sys_socket_h | ||
| 190 | # undef listen | ||
| 191 | # define listen listen_used_without_including_sys_socket_h | ||
| 192 | # undef recv | ||
| 193 | # define recv recv_used_without_including_sys_socket_h | ||
| 194 | # undef send | ||
| 195 | # define send send_used_without_including_sys_socket_h | ||
| 196 | # undef recvfrom | ||
| 197 | # define recvfrom recvfrom_used_without_including_sys_socket_h | ||
| 198 | # undef sendto | ||
| 199 | # define sendto sendto_used_without_including_sys_socket_h | ||
| 200 | # undef setsockopt | ||
| 201 | # define setsockopt setsockopt_used_without_including_sys_socket_h | ||
| 202 | # undef shutdown | ||
| 203 | # define shutdown shutdown_used_without_including_sys_socket_h | ||
| 204 | # else | ||
| 205 | _GL_WARN_ON_USE (socket, | ||
| 206 | "socket() used without including <sys/socket.h>"); | ||
| 207 | _GL_WARN_ON_USE (connect, | ||
| 208 | "connect() used without including <sys/socket.h>"); | ||
| 209 | _GL_WARN_ON_USE (accept, | ||
| 210 | "accept() used without including <sys/socket.h>"); | ||
| 211 | _GL_WARN_ON_USE (bind, | ||
| 212 | "bind() used without including <sys/socket.h>"); | ||
| 213 | _GL_WARN_ON_USE (getpeername, | ||
| 214 | "getpeername() used without including <sys/socket.h>"); | ||
| 215 | _GL_WARN_ON_USE (getsockname, | ||
| 216 | "getsockname() used without including <sys/socket.h>"); | ||
| 217 | _GL_WARN_ON_USE (getsockopt, | ||
| 218 | "getsockopt() used without including <sys/socket.h>"); | ||
| 219 | _GL_WARN_ON_USE (listen, | ||
| 220 | "listen() used without including <sys/socket.h>"); | ||
| 221 | _GL_WARN_ON_USE (recv, | ||
| 222 | "recv() used without including <sys/socket.h>"); | ||
| 223 | _GL_WARN_ON_USE (send, | ||
| 224 | "send() used without including <sys/socket.h>"); | ||
| 225 | _GL_WARN_ON_USE (recvfrom, | ||
| 226 | "recvfrom() used without including <sys/socket.h>"); | ||
| 227 | _GL_WARN_ON_USE (sendto, | ||
| 228 | "sendto() used without including <sys/socket.h>"); | ||
| 229 | _GL_WARN_ON_USE (setsockopt, | ||
| 230 | "setsockopt() used without including <sys/socket.h>"); | ||
| 231 | _GL_WARN_ON_USE (shutdown, | ||
| 232 | "shutdown() used without including <sys/socket.h>"); | ||
| 233 | # endif | ||
| 234 | # endif | ||
| 235 | #endif | ||
| 236 | |||
| 237 | |||
| 238 | #if @GNULIB_PSELECT@ | ||
| 239 | # if @REPLACE_PSELECT@ | ||
| 240 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
| 241 | # undef pselect | ||
| 242 | # define pselect rpl_pselect | ||
| 243 | # endif | ||
| 244 | _GL_FUNCDECL_RPL (pselect, int, | ||
| 245 | (int, fd_set *restrict, fd_set *restrict, fd_set *restrict, | ||
| 246 | struct timespec const *restrict, const sigset_t *restrict)); | ||
| 247 | _GL_CXXALIAS_RPL (pselect, int, | ||
| 248 | (int, fd_set *restrict, fd_set *restrict, fd_set *restrict, | ||
| 249 | struct timespec const *restrict, const sigset_t *restrict)); | ||
| 250 | # else | ||
| 251 | # if !@HAVE_PSELECT@ | ||
| 252 | _GL_FUNCDECL_SYS (pselect, int, | ||
| 253 | (int, fd_set *restrict, fd_set *restrict, fd_set *restrict, | ||
| 254 | struct timespec const *restrict, const sigset_t *restrict)); | ||
| 255 | # endif | ||
| 256 | _GL_CXXALIAS_SYS (pselect, int, | ||
| 257 | (int, fd_set *restrict, fd_set *restrict, fd_set *restrict, | ||
| 258 | struct timespec const *restrict, const sigset_t *restrict)); | ||
| 259 | # endif | ||
| 260 | _GL_CXXALIASWARN (pselect); | ||
| 261 | #elif defined GNULIB_POSIXCHECK | ||
| 262 | # undef pselect | ||
| 263 | # if HAVE_RAW_DECL_PSELECT | ||
| 264 | _GL_WARN_ON_USE (pselect, "pselect is not portable - " | ||
| 265 | "use gnulib module pselect for portability"); | ||
| 266 | # endif | ||
| 267 | #endif | ||
| 268 | |||
| 269 | #if @GNULIB_SELECT@ | ||
| 270 | # if @REPLACE_SELECT@ | ||
| 271 | # if !(defined __cplusplus && defined GNULIB_NAMESPACE) | ||
| 272 | # undef select | ||
| 273 | # define select rpl_select | ||
| 274 | # endif | ||
| 275 | _GL_FUNCDECL_RPL (select, int, | ||
| 276 | (int, fd_set *, fd_set *, fd_set *, struct timeval *)); | ||
| 277 | _GL_CXXALIAS_RPL (select, int, | ||
| 278 | (int, fd_set *, fd_set *, fd_set *, struct timeval *)); | ||
| 279 | # else | ||
| 280 | _GL_CXXALIAS_SYS (select, int, | ||
| 281 | (int, fd_set *, fd_set *, fd_set *, struct timeval *)); | ||
| 282 | # endif | ||
| 283 | _GL_CXXALIASWARN (select); | ||
| 284 | #elif @HAVE_WINSOCK2_H@ | ||
| 285 | # undef select | ||
| 286 | # define select select_used_without_requesting_gnulib_module_select | ||
| 287 | #elif defined GNULIB_POSIXCHECK | ||
| 288 | # undef select | ||
| 289 | # if HAVE_RAW_DECL_SELECT | ||
| 290 | _GL_WARN_ON_USE (select, "select is not always POSIX compliant - " | ||
| 291 | "use gnulib module select for portability"); | ||
| 292 | # endif | ||
| 293 | #endif | ||
| 294 | |||
| 295 | |||
| 296 | #endif /* _@GUARD_PREFIX@_SYS_SELECT_H */ | ||
| 297 | #endif /* _@GUARD_PREFIX@_SYS_SELECT_H */ | ||
| 298 | #endif /* OSF/1 */ | ||