summaryrefslogtreecommitdiffstats
path: root/src/network
diff options
context:
space:
mode:
authorRobert Griebl <rgriebl@trolltech.com>2008-07-30 21:14:24 (GMT)
committerRobert Griebl <rgriebl@trolltech.com>2009-07-29 08:50:20 (GMT)
commitd7b688870aead912690188b324d370b920a7a600 (patch)
treeaac6c19d222ca3bad65cfbb850483a647013c67a /src/network
parente5262a0c29c743f2afd4ba249e8adff984c1ca83 (diff)
downloadQt-d7b688870aead912690188b324d370b920a7a600.zip
Qt-d7b688870aead912690188b324d370b920a7a600.tar.gz
Qt-d7b688870aead912690188b324d370b920a7a600.tar.bz2
Port of Qt to VxWorks
This makes Qt work on VxWorks 6.6+ in native (kernel) mode. * compiles with the WindRiver GNU toolchain (Linux only) * works with QWS (tested with the VNC driver only) * tested on PPC hardware and the x86 VxWorks simulator * no q3support, no phonon, no webkit * no QSharedMemory, no QSystemSemaphore, no QProcess * only one QApplication instance (flat address space) * filesystem support depends heavily on the quality of the native driver * QLibrary is just a dummy to make plugins work at all * qmake transparently creates VxWorks munching rules for static ctors * made auto-test cope with missing OS features A special note regarding the Q_FOREACH patch for dcc: when calling foreach(a,c) with c being a function returning a container, the compiler would generate 5 references to some labels (.LXXXX), which are not there (so the linker complains in the end). Seems like dcc doesn't really like the 'true ? 0 : <function call to get type>' statement Reviewed-By: Harald Fernengel
Diffstat (limited to 'src/network')
-rw-r--r--src/network/kernel/qhostinfo_unix.cpp11
-rw-r--r--src/network/socket/qlocalserver_unix.cpp4
-rw-r--r--src/network/socket/qlocalsocket_unix.cpp4
-rw-r--r--src/network/socket/qnativesocketengine_p.h4
-rw-r--r--src/network/socket/qnativesocketengine_unix.cpp27
-rw-r--r--src/network/socket/qnet_unix_p.h26
6 files changed, 61 insertions, 15 deletions
diff --git a/src/network/kernel/qhostinfo_unix.cpp b/src/network/kernel/qhostinfo_unix.cpp
index fef488b..64e9e29 100644
--- a/src/network/kernel/qhostinfo_unix.cpp
+++ b/src/network/kernel/qhostinfo_unix.cpp
@@ -57,7 +57,11 @@ static const int RESOLVER_TIMEOUT = 2000;
#include <sys/types.h>
#include <netdb.h>
#include <arpa/inet.h>
-#include <resolv.h>
+#if defined(Q_OS_VXWORKS)
+# include <hostLib.h>
+#else
+# include <resolv.h>
+#endif
#if defined (QT_NO_GETADDRINFO)
#include <qmutex.h>
@@ -275,10 +279,12 @@ QHostInfo QHostInfoAgent::fromName(const QString &hostName)
results.setError(QHostInfo::UnknownError);
results.setErrorString(tr("Unknown address type"));
}
+#if !defined(Q_OS_VXWORKS)
} else if (h_errno == HOST_NOT_FOUND || h_errno == NO_DATA
|| h_errno == NO_ADDRESS) {
results.setError(QHostInfo::HostNotFound);
results.setErrorString(tr("Host not found"));
+#endif
} else {
results.setError(QHostInfo::UnknownError);
results.setErrorString(tr("Unknown error"));
@@ -315,6 +321,7 @@ QString QHostInfo::localHostName()
QString QHostInfo::localDomainName()
{
+#if !defined(Q_OS_VXWORKS)
resolveLibrary();
if (local_res_ninit) {
// using thread-safe version
@@ -344,7 +351,7 @@ QString QHostInfo::localDomainName()
domainName = QUrl::fromAce(local_res->dnsrch[0]);
return domainName;
}
-
+#endif
// nothing worked, try doing it by ourselves:
QFile resolvconf;
#if defined(_PATH_RESCONF)
diff --git a/src/network/socket/qlocalserver_unix.cpp b/src/network/socket/qlocalserver_unix.cpp
index c2e05cd..3df6b6a 100644
--- a/src/network/socket/qlocalserver_unix.cpp
+++ b/src/network/socket/qlocalserver_unix.cpp
@@ -54,6 +54,10 @@
#include <qdir.h>
#include <qdatetime.h>
+#ifdef Q_OS_VXWORKS
+# include <selectLib.h>
+#endif
+
QT_BEGIN_NAMESPACE
void QLocalServerPrivate::init()
diff --git a/src/network/socket/qlocalsocket_unix.cpp b/src/network/socket/qlocalsocket_unix.cpp
index d038794..08d94ef 100644
--- a/src/network/socket/qlocalsocket_unix.cpp
+++ b/src/network/socket/qlocalsocket_unix.cpp
@@ -56,6 +56,10 @@
#include <qdir.h>
#include <qdebug.h>
+#ifdef Q_OS_VXWORKS
+# include <selectLib.h>
+#endif
+
#define QT_CONNECT_TIMEOUT 30000
QT_BEGIN_NAMESPACE
diff --git a/src/network/socket/qnativesocketengine_p.h b/src/network/socket/qnativesocketengine_p.h
index a9479d3..24dc344 100644
--- a/src/network/socket/qnativesocketengine_p.h
+++ b/src/network/socket/qnativesocketengine_p.h
@@ -56,9 +56,9 @@
#include "QtNetwork/qhostaddress.h"
#include "private/qabstractsocketengine_p.h"
#ifndef Q_OS_WIN
-# include "qplatformdefs.h"
+# include "qplatformdefs.h"
#else
-# include <winsock2.h>
+# include <winsock2.h>
#endif
QT_BEGIN_NAMESPACE
diff --git a/src/network/socket/qnativesocketengine_unix.cpp b/src/network/socket/qnativesocketengine_unix.cpp
index b4b673a..6f9ee1a 100644
--- a/src/network/socket/qnativesocketengine_unix.cpp
+++ b/src/network/socket/qnativesocketengine_unix.cpp
@@ -237,7 +237,7 @@ int QNativeSocketEnginePrivate::option(QNativeSocketEngine::SocketOption opt) co
int v = -1;
QT_SOCKOPTLEN_T len = sizeof(v);
- if (getsockopt(socketDescriptor, level, n, (char *) &v, &len) != -1)
+ if (::getsockopt(socketDescriptor, level, n, (char *) &v, &len) != -1)
return v;
return -1;
}
@@ -267,6 +267,7 @@ bool QNativeSocketEnginePrivate::setOption(QNativeSocketEngine::SocketOption opt
break;
case QNativeSocketEngine::NonBlockingSocketOption: {
// Make the socket nonblocking.
+#if !defined(Q_OS_VXWORKS)
int flags = ::fcntl(socketDescriptor, F_GETFL, 0);
if (flags == -1) {
#ifdef QNATIVESOCKETENGINE_DEBUG
@@ -280,7 +281,15 @@ bool QNativeSocketEnginePrivate::setOption(QNativeSocketEngine::SocketOption opt
#endif
return false;
}
-
+#else // Q_OS_VXWORKS
+ int onoff = 1;
+ if (qt_safe_ioctl(socketDescriptor, FIONBIO, &onoff) < 0) {
+#ifdef QNATIVESOCKETENGINE_DEBUG
+ perror("QNativeSocketEnginePrivate::setOption(): ioctl(FIONBIO, 1) failed");
+#endif
+ return false;
+ }
+#endif // Q_OS_VXWORKS
return true;
}
case QNativeSocketEngine::AddressReusable:
@@ -652,11 +661,8 @@ qint64 QNativeSocketEnginePrivate::nativeSendDatagram(const char *data, qint64 l
// ignore the SIGPIPE signal
qt_ignore_sigpipe();
- ssize_t sentBytes;
- do {
- sentBytes = qt_safe_sendto(socketDescriptor, data, len,
- 0, sockAddrPtr, sockAddrSize);
- } while (sentBytes == -1 && errno == EINTR);
+ ssize_t sentBytes = qt_safe_sendto(socketDescriptor, data, len,
+ 0, sockAddrPtr, sockAddrSize);
if (sentBytes < 0) {
switch (errno) {
@@ -722,7 +728,7 @@ bool QNativeSocketEnginePrivate::fetchConnectionParameters()
// Determine the socket type (UDP/TCP)
int value = 0;
QT_SOCKOPTLEN_T valueSize = sizeof(int);
- if (::getsockopt(socketDescriptor, SOL_SOCKET, SO_TYPE, &value, &valueSize) == 0) {
+ if (::getsockopt(socketDescriptor, SOL_SOCKET, SO_TYPE, (char *) &value, &valueSize) == 0) {
if (value == SOCK_STREAM)
socketType = QAbstractSocket::TcpSocket;
else if (value == SOCK_DGRAM)
@@ -767,7 +773,7 @@ qint64 QNativeSocketEnginePrivate::nativeWrite(const char *data, qint64 len)
// of an interrupting signal.
ssize_t writtenBytes;
do {
- writtenBytes = ::write(socketDescriptor, data, len);
+ writtenBytes = QT_WRITE(socketDescriptor, data, len);
} while (writtenBytes < 0 && errno == EINTR);
if (writtenBytes < 0) {
@@ -828,6 +834,9 @@ qint64 QNativeSocketEnginePrivate::nativeRead(char *data, qint64 maxSize)
setError(QAbstractSocket::NetworkError, ReadErrorString);
break;
case ECONNRESET:
+#if defined(Q_OS_VXWORKS)
+ case ESHUTDOWN:
+#endif
r = 0;
break;
default:
diff --git a/src/network/socket/qnet_unix_p.h b/src/network/socket/qnet_unix_p.h
index 03ed3b4..f38c2fc 100644
--- a/src/network/socket/qnet_unix_p.h
+++ b/src/network/socket/qnet_unix_p.h
@@ -59,11 +59,18 @@
#include <sys/socket.h>
#include <netinet/in.h>
+#if defined(Q_OS_VXWORKS)
+# include <sockLib.h>
+#endif
+
// for inet_addr
#include <netdb.h>
#include <arpa/inet.h>
-#include <resolv.h>
-
+#if defined(Q_OS_VXWORKS)
+# include <hostLib.h>
+#else
+# include <resolv.h>
+#endif
QT_BEGIN_NAMESPACE
@@ -155,17 +162,28 @@ static inline int qt_safe_connect(int sockfd, const struct sockaddr *addr, QT_SO
# undef listen
#endif
+// VxWorks' headers specify 'int' instead of '...' for the 3rd ioctl() parameter.
template <typename T>
static inline int qt_safe_ioctl(int sockfd, int request, T arg)
{
+#ifdef Q_OS_VXWORKS
+ return ::ioctl(sockfd, request, (int) arg);
+#else
return ::ioctl(sockfd, request, arg);
+#endif
}
+// VxWorks' headers do not specify any const modifiers
static inline in_addr_t qt_safe_inet_addr(const char *cp)
{
+#ifdef Q_OS_VXWORKS
+ return ::inet_addr((char *) cp);
+#else
return ::inet_addr(cp);
+#endif
}
+// VxWorks' headers do not specify any const modifiers
static inline int qt_safe_sendto(int sockfd, const void *buf, size_t len, int flags, const struct sockaddr *to, QT_SOCKLEN_T tolen)
{
#ifdef MSG_NOSIGNAL
@@ -173,7 +191,11 @@ static inline int qt_safe_sendto(int sockfd, const void *buf, size_t len, int fl
#endif
register int ret;
+#ifdef Q_OS_VXWORKS
+ EINTR_LOOP(ret, ::sendto(sockfd, (char *) buf, len, flags, (struct sockaddr *) to, tolen));
+#else
EINTR_LOOP(ret, ::sendto(sockfd, buf, len, flags, to, tolen));
+#endif
return ret;
}