Results 1 to 3 of 3

Thread: OpenSSLPluginI.cpp problem on FreeBSD-CURRENT

  1. #1
    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

  2. #2
    bernard's Avatar
    bernard is offline ZeroC Staff
    Name: Bernard Normier
    Organization: ZeroC, Inc.
    Project: Ice
    Join Date
    Feb 2003
    Location
    Palm Beach Gardens, FL
    Posts
    1,294
    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

  3. #3
    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

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 1
    Last Post: 03-01-2005, 10:34 AM
  2. Replies: 0
    Last Post: 02-27-2003, 12:08 PM
  3. Working on FreeBSD-CURRENT port
    By rodrigc in forum Patches
    Replies: 7
    Last Post: 02-23-2003, 09:58 PM
  4. FreeBSD compilation problem: EPROTO undeclared
    By rodrigc in forum Bug Reports
    Replies: 1
    Last Post: 02-22-2003, 06:53 PM
  5. Replies: 3
    Last Post: 02-19-2003, 11:25 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •