summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qcore_unix_p.h
diff options
context:
space:
mode:
authorLouai Al-Khanji <louai.al-khanji@theqtcompany.com>2015-10-15 16:04:17 +0300
committerLouai Al-Khanji <louai.al-khanji@theqtcompany.com>2015-12-01 00:13:41 +0000
commit105fc117b70635dbeb921a5a74be75e44ac98fe2 (patch)
tree9f73791758528154a9a7dbb327dc0acefe1ae4b5 /src/corelib/kernel/qcore_unix_p.h
parentf9ba58a13baad7982600a84563b488f65581bfd9 (diff)
Add qt_safe_poll
This function is introduced to safely provide poll(2)-like semantics for socket multiplexing on Unix-like platforms. For platforms where no poll system call is available, an implementation based on select(2) is provided. Change-Id: I320e97dae5924316675a74d1897c48cae292ac6d Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/kernel/qcore_unix_p.h')
-rw-r--r--src/corelib/kernel/qcore_unix_p.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/corelib/kernel/qcore_unix_p.h b/src/corelib/kernel/qcore_unix_p.h
index d82b2651e7..d5434888d0 100644
--- a/src/corelib/kernel/qcore_unix_p.h
+++ b/src/corelib/kernel/qcore_unix_p.h
@@ -66,6 +66,28 @@
# include <ioLib.h>
#endif
+#ifndef QT_NO_NATIVE_POLL
+# include <poll.h>
+#else
+struct pollfd {
+ int fd;
+ short events, revents;
+};
+
+typedef unsigned long int nfds_t;
+
+# define POLLIN 0x001
+# define POLLPRI 0x002
+# define POLLOUT 0x004
+# define POLLERR 0x008
+# define POLLHUP 0x010
+# define POLLNVAL 0x020
+# define POLLRDNORM 0x040
+# define POLLRDBAND 0x080
+# define POLLWRNORM 0x100
+# define POLLWRBAND 0x200
+#endif
+
struct sockaddr;
#define EINTR_LOOP(var, cmd) \
@@ -303,6 +325,8 @@ static inline pid_t qt_safe_waitpid(pid_t pid, int *status, int options)
timespec qt_gettime() Q_DECL_NOTHROW;
void qt_nanosleep(timespec amount);
+Q_CORE_EXPORT int qt_safe_poll(struct pollfd *fds, nfds_t nfds, const struct timespec *timeout_ts);
+
Q_CORE_EXPORT int qt_safe_select(int nfds, fd_set *fdread, fd_set *fdwrite, fd_set *fdexcept,
const struct timespec *tv);