|
|
|
|||||
|
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 |
|
|||||
|
Re: FreeBSD compilation problem: pthread_t is not unsigned long
[quote]Originally posted by rodrigc
[b]Hi, 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, It is not a Linux-ism, the actual type of a thread id is implementation-dependent. So the above happens to work on Linux and Solaris but you have found that it doesn't work on openBSD. I know that the assumption also fails on HPUX. Regards, Andrew M.
__________________
You are in a maze of twisty little passages, all different. |
|
||||||
|
Unfortunately, there is not much we can do about this. OpenSSL assumes that a thread id can be mapped to an unsigned long:
void CRYPTO_set_id_callback(unsigned long (*id_function)(void)); See: http://www.openssl.org/docs/crypto/threads.html |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Icegridnode:long waiting problem | georgia419 | Help Center | 14 | 07-06-2006 08:21 AM |
| Compilation Problem with GCC | mykael | Help Center | 1 | 07-03-2006 04:06 AM |
| problem with c++ compilation | arnaud | Help Center | 4 | 04-21-2006 08:18 PM |
| OpenSSLPluginI.cpp problem on FreeBSD-CURRENT | rodrigc | Bug Reports | 2 | 05-30-2003 08:54 AM |
| FreeBSD compilation problem: EPROTO undeclared | rodrigc | Bug Reports | 1 | 02-22-2003 06:53 PM |