diff options
author | Louai Al-Khanji <louai.al-khanji@theqtcompany.com> | 2016-02-03 19:09:00 -0800 |
---|---|---|
committer | Louai Al-Khanji <louai.al-khanji@theqtcompany.com> | 2016-02-04 22:34:38 +0000 |
commit | bb747268ed89af8f034132fa46e30998b72a7ba9 (patch) | |
tree | 3516c7edfb90c3aab4a832945d8a8b8e12dfffe8 /src/corelib/kernel/qcore_unix_p.h | |
parent | e9802a10730345f734adff31a6c023690878c883 (diff) |
Clean up new poll code slightly
Change-Id: I046126ff69a77a50e79efb1b6ebb0fffef67ac8e
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.h | 19 |
1 files changed, 18 insertions, 1 deletions
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); |