From owner-freebsd-stable@FreeBSD.ORG Tue Nov 24 22:20:27 2009 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CA814106566B for ; Tue, 24 Nov 2009 22:20:27 +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 37FCA8FC1D for ; Tue, 24 Nov 2009 22:20:26 +0000 (UTC) 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 nAOMKPXx007425; Tue, 24 Nov 2009 17:20:25 -0500 (EST) 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.2.2 (mail.netplex.net [204.213.176.10]); Tue, 24 Nov 2009 17:20:25 -0500 (EST) Date: Tue, 24 Nov 2009 17:20:25 -0500 (EST) From: Daniel Eischen X-X-Sender: eischen@sea.ntplx.net To: Mark Andrews In-Reply-To: <200911242141.nAOLfAQa050429@drugs.dv.isc.org> Message-ID: References: <86aayc7z4g.fsf@zhuzha.ua1> <8663907xyy.fsf@zhuzha.ua1> <20091124153422.GT2331@deviant.kiev.zoral.com.ua> <200911242141.nAOLfAQa050429@drugs.dv.isc.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: Kostik Belousov , FreeBSD Stable , Mikolaj Golub Subject: Re: pthread.h: typo in #define pthread_cleanup_push/pthread_cleanup_pop X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Daniel Eischen List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 Nov 2009 22:20:27 -0000 On Wed, 25 Nov 2009, Mark Andrews wrote: > > In message <20091124153422.GT2331@deviant.kiev.zoral.com.ua>, Kostik Belousov write > s: >> >> --i616tqyc3hrkKsk2 >> Content-Type: text/plain; charset=us-ascii >> Content-Disposition: inline >> Content-Transfer-Encoding: quoted-printable >> >> On Tue, Nov 24, 2009 at 05:18:29PM +0200, Mikolaj Golub wrote: >> >> pthread_cleanup_push/pop are supposed to be used from the common >> lexical scope. Citation from SUSv4: >> >> These functions may be implemented as macros. The application shall >> ensure that they appear as statements, and in pairs within the same >> lexical scope (that is, the pthread_cleanup_push() macro may be >> thought to expand to a token list whose first token is '{' with >> pthread_cleanup_pop() expanding to a token list whose last token is the >> corresponding '}' ). >> >> Your change is wrong. >> >> Basically, the code should do >> pthread_cleanup_push(some_func, arh); >> something ... >> pthread_cleanup_pop(1); >> (1 denotes that some_func should be called). > > The problem is that that expands to C code that can only be used > with newer C compilers. This expansion should be usable with all > C compilers. > > #define pthread_cleanup_push(cleanup_routine, cleanup_arg) \ > { \ > struct _pthread_cleanup_info __cleanup_info__; \ > __pthread_cleanup_push_imp(cleanup_routine, cleanup _arg,\ > &__cleanup_info__) > > #define pthread_cleanup_pop(execute) \ > __pthread_cleanup_pop_imp(execute); \ > } ((void)0) Hmm, agreed. But note that Solaris 10 does it this way: #define pthread_cleanup_push(routine, args) { \ _cleanup_t _cleanup_info; \ __pthread_cleanup_push((_Voidfp)(routine), (void *)(args), \ (caddr_t)_getfp(), &_cleanup_info); #define pthread_cleanup_pop(ex) \ __pthread_cleanup_pop(ex, &_cleanup_info); \ } -- DE