From owner-freebsd-threads@FreeBSD.ORG Wed Oct 8 06:31:04 2008 Return-Path: Delivered-To: threads@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6E9941065687 for ; Wed, 8 Oct 2008 06:31:04 +0000 (UTC) (envelope-from deischen@freebsd.org) Received: from mail.netplex.net (mail.netplex.net [204.213.176.10]) by mx1.freebsd.org (Postfix) with ESMTP id 2CA168FC23 for ; Wed, 8 Oct 2008 06:31:04 +0000 (UTC) (envelope-from deischen@freebsd.org) Received: from sea.ntplx.net (sea.ntplx.net [204.213.176.11]) by mail.netplex.net (8.14.3/8.14.3/NETPLEX) with ESMTP id m986Ia7p015190; Wed, 8 Oct 2008 02:18:36 -0400 (EDT) X-Virus-Scanned: by AMaViS and Clam AntiVirus (mail.netplex.net) X-Greylist: Message whitelisted by DRAC access database, not delayed by milter-greylist-4.0 (mail.netplex.net [204.213.176.10]); Wed, 08 Oct 2008 02:18:36 -0400 (EDT) Date: Wed, 8 Oct 2008 02:18:36 -0400 (EDT) From: Daniel Eischen X-X-Sender: eischen@sea.ntplx.net To: Alfred Perlstein In-Reply-To: <20081008045447.GY36572@elvis.mu.org> Message-ID: References: <18668.10465.699531.162573@gromit.timing.com> <20081008045447.GY36572@elvis.mu.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: threads@freebsd.org, John Hein Subject: Re: pthread_cleanup_push & pthread_cleanup_pop usage X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Daniel Eischen List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Oct 2008 06:31:04 -0000 On Tue, 7 Oct 2008, Alfred Perlstein wrote: > * John Hein [081007 21:45] wrote: >> In June pthread_cleanup_push & pthread_cleanup_pop were changed to macros >> that look like so... > > Hey John, I found the same problem when working on QNX a while back, > however that is really how it's supposed to be set up. > > I would suggest the following construct to fix the problem, > make your own per-thread stack of destructors that are callable > as functions and not macros. > > It's not too hard to do. > > Just use a pthread_key and pthread_once thingy to write a library > to do it, shouldn't take more than a hundred lines of code. > > FWIW, OS X and QNX have the same set of macros, not sure about > other OSes. Solaris as well. Just conditionally undef them before you use them. #ifdef pthread_cleanup_push #undef pthread_cleanup_push #endif #ifdef pthread_cleanup_pop #undef pthread_cleanup_pop #endif The library versions are still there (they have to be in order to be callable from non-C/C++ languages). -- DE