From owner-freebsd-threads@FreeBSD.ORG Sat May 31 01:49:33 2008 Return-Path: Delivered-To: freebsd-threads@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 952121065724; Sat, 31 May 2008 01:49:33 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (bigknife-pt.tunnel.tserv9.chi1.ipv6.he.net [IPv6:2001:470:1f10:75::2]) by mx1.freebsd.org (Postfix) with ESMTP id 32A3F8FC12; Sat, 31 May 2008 01:49:33 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from localhost.corp.yahoo.com (john@localhost [IPv6:::1]) (authenticated bits=0) by server.baldwin.cx (8.14.2/8.14.2) with ESMTP id m4V1nIoP030810; Fri, 30 May 2008 21:49:26 -0400 (EDT) (envelope-from jhb@freebsd.org) From: John Baldwin To: freebsd-threads@freebsd.org Date: Fri, 30 May 2008 21:45:49 -0400 User-Agent: KMail/1.9.7 References: <483FA1C0.2010506@freebsd.org> <20080530184141.GG48790@elvis.mu.org> In-Reply-To: <20080530184141.GG48790@elvis.mu.org> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200805302145.49524.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.0.2 (server.baldwin.cx [IPv6:::1]); Fri, 30 May 2008 21:49:27 -0400 (EDT) X-Virus-Scanned: ClamAV 0.91.2/7300/Fri May 30 19:42:28 2008 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-2.6 required=4.2 tests=AWL,BAYES_00,NO_RELAYS autolearn=ham version=3.1.3 X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on server.baldwin.cx Cc: David Xu Subject: Re: pthread_cleanup_push as a macro X-BeenThere: freebsd-threads@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Threading on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 31 May 2008 01:49:33 -0000 On Friday 30 May 2008 02:41:41 pm Alfred Perlstein wrote: > * David Xu [080529 23:40] wrote: > > I would like to make pthread_cleanup_push and pthread_cleanup_pop as a > > pair of macros, the current implementation has to malloc() and free() a > > pthread_cleanup memory block everytime, this is slow, the new one > > simply uses stack space, note that other OSes have already done it in > > this way. The patch keeps old functions and should not have binary > > compatible problem. > > > > http://people.freebsd.org/~davidxu/patch/pthread_cleanup_push.patch > > Heh, when I had to use QNX on a project this totally confused > me, but if others are doing it then go for it. > > Does Solaris do it? It's explicitly documented in the standard that push and pop may be implemented as macros and that they have to be paired at the same block level (i.e. it's permitted for push to start a new block and declare a new local variable and for pop to end that block similar to DROP_GIANT/PICKUP_GIANT in the kernel). Internally the thread libraries already do this for internal push/pops to avoid deadlocks. -- John Baldwin