From owner-freebsd-threads@FreeBSD.ORG Wed May 28 17:07:26 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 DB7DF37B404 for ; Wed, 28 May 2003 17:07:26 -0700 (PDT) Received: from mail.pcnet.com (mail.pcnet.com [204.213.232.4]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1FFE243F75 for ; Wed, 28 May 2003 17:07:26 -0700 (PDT) (envelope-from eischen@pcnet.com) Received: from mail.pcnet.com (mail.pcnet.com [204.213.232.4]) by mail.pcnet.com (8.12.8/8.12.1) with ESMTP id h4T07OMv001159; Wed, 28 May 2003 20:07:24 -0400 (EDT) Date: Wed, 28 May 2003 20:07:24 -0400 (EDT) From: Daniel Eischen To: Craig Rodrigues In-Reply-To: <20030528235120.GA3481@attbi.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: freebsd-threads@freebsd.org 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 00:07:27 -0000 On Wed, 28 May 2003, Craig Rodrigues wrote: > Hi, > > I previously asked this question on freebsd-security@ and > freebsd-current@ : > > http://docs.freebsd.org/cgi/getmsg.cgi?fetch=63674+0+archive/2003/freebsd-security/20030302.freebsd-security > > > Let me try again, now that there is a freebsd-threads mailing list. > > > On the following OpenSSL web page: > http://www.openssl.org/docs/crypto/threads.html > > "void CRYPTO_set_id_callback(unsigned long (*id_function)(void)); > > id_function(void) is a function that returns a thread ID. > It is not needed on Windows nor on platforms where getpid() returns > a different ID for each thread (most notably Linux)." > > > I have some third party C++ code which tries to implements this function: > > tatic unsigned long > idFunction() > { > #ifdef _WIN32 > return static_cast(GetCurrentThreadId()); > #else > return static_cast(pthread_self()); > #endif > } > > > This code does not compile on FreeBSD-CURRENT: > > OpenSSLPluginI.cpp: In function `long unsigned int idFunction()': > OpenSSLPluginI.cpp:151: invalid static_cast from type `pthread*' to type `long > unsigned int' I don't know C++ well (much at all). What does static_cast do? The error message makes it look as if you are converting a "pthread" * to "long unsigned int". Don't you just want "unsigned long" instead? > > How can I implement this function properly on FreeBSD? -- Dan Eischen