7#include <rtems/rtems_bsdnet_internal.h>
12#define QT_POLL_READ_MASK (POLLIN
| POLLRDNORM
)
13#define QT_POLL_WRITE_MASK (POLLOUT
| POLLWRNORM
| POLLWRBAND
)
14#define QT_POLL_EXCEPT_MASK (POLLPRI
| POLLRDBAND
)
15#define QT_POLL_ERROR_MASK (POLLERR
| POLLNVAL
)
19 fd_set *read_fds, fd_set *write_fds, fd_set *except_fds)
27 for (nfds_t i = 0; i < nfds; i++) {
28 if (fds[i].fd >= FD_SETSIZE) {
37 FD_SET(fds[i].fd, read_fds);
40 FD_SET(fds[i].fd, write_fds);
43 FD_SET(fds[i].fd, except_fds);
46 max_fd = qMax(max_fd, fds[i].fd);
57 QT_EINTR_LOOP(res, ::recv(pfd.fd, &data,
sizeof(data), MSG_PEEK));
58 const int error = (res < 0) ? errno : 0;
61 pfd.revents |= POLLHUP;
62 }
else if (res > 0 || error == ENOTSOCK || error == ENOTCONN) {
70 pfd.revents |= POLLHUP;
73 pfd.revents |= POLLERR;
80 fd_set *read_fds, fd_set *write_fds, fd_set *except_fds)
84 for (nfds_t i = 0; i < nfds; i++) {
88 if (FD_ISSET(fds[i].fd, read_fds))
91 if (FD_ISSET(fds[i].fd, write_fds))
94 if (FD_ISSET(fds[i].fd, except_fds))
97 if (fds[i].revents != 0)
107 if (!rtems_bsdnet_fdToSocket(fd))
113 return (ret == -1 && errno == EBADF);
120 for (nfds_t i = 0; i < nfds; i++) {
128 fds[i].revents |= POLLNVAL;
136int qt_poll(
struct pollfd *fds, nfds_t nfds,
const struct timespec *timeout_ts)
143 fd_set read_fds, write_fds, except_fds;
144 struct timeval tv, *ptv =
nullptr;
153 for (nfds_t i = 0; i < nfds; i++) {
159 if (fds[i].fd > FD_SETSIZE) {
171 fds[i].revents = POLLNVAL;
177 const int max_fd = qt_poll_prepare(fds, nfds, &read_fds, &write_fds, &except_fds);
188 const int ret = ::select(max_fd, &read_fds, &write_fds, &except_fds, ptv);
194 return qt_poll_sweep(fds, nfds, &read_fds, &write_fds, &except_fds);
200 n_bad_fds += qt_poll_mark_bad_fds(fds, nfds);
Combined button and popup list for selecting options.
int qt_poll(struct pollfd *fds, nfds_t nfds, const struct timespec *timeout_ts)
#define QT_EINTR_LOOP(var, cmd)
timeval timespecToTimeval(timespec ts)
static int qt_poll_prepare(struct pollfd *fds, nfds_t nfds, fd_set *read_fds, fd_set *write_fds, fd_set *except_fds)
static void qt_poll_examine_ready_read(struct pollfd &pfd)
#define QT_POLL_READ_MASK
#define QT_POLL_ERROR_MASK
#define QT_POLL_EVENTS_MASK
#define QT_POLL_EXCEPT_MASK
static int qt_poll_mark_bad_fds(struct pollfd *fds, const nfds_t nfds)
static int qt_poll_sweep(struct pollfd *fds, nfds_t nfds, fd_set *read_fds, fd_set *write_fds, fd_set *except_fds)
static bool qt_poll_is_bad_fd(int fd)
#define QT_POLL_WRITE_MASK