From bb747268ed89af8f034132fa46e30998b72a7ba9 Mon Sep 17 00:00:00 2001 From: Louai Al-Khanji Date: Wed, 3 Feb 2016 19:09:00 -0800 Subject: Clean up new poll code slightly Change-Id: I046126ff69a77a50e79efb1b6ebb0fffef67ac8e Reviewed-by: Thiago Macieira --- src/corelib/kernel/qcore_unix_p.h | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src/corelib/kernel/qcore_unix_p.h') diff --git a/src/corelib/kernel/qcore_unix_p.h b/src/corelib/kernel/qcore_unix_p.h index 9ceee17055..96f791698f 100644 --- a/src/corelib/kernel/qcore_unix_p.h +++ b/src/corelib/kernel/qcore_unix_p.h @@ -326,7 +326,24 @@ void qt_nanosleep(timespec amount); Q_CORE_EXPORT int qt_safe_poll(struct pollfd *fds, nfds_t nfds, const struct timespec *timeout_ts); -int qt_poll_msecs(struct pollfd *fds, nfds_t nfds, int timeout); +static inline int qt_poll_msecs(struct pollfd *fds, nfds_t nfds, int timeout) +{ + timespec ts, *pts = Q_NULLPTR; + + if (timeout >= 0) { + ts.tv_sec = timeout / 1000; + ts.tv_nsec = (timeout % 1000) * 1000 * 1000; + pts = &ts; + } + + return qt_safe_poll(fds, nfds, pts); +} + +static inline struct pollfd qt_make_pollfd(int fd, short events) +{ + struct pollfd pfd = { fd, events, 0 }; + return pfd; +} Q_CORE_EXPORT int qt_safe_select(int nfds, fd_set *fdread, fd_set *fdwrite, fd_set *fdexcept, const struct timespec *tv); -- cgit v1.2.3