From 3b73ee0fb54c45e51e329614d18e667f7e751d41 Mon Sep 17 00:00:00 2001 From: Louai Al-Khanji Date: Wed, 3 Feb 2016 23:07:18 -0800 Subject: Remove qt_safe_select and qt_select_msecs Change-Id: If46228dc750554b65acd23e48410ec541fc33714 Reviewed-by: Thiago Macieira --- src/corelib/kernel/qcore_unix.cpp | 53 --------------------------------------- src/corelib/kernel/qcore_unix_p.h | 5 ---- 2 files changed, 58 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/kernel/qcore_unix.cpp b/src/corelib/kernel/qcore_unix.cpp index 23b98430bc..93af957d95 100644 --- a/src/corelib/kernel/qcore_unix.cpp +++ b/src/corelib/kernel/qcore_unix.cpp @@ -74,59 +74,6 @@ static inline bool time_update(struct timespec *tv, const struct timespec &start return tv->tv_sec >= 0; } -int qt_safe_select(int nfds, fd_set *fdread, fd_set *fdwrite, fd_set *fdexcept, - const struct timespec *orig_timeout) -{ - if (!orig_timeout) { - // no timeout -> block forever - int ret; - EINTR_LOOP(ret, select(nfds, fdread, fdwrite, fdexcept, 0)); - return ret; - } - - timespec start = qt_gettime(); - timespec timeout = *orig_timeout; - - // loop and recalculate the timeout as needed - int ret; - forever { -#ifndef Q_OS_QNX - ret = ::pselect(nfds, fdread, fdwrite, fdexcept, &timeout, 0); -#else - timeval timeoutVal = timespecToTimeval(timeout); - ret = ::select(nfds, fdread, fdwrite, fdexcept, &timeoutVal); -#endif - if (ret != -1 || errno != EINTR) - return ret; - - // recalculate the timeout - if (!time_update(&timeout, start, *orig_timeout)) { - // timeout during update - // or clock reset, fake timeout error - return 0; - } - } -} - -static inline struct timespec millisecsToTimespec(const unsigned int ms) -{ - struct timespec tv; - - tv.tv_sec = ms / 1000; - tv.tv_nsec = (ms % 1000) * 1000 * 1000; - - return tv; -} - -int qt_select_msecs(int nfds, fd_set *fdread, fd_set *fdwrite, int timeout) -{ - if (timeout < 0) - return qt_safe_select(nfds, fdread, fdwrite, 0, 0); - - struct timespec tv = millisecsToTimespec(timeout); - return qt_safe_select(nfds, fdread, fdwrite, 0, &tv); -} - #if !defined(QT_HAVE_PPOLL) && defined(QT_HAVE_POLL) static inline int timespecToMillisecs(const struct timespec *ts) { diff --git a/src/corelib/kernel/qcore_unix_p.h b/src/corelib/kernel/qcore_unix_p.h index 96f791698f..319914a99d 100644 --- a/src/corelib/kernel/qcore_unix_p.h +++ b/src/corelib/kernel/qcore_unix_p.h @@ -345,11 +345,6 @@ static inline struct pollfd qt_make_pollfd(int fd, short events) return pfd; } -Q_CORE_EXPORT int qt_safe_select(int nfds, fd_set *fdread, fd_set *fdwrite, fd_set *fdexcept, - const struct timespec *tv); - -int qt_select_msecs(int nfds, fd_set *fdread, fd_set *fdwrite, int timeout); - // according to X/OPEN we have to define semun ourselves // we use prefix as on some systems sem.h will have it struct semid_ds; -- cgit v1.2.3