summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qcore_unix_p.h
diff options
context:
space:
mode:
authorLouai Al-Khanji <louai.al-khanji@theqtcompany.com>2015-12-02 17:22:32 -0800
committerLouai Al-Khanji <louai.al-khanji@theqtcompany.com>2015-12-05 00:47:36 +0000
commitf0a6d45cc8ca0b17838046c1c17efbc64773f2b5 (patch)
tree5ce13632dc05400b4c61ff817b01322111abde24 /src/corelib/kernel/qcore_unix_p.h
parentc456fb366a92cd08f6d2bf95b6974fea82340003 (diff)
qt_poll: split out into separate file and sanitize build
The qt_poll function calls recv to query whether fds marked by select as readable should be marked POLLIN or POLLHUP in the pollfd structure. On many platforms such as QNX this requires extra link-time libraries which were not previously required by QtCore. While the qt_poll function is intended as a fallback mechanism only for those platforms which do not implement poll natively, the function was compiled unconditionally whenever QT_BUILD_INTERNAL was defined, e.g. in developer builds. Additionally the function was included on those systems that define poll in system headers so that configure determines build-time availability, but do not define _POSIX_POLL > 0 or indicate POSIX:2008 compliance via either the _POSIX_VERSION or _XOPEN_VERSION macros. On those systems a sysconf query for _SC_POLL was performed to determine at runtime whether to call the system poll or qt_poll. Both of these cases are in fact counterproductive. In the first case the sole consumer of the function is a single manual unit test. In the second, to my knowledge no platform requires the runtime fallback. Despite that, we were forcing an extra dylib in both cases. Both cases are fixed by 1) moving the implementation into its own file for the unit test to include and 2) dropping the dynamic fallback if configure determines availability of poll at compile-time. This also reverts commit 13777097118c496391d4b9656b95097ac25e4a40, which added -lsocket for QtCore on QNX. Change-Id: I2dd10695c5d4cac81b68d2c2558797f3cdabc153 Reviewed-by: James McDonnell <jmcdonnell@qnx.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.h30
1 files changed, 11 insertions, 19 deletions
diff --git a/src/corelib/kernel/qcore_unix_p.h b/src/corelib/kernel/qcore_unix_p.h
index d5434888d0..fcc65589a0 100644
--- a/src/corelib/kernel/qcore_unix_p.h
+++ b/src/corelib/kernel/qcore_unix_p.h
@@ -66,26 +66,10 @@
# include <ioLib.h>
#endif
-#ifndef QT_NO_NATIVE_POLL
-# include <poll.h>
+#ifdef QT_NO_NATIVE_POLL
+# include "qpoll_p.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
+# include <poll.h>
#endif
struct sockaddr;
@@ -143,6 +127,14 @@ inline timespec operator*(const timespec &t1, int mul)
tmp.tv_nsec = t1.tv_nsec * mul;
return normalizedTimespec(tmp);
}
+inline timeval timespecToTimeval(const timespec &ts)
+{
+ timeval tv;
+ tv.tv_sec = ts.tv_sec;
+ tv.tv_usec = ts.tv_nsec / 1000;
+ return tv;
+}
+
inline void qt_ignore_sigpipe()
{