From owner-freebsd-threads@FreeBSD.ORG Wed May 28 18:51:31 2003 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 70DD437B401 for ; Wed, 28 May 2003 18:51:31 -0700 (PDT) Received: from exchhz01.viatech.com.cn (ip-167-164-97-218.anlai.com [218.97.164.167]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3CB7D43FA3 for ; Wed, 28 May 2003 18:51:29 -0700 (PDT) (envelope-from davidxu@viatech.com.cn) Received: from davidw2k (ip-240-1-168-192.rev.dyxnet.com [192.168.1.240]) by exchhz01.viatech.com.cn with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2650.21) id KD4SJD9L; Thu, 29 May 2003 09:35:42 +0800 Message-ID: <006b01c32585$28ca4ad0$f001a8c0@davidw2k> From: "David Xu" To: "Craig Rodrigues" , References: <20030528235120.GA3481@attbi.com> Date: Thu, 29 May 2003 09:53:54 +0800 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4807.1700 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300 Subject: Re: Question about OpenSSL id_function() and pthreads X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 May 2003 01:51:31 -0000 ----- Original Message -----=20 From: "Craig Rodrigues" To: Sent: Thursday, May 29, 2003 7:51 AM Subject: Question about OpenSSL id_function() and pthreads > Hi, >=20 > I previously asked this question on freebsd-security@ and > freebsd-current@ : >=20 > = http://docs.freebsd.org/cgi/getmsg.cgi?fetch=3D63674+0+archive/2003/freeb= sd-security/20030302.freebsd-security >=20 >=20 > Let me try again, now that there is a freebsd-threads mailing list. >=20 >=20 > On the following OpenSSL web page: > http://www.openssl.org/docs/crypto/threads.html >=20 > "void CRYPTO_set_id_callback(unsigned long (*id_function)(void)); >=20 > id_function(void) is a function that returns a thread ID.=20 > It is not needed on Windows nor on platforms where getpid() returns=20 > a different ID for each thread (most notably Linux)." >=20 >=20 > I have some third party C++ code which tries to implements this = function: >=20 > tatic unsigned long > idFunction() > { > #ifdef _WIN32 > return static_cast(GetCurrentThreadId()); > #else > return static_cast(pthread_self()); > #endif > } >=20 >=20 > This code does not compile on FreeBSD-CURRENT: >=20 > OpenSSLPluginI.cpp: In function `long unsigned int idFunction()': > OpenSSLPluginI.cpp:151: invalid static_cast from type `pthread*' to = type `long=20 > unsigned int' >=20 >=20 > How can I implement this function properly on FreeBSD? >=20 Why don't you change an abused static_cast to use C convertion directly like this: static unsigned long idFunction() { #ifdef _WIN32 return static_cast(GetCurrentThreadId()); #else return (unsigned long)pthread_self(); #endif } Don't be confused by mincing C++. David Xu