|
FreeBSD compilation problem: pthread_t is not unsigned long
Hi,
I've got almost all of ICE compiled under FreeBSD-CURRENT.
I've encountered one problem though:
gmake[2]: Entering directory `/usr/home/rodrigc/ice/Ice-1.0.0/src/IceSSL'
c++ -c -I.. -I../../include -I/usr/local/include -g -ftemplate-depth-128 -fPI
C -Wall OpenSSLPluginI.cpp
OpenSSLPluginI.cpp: In function `long unsigned int IceSSL::idFunction()':
OpenSSLPluginI.cpp:151: invalid conversion from `pthread*' to `long unsigned
int'
gmake[2]: *** [OpenSSLPluginI.o] Error 1
The problem is caused by this code in OpenSSLPluginI.cpp:
unsigned long IceSSL::idFunction()
{
unsigned long threadID = 0;
#ifdef WINDOWS
threadID = GetCurrentThreadId();
#elif _POSIX_THREADS
threadID = pthread_self();
#else
#error You must define a method to return the current thread ID.
#endif
return threadID;
}
This code is taking advantage of a Linux-ism, where threads are actually
processes, and a pthread_t == pid_t. Unfortunately, pthread_t should
be treated as an opaque type, and should not be assumed to be an
an unsigned long. On FreeBSD, pthread_t is a typedef for
a pointer to struct pthread. struct pthread is a FreeBSD specific data structure.
My short term compilation fix is to do:
threadID = (unsigned long)pthread_self();
But this seems wrong....ie. this amounts to casting a pointer to a long,
which makes me shudder.
What is the intent of this code?
Thanks.
__________________
--
Craig Rodrigues
|