1 #ifndef HEADER_CURL_SELECT_H
2 #define HEADER_CURL_SELECT_H
3 /***************************************************************************
5 * Project ___| | | | _ \| |
7 * | (__| |_| | _ <| |___
8 * \___|\___/|_| \_\_____|
10 * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
12 * This software is licensed as described in the file COPYING, which
13 * you should have received as part of this distribution. The terms
14 * are also available at https://curl.haxx.se/docs/copyright.html.
16 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
17 * copies of the Software, and permit persons to whom the Software is
18 * furnished to do so, under the terms of the COPYING file.
20 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 * KIND, either express or implied.
23 ***************************************************************************/
25 #include "curl_setup.h"
29 #elif defined(HAVE_SYS_POLL_H)
34 * Definition of pollfd struct and constants for platforms lacking them.
37 #if !defined(HAVE_STRUCT_POLLFD) && \
38 !defined(HAVE_SYS_POLL_H) && \
39 !defined(HAVE_POLL_H) && \
59 #define POLLRDNORM POLLIN
63 #define POLLWRNORM POLLOUT
67 #define POLLRDBAND POLLPRI
70 /* there are three CSELECT defines that are defined in the public header that
71 are exposed to users, but this *IN2 bit is only ever used internally and
72 therefore defined here */
73 #define CURL_CSELECT_IN2 (CURL_CSELECT_ERR << 1)
75 int Curl_socket_check(curl_socket_t readfd, curl_socket_t readfd2,
76 curl_socket_t writefd,
79 #define SOCKET_READABLE(x,z) \
80 Curl_socket_check(x, CURL_SOCKET_BAD, CURL_SOCKET_BAD, z)
81 #define SOCKET_WRITABLE(x,z) \
82 Curl_socket_check(CURL_SOCKET_BAD, CURL_SOCKET_BAD, x, z)
84 int Curl_poll(struct pollfd ufds[], unsigned int nfds, int timeout_ms);
86 /* On non-DOS and non-Winsock platforms, when Curl_ack_eintr is set,
87 * EINTR condition is honored and function might exit early without
88 * awaiting full timeout. Otherwise EINTR will be ignored and full
89 * timeout will elapse. */
90 extern int Curl_ack_eintr;
92 int Curl_wait_ms(int timeout_ms);
95 int tpf_select_libcurl(int maxfds, fd_set* reads, fd_set* writes,
96 fd_set* excepts, struct timeval* tv);
99 /* Winsock and TPF sockets are not in range [0..FD_SETSIZE-1], which
100 unfortunately makes it impossible for us to easily check if they're valid
102 #if defined(USE_WINSOCK) || defined(TPF)
103 #define VALID_SOCK(x) 1
104 #define VERIFY_SOCK(x) Curl_nop_stmt
106 #define VALID_SOCK(s) (((s) >= 0) && ((s) < FD_SETSIZE))
107 #define VERIFY_SOCK(x) do { \
108 if(!VALID_SOCK(x)) { \
109 SET_SOCKERRNO(EINVAL); \
115 #endif /* HEADER_CURL_SELECT_H */