Portability fixes. Now builds on Linux 2.2 and 2.4 and solaris.

Also builds on i386, alpha, G3/G4, and sparc.
This commit is contained in:
crs 2003-01-08 21:36:14 +00:00
parent 0347bb1667
commit 7872c30111
3 changed files with 16 additions and 4 deletions

View File

@ -40,6 +40,7 @@ public:
public: public:
int m_refCount; int m_refCount;
IArchMultithread::ThreadID m_id;
pthread_t m_thread; pthread_t m_thread;
IArchMultithread::ThreadFunc m_func; IArchMultithread::ThreadFunc m_func;
void* m_userData; void* m_userData;
@ -51,6 +52,7 @@ public:
CArchThreadImpl::CArchThreadImpl() : CArchThreadImpl::CArchThreadImpl() :
m_refCount(1), m_refCount(1),
m_id(0),
m_func(NULL), m_func(NULL),
m_userData(NULL), m_userData(NULL),
m_cancel(false), m_cancel(false),
@ -69,7 +71,8 @@ CArchThreadImpl::CArchThreadImpl() :
CArchMultithreadPosix* CArchMultithreadPosix::s_instance = NULL; CArchMultithreadPosix* CArchMultithreadPosix::s_instance = NULL;
CArchMultithreadPosix::CArchMultithreadPosix() : CArchMultithreadPosix::CArchMultithreadPosix() :
m_newThreadCalled(false) m_newThreadCalled(false),
m_nextID(0)
{ {
assert(s_instance == NULL); assert(s_instance == NULL);
@ -505,6 +508,7 @@ bool
CArchMultithreadPosix::waitForEvent(double /*timeout*/) CArchMultithreadPosix::waitForEvent(double /*timeout*/)
{ {
// not implemented // not implemented
return false;
} }
bool bool
@ -534,7 +538,7 @@ CArchMultithreadPosix::getResultOfThread(CArchThread thread)
IArchMultithread::ThreadID IArchMultithread::ThreadID
CArchMultithreadPosix::getIDOfThread(CArchThread thread) CArchMultithreadPosix::getIDOfThread(CArchThread thread)
{ {
return reinterpret_cast<ThreadID>(reinterpret_cast<void*>(thread)); return thread->m_id;
} }
void void
@ -601,6 +605,12 @@ CArchMultithreadPosix::insert(CArchThreadImpl* thread)
// thread shouldn't already be on the list // thread shouldn't already be on the list
assert(findNoRef(thread->m_thread) == NULL); assert(findNoRef(thread->m_thread) == NULL);
// set thread id. note that we don't worry about m_nextID
// wrapping back to 0 and duplicating thread ID's since the
// likelihood of synergy running that long is vanishingly
// small.
thread->m_id = ++m_nextID;
// append to list // append to list
m_threadList.push_back(thread); m_threadList.push_back(thread);
} }

View File

@ -87,6 +87,7 @@ private:
CArchMutex m_threadMutex; CArchMutex m_threadMutex;
CArchThread m_mainThread; CArchThread m_mainThread;
CThreadList m_threadList; CThreadList m_threadList;
ThreadID m_nextID;
pthread_t m_signalThread; pthread_t m_signalThread;
}; };

View File

@ -641,8 +641,9 @@ CArchNetworkBSD::addrToName(CArchNetAddress addr)
// mutexed name lookup (ugh) // mutexed name lookup (ugh)
ARCH->lockMutex(m_mutex); ARCH->lockMutex(m_mutex);
struct hostent* info = gethostbyaddr(&addr->m_addr, addr->m_len, struct hostent* info = gethostbyaddr(
addr->m_addr.sa_family); reinterpret_cast<const char*>(&addr->m_addr),
addr->m_len, addr->m_addr.sa_family);
if (info == NULL) { if (info == NULL) {
ARCH->unlockMutex(m_mutex); ARCH->unlockMutex(m_mutex);
throwNameError(h_errno); throwNameError(h_errno);