summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorJason Barron <jbarron@trolltech.com>2009-07-29 09:35:31 (GMT)
committerJason Barron <jbarron@trolltech.com>2009-07-29 09:35:31 (GMT)
commit55d72c2ffc857da3bdec78544d6f3d90dca19c7f (patch)
tree2fab8ff68f6313cd42b1b41f35fbf31d45847688 /src/corelib
parent7ee964bea3ba3ed31f36c8110789509edcbfbd54 (diff)
downloadQt-55d72c2ffc857da3bdec78544d6f3d90dca19c7f.zip
Qt-55d72c2ffc857da3bdec78544d6f3d90dca19c7f.tar.gz
Qt-55d72c2ffc857da3bdec78544d6f3d90dca19c7f.tar.bz2
Move the 'timeval' operators to qcore_unix_p.h.
Since these operators are also used by qcore_unix.cpp, it makes more sense to have them in qcore_unix_p.h so that these files can be compiled without a dependancy on the unix event dispatcher. Also remove some headers from the unix event dispatcher since the headers are already included in qcore_unix_p.h Reviewed-by: brad <bradley.hughes@nokia.com>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/kernel/qcore_unix.cpp2
-rw-r--r--src/corelib/kernel/qcore_unix_p.h45
-rw-r--r--src/corelib/kernel/qeventdispatcher_unix_p.h48
3 files changed, 46 insertions, 49 deletions
diff --git a/src/corelib/kernel/qcore_unix.cpp b/src/corelib/kernel/qcore_unix.cpp
index 0bc03cd..b57d385 100644
--- a/src/corelib/kernel/qcore_unix.cpp
+++ b/src/corelib/kernel/qcore_unix.cpp
@@ -50,8 +50,6 @@
#include <stdlib.h>
-#include "qeventdispatcher_unix_p.h" // for the timeval operators
-
#ifdef Q_OS_MAC
#include <mach/mach_time.h>
#endif
diff --git a/src/corelib/kernel/qcore_unix_p.h b/src/corelib/kernel/qcore_unix_p.h
index fb0e6a5..dceb73a 100644
--- a/src/corelib/kernel/qcore_unix_p.h
+++ b/src/corelib/kernel/qcore_unix_p.h
@@ -114,6 +114,51 @@ using namespace QT_PREPEND_NAMESPACE(QtLibcSupplement);
QT_BEGIN_NAMESPACE
+// Internal operator functions for timevals
+inline timeval &normalizedTimeval(timeval &t)
+{
+ while (t.tv_usec > 1000000l) {
+ ++t.tv_sec;
+ t.tv_usec -= 1000000l;
+ }
+ while (t.tv_usec < 0l) {
+ --t.tv_sec;
+ t.tv_usec += 1000000l;
+ }
+ return t;
+}
+inline bool operator<(const timeval &t1, const timeval &t2)
+{ return t1.tv_sec < t2.tv_sec || (t1.tv_sec == t2.tv_sec && t1.tv_usec < t2.tv_usec); }
+inline bool operator==(const timeval &t1, const timeval &t2)
+{ return t1.tv_sec == t2.tv_sec && t1.tv_usec == t2.tv_usec; }
+inline timeval &operator+=(timeval &t1, const timeval &t2)
+{
+ t1.tv_sec += t2.tv_sec;
+ t1.tv_usec += t2.tv_usec;
+ return normalizedTimeval(t1);
+}
+inline timeval operator+(const timeval &t1, const timeval &t2)
+{
+ timeval tmp;
+ tmp.tv_sec = t1.tv_sec + t2.tv_sec;
+ tmp.tv_usec = t1.tv_usec + t2.tv_usec;
+ return normalizedTimeval(tmp);
+}
+inline timeval operator-(const timeval &t1, const timeval &t2)
+{
+ timeval tmp;
+ tmp.tv_sec = t1.tv_sec - (t2.tv_sec - 1);
+ tmp.tv_usec = t1.tv_usec - (t2.tv_usec + 1000000);
+ return normalizedTimeval(tmp);
+}
+inline timeval operator*(const timeval &t1, int mul)
+{
+ timeval tmp;
+ tmp.tv_sec = t1.tv_sec * mul;
+ tmp.tv_usec = t1.tv_usec * mul;
+ return normalizedTimeval(tmp);
+}
+
// don't call QT_OPEN or ::open
// call qt_safe_open
static inline int qt_safe_open(const char *pathname, int flags, mode_t mode = 0777)
diff --git a/src/corelib/kernel/qeventdispatcher_unix_p.h b/src/corelib/kernel/qeventdispatcher_unix_p.h
index 30d566d..9c67c70 100644
--- a/src/corelib/kernel/qeventdispatcher_unix_p.h
+++ b/src/corelib/kernel/qeventdispatcher_unix_p.h
@@ -56,9 +56,9 @@
#include "QtCore/qabstracteventdispatcher.h"
#include "QtCore/qlist.h"
#include "private/qabstracteventdispatcher_p.h"
+#include "private/qcore_unix_p.h"
#include "private/qpodlist_p.h"
-#include <sys/types.h>
#if defined(Q_OS_VXWORKS)
# include <sys/times.h>
#else
@@ -67,58 +67,12 @@
# include <sys/select.h>
# endif
#endif
-#include <unistd.h>
QT_BEGIN_NAMESPACE
#if !defined(_POSIX_MONOTONIC_CLOCK)
# define _POSIX_MONOTONIC_CLOCK -1
#endif
-// Internal operator functions for timevals
-inline timeval &normalizedTimeval(timeval &t)
-{
- while (t.tv_usec > 1000000l) {
- ++t.tv_sec;
- t.tv_usec -= 1000000l;
- }
- while (t.tv_usec < 0l) {
- --t.tv_sec;
- t.tv_usec += 1000000l;
- }
- return t;
-}
-inline bool operator<(const timeval &t1, const timeval &t2)
-{ return t1.tv_sec < t2.tv_sec || (t1.tv_sec == t2.tv_sec && t1.tv_usec < t2.tv_usec); }
-inline bool operator==(const timeval &t1, const timeval &t2)
-{ return t1.tv_sec == t2.tv_sec && t1.tv_usec == t2.tv_usec; }
-inline timeval &operator+=(timeval &t1, const timeval &t2)
-{
- t1.tv_sec += t2.tv_sec;
- t1.tv_usec += t2.tv_usec;
- return normalizedTimeval(t1);
-}
-inline timeval operator+(const timeval &t1, const timeval &t2)
-{
- timeval tmp;
- tmp.tv_sec = t1.tv_sec + t2.tv_sec;
- tmp.tv_usec = t1.tv_usec + t2.tv_usec;
- return normalizedTimeval(tmp);
-}
-inline timeval operator-(const timeval &t1, const timeval &t2)
-{
- timeval tmp;
- tmp.tv_sec = t1.tv_sec - (t2.tv_sec - 1);
- tmp.tv_usec = t1.tv_usec - (t2.tv_usec + 1000000);
- return normalizedTimeval(tmp);
-}
-inline timeval operator*(const timeval &t1, int mul)
-{
- timeval tmp;
- tmp.tv_sec = t1.tv_sec * mul;
- tmp.tv_usec = t1.tv_usec * mul;
- return normalizedTimeval(tmp);
-}
-
// internal timer info
struct QTimerInfo {
int id; // - timer identifier