From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6788 invoked by alias); 7 Nov 2002 13:13:42 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 6779 invoked from network); 7 Nov 2002 13:13:41 -0000 Received: from unknown (HELO mulga.cs.mu.OZ.AU) (128.250.1.22) by sources.redhat.com with SMTP; 7 Nov 2002 13:13:41 -0000 Received: from ceres.cs.mu.oz.au (mail@ceres.cs.mu.OZ.AU [128.250.25.4]) by mulga.cs.mu.OZ.AU with ESMTP id AAA13139; Fri, 8 Nov 2002 00:13:33 +1100 (EST) Received: from fjh by ceres.cs.mu.oz.au with local (Exim 3.35 #1 (Debian)) id 189mTU-0005cF-00; Fri, 08 Nov 2002 00:13:32 +1100 Date: Thu, 07 Nov 2002 05:13:00 -0000 From: Fergus Henderson To: Jakub Jelinek Cc: Geoff Keating , Richard Henderson , Aldy Hernandez , "gcc-patches@gcc.gnu.org" , "jason@redhat.com" Subject: Re: [basic-improvements] try/finally support for c/c++ - more tests Message-ID: <20021107131331.GA8648@ceres.cs.mu.oz.au> References: <20021106124304.G10988@devserv.devel.redhat.com> <8450000.1036625540@warlock.codesourcery.com> <20021107000307.GQ22215@redhat.com> <20021107112921.GA14780@ceres.cs.mu.oz.au> <20021107072246.M10988@devserv.devel.redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20021107072246.M10988@devserv.devel.redhat.com> User-Agent: Mutt/1.3.28i X-SW-Source: 2002-11/txt/msg00445.txt.bz2 On 07-Nov-2002, Jakub Jelinek wrote: > On Thu, Nov 07, 2002 at 10:29:21PM +1100, Fergus Henderson wrote: > > On 06-Nov-2002, Geoff Keating wrote: > > > Richard Henderson writes: > > > > > > > On Wed, Nov 06, 2002 at 03:32:20PM -0800, Mark Mitchell wrote: > > > > > I do not think we should add exception support of any kind to GNU C; use > > > > > C++ if you want exceptions. > > > > > > > > See elsewhere about resistance compiling libc with a c++ compiler. > > > > > > It wouldn't work, anyway. User programs can also use > > > pthread_cleanup_push/pthread_cleanup_pop, in C, so whatever mechanism > > > is used for that must be accessible to C. > > > > How about the following? > > This uses the C++ compiler's exception support, and is accessible from C. > > It makes use of the GNU C nested function extension. > > The main drawback that I can see is that it is not as efficient as possible. > > s/not efficient as possible/completely inefficient/. I agree that this approach is not efficient. Describing it as "completely inefficient" is going a bit too far, IMHO. Cleanups are most often used to protect code which acquires locks or makes system calls, aren't they? Isn't acquiring a lock or making a system call a fairly expensive operation anyway? The worst cause of inefficiency for this approach is probably the icache flush needed for the trampoline creation when you take the address of a GNU C nested function. (I would like to see a different extension to fix that: one that allowed you to take the address of a nested function in a way that gave you two pointers -- a code pointer and a data pointer -- rather than a single pointer to a trampoline.) > This would slow e.g. stdio a lot. I was not saying that this code should be used for stdio. I was just refuting the claim that "it wouldn't work". Stdio (and other performance-critical routines that need cleanups) could be implemented in C++. These macros could be implemented differently (more efficiently) for C++. Now, all that said, I would like to see support for exception handling in GNU C (and for glibc to continue to be written in C rather than C++). But I would like the support for exception handling to include support for throwing and catching exceptions, not just try/finally. The current proposal seems too limited to be useful for much else than glibc, IMHO. > Plus it is incorrect too as pthread_cleanup_p{ush,op} implementation - the > cleanup is to be run if cancellation happens no matter whether __call_cleanup > is zero or non-zero. Details, details ;-) Sorry, I misread the spec for pthread_cleanup_{push,pop}. But this point can easily be remedied. The code I posted was just proof of concept, really. "Designing grand concepts is fun, finding nitty little bugs is just work" -- Brooks, in "The Mythical Man-Month". -- Fergus Henderson | "I have always known that the pursuit The University of Melbourne | of excellence is a lethal habit" WWW: | -- the last words of T. S. Garp.