Go Back   ZeroC Forums > Bug Reports

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 02-21-2003
rodrigc rodrigc is offline
Registered User
 
 
Join Date: Feb 2003
Location: Boston, MA, U.S.A.
Posts: 27
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
Reply With Quote
  #2 (permalink)  
Old 02-22-2003
marlowa marlowa is offline
Registered User
 
 
Join Date: Feb 2003
Location: London
Posts: 64
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.
Reply With Quote
  #3 (permalink)  
Old 02-22-2003
marc's Avatar
marc marc is offline
ZeroC Staff
 
Name: Marc Laukien
Organization: ZeroC, Inc.
Project: The Internet Communications Engine
 
Join Date: Feb 2003
Location: Florida
Posts: 1,780
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
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

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


All times are GMT -4. The time now is 07:43 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0
(c) 2008 ZeroC, Inc.