Go Back   ZeroC Forums > Bug Reports

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 05-29-2003
rodrigc rodrigc is offline
Registered User
 
 
Join Date: Feb 2003
Location: Boston, MA, U.S.A.
Posts: 27
OpenSSLPluginI.cpp problem on FreeBSD-CURRENT

Hi,

I am using:
FreeBSD-CURRENT
gcc version 3.2.2 [FreeBSD] 20030205 (release)

On FreeBSD, pthread_t is a typedef for "struct pthread *"

When compiling IceSSL, I get this error:
OpenSSLPluginI.cpp: In function `long unsigned int idFunction()':
OpenSSLPluginI.cpp:151: invalid static_cast from type `pthread*' to type `long
unsigned int'

Why is a static_cast necessary for this code? If I change to a C-style cast,
the problem goes away:

--- OpenSSLPluginI.cpp.orig Wed May 28 17:58:00 2003
+++ OpenSSLPluginI.cpp Thu May 29 22:34:13 2003
@@ -148,7 +152,7 @@
#ifdef _WIN32
return static_cast<unsigned long>(GetCurrentThreadId());
#else
- return static_cast<unsigned long>(pthread_self());
+ return (unsigned long)pthread_self();
#endif
}
}
__________________
--
Craig Rodrigues
Reply With Quote
  #2 (permalink)  
Old 05-30-2003
bernard's Avatar
bernard bernard is offline
ZeroC Staff
 
Name: Bernard Normier
Organization: ZeroC, Inc.
Project: Ice
 
Join Date: Feb 2003
Location: Palm Beach Gardens, FL
Posts: 761
Hi Craig,

This code should use a conditional for each platform: pthread_t is an opaque type, and any "automatic" convertion to an integer is somewhat dangerous, as it could yield the same id for different threads on some platform.

On FreeBSD since pthread_t is a pointer to a per-thread structure, you can safely use reinterpret_cast<unsigned long>(pthread_self()).

On Tru64, for example, the correct code would be pthread_getsequence_np(pthread_self()).

Cheers,
Bernard
Reply With Quote
  #3 (permalink)  
Old 05-30-2003
rodrigc rodrigc is offline
Registered User
 
 
Join Date: Feb 2003
Location: Boston, MA, U.S.A.
Posts: 27
OK, then I submit this patch.

--- OpenSSLPluginI.cpp.orig Wed May 28 17:58:00 2003
+++ OpenSSLPluginI.cpp Fri May 30 08:51:42 2003
@@ -147,6 +151,8 @@
{
#ifdef _WIN32
return static_cast<unsigned long>(GetCurrentThreadId());
+#elif defined(__FreeBSD__)
+ return reinterpret_cast<unsigned long>(pthread_self());
#else
return static_cast<unsigned long>(pthread_self());
#endif
__________________
--
Craig Rodrigues
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
a problem about how to modify a value at the iterator’s current position! fw_csha Help Center 1 03-01-2005 10:34 AM
OpenSSLPluginI.cpp, invalid static cast on FreeBSD rodrigc Patches 0 02-27-2003 12:08 PM
Working on FreeBSD-CURRENT port rodrigc Patches 7 02-23-2003 09:58 PM
FreeBSD compilation problem: EPROTO undeclared rodrigc Bug Reports 1 02-22-2003 06:53 PM
FreeBSD compilation problem: pthread_t is not unsigned long rodrigc Bug Reports 2 02-22-2003 06:49 PM


All times are GMT -4. The time now is 10:48 AM.


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.