public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Mark Mitchell <mark@codesourcery.com>
Cc: Michael Matz <matz@suse.de>,
	Zack Weinberg <zack@codesourcery.com>,
	Richard Henderson <rth@redhat.com>,
	Aldy Hernandez <aldyh@redhat.com>,
	"gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>,
	"jason@redhat.com" <jason@redhat.com>
Subject: Re: [basic-improvements] try/finally support for c/c++ - more tests
Date: Thu, 07 Nov 2002 08:44:00 -0000	[thread overview]
Message-ID: <20021107114358.Q10988@devserv.devel.redhat.com> (raw)
In-Reply-To: <19940000.1036685525@warlock.codesourcery.com>; from mark@codesourcery.com on Thu, Nov 07, 2002 at 08:12:05AM -0800

On Thu, Nov 07, 2002 at 08:12:05AM -0800, Mark Mitchell wrote:
> > Standards fixate existing practice, they don't establish it.
> 
> We've already got a standard that's relevant here.   In particular,
> we have the C++ programming language, which provides the functionality
> needed.  If you need that functionality, use that language, or another
> language (like Java, Ada, etc.) that provides that functionality.

As has been mentioned previously, compiling GNU libc as C++ is hard, since
it is a heavy user of -std=gnu99 features and extensions which are not in C++.

> Now, I'm not fully understanding how this is going to be used, which
> is perhaps coloring my thinking.  I'm getting the impression that this
> functionality is going to get buried in C headers that are going to
> get seen in *user* C code.  Is that true?

Yes, among other places.

> We're trying to implement one particular piece of functionality required
> by the POSIX threads interface; namely "pthread_cleanup_push" and friends.
> (I know that any feature might get used more widely, but this is the
> motivation, as I understand it.)  Furthermore, we're trying to make the
> POSIX threads cleanups play nice with exception-handling.  Or are we
> trying to use EH mechanisms to make things go faster?

Both. One goal is to make sure C++ destructors are run when cancelling a
thread, properly interleaved with C cleanups.
Of course the smaller overhead the mechanism has in the normal (ie. thread
is not being cancelled) case, the better.

> Anyhow, if I write:
> 
>   try { pthread_cleanup_push (...);
>         throw 3;
	  pthread_cleanup_pop (doit);
>	 }
>   catch (...) { }
> 
> and the system arranges to run the cleanup when the exception is thrown,
> the system is badly broken.

Implementation of pthread_cleanup_pop using __try/__finally would have to
do if ((doit) || __pthread_cancelling()) at the beginning of the __finally
block, so if you do pthread_cleanup_pop (0), the cleanup will not be run
when the exception is thrown, just when cancellation happens.
__pthread_cancelling may be just a simple TLS variable access.

Though if C has something like __try/__finally, then the programmer can as
well use it directly and not through the horrible pthread_cleanup_*
interface, while if pthread_cleanup_{push,pop} is implemented using
builtins which match exactly what pthread_cleanup_{push,pop}
is doing (as has been already suggested), then all the code is stuck
in using it.

	Jakub

  parent reply	other threads:[~2002-11-07 16:44 UTC|newest]

Thread overview: 128+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-05 15:16 [basic-improvements] try/finally support for c/c++ Aldy Hernandez
2002-11-05 15:57 ` Richard Henderson
2002-11-05 23:03   ` Aldy Hernandez
2002-11-06  0:44     ` Joseph S. Myers
2002-11-06  0:52       ` Jakub Jelinek
2002-11-06  3:02         ` Michael Matz
2002-11-06  3:11           ` Jakub Jelinek
2002-11-06  4:16             ` Michael Matz
2002-11-06 10:29       ` Aldy Hernandez
2002-11-06 10:53         ` Richard Henderson
2002-11-06 10:56           ` Aldy Hernandez
2002-11-06 11:24           ` Joseph S. Myers
2002-11-06 13:49             ` Richard Henderson
2002-11-06 17:45           ` Fergus Henderson
2002-11-07  9:54             ` Richard Henderson
2002-11-06 17:48           ` Fergus Henderson
2002-11-07  9:58             ` Richard Henderson
2002-11-06 11:22         ` Joseph S. Myers
2002-11-06 14:00           ` Richard Henderson
2002-11-06 17:21         ` Fergus Henderson
2002-11-06  4:20   ` Gabriel Dos Reis
2002-11-06  9:05     ` Aldy Hernandez
2002-11-06  9:11       ` Matt Austern
2002-11-06  9:25         ` Gabriel Dos Reis
2002-11-06 11:15         ` Richard Henderson
2002-11-07  0:09           ` Kai Henningsen
2002-11-07 12:56             ` Richard Henderson
2002-11-06  6:05   ` Jason Merrill
2002-11-06 10:56     ` Richard Henderson
2002-11-06 12:14       ` Jason Merrill
2002-11-05 16:40 ` Stan Shebs
2002-11-05 16:48   ` Matt Austern
2002-11-05 17:21     ` Jason Merrill
2002-11-05 19:25       ` Matt Austern
2002-11-06 10:25         ` Richard Henderson
2002-11-06 11:05         ` Mike Stump
2002-11-05 21:20     ` Aldy Hernandez
2002-11-06  9:43 ` [basic-improvements] try/finally support for c/c++ - more tests Jakub Jelinek
2002-11-06 11:04   ` Joseph S. Myers
2002-11-06 15:34   ` Mark Mitchell
2002-11-06 16:03     ` Richard Henderson
2002-11-06 16:10       ` Gabriel Dos Reis
2002-11-06 16:12         ` Richard Henderson
2002-11-06 16:20           ` Gabriel Dos Reis
2002-11-06 17:02             ` Per Bothner
2002-11-06 17:14               ` Gabriel Dos Reis
2002-11-06 16:47       ` Mark Mitchell
2002-11-06 16:54         ` Matt Austern
2002-11-06 18:00         ` Zack Weinberg
2002-11-06 18:14           ` Gabriel Dos Reis
2002-11-06 18:58             ` Zack Weinberg
2002-11-06 19:33               ` Gabriel Dos Reis
2002-11-06 22:15                 ` Zack Weinberg
2002-11-06 22:37           ` Mark Mitchell
2002-11-06 23:30             ` Aldy Hernandez
2002-11-07  1:03               ` Gabriel Dos Reis
2002-11-07  5:34             ` Michael Matz
2002-11-07  8:14               ` Mark Mitchell
2002-11-07  8:37                 ` Daniel Jacobowitz
2002-11-07  9:09                   ` Mark Mitchell
2002-11-07  9:19                     ` Daniel Jacobowitz
2002-11-07  9:53                       ` Mark Mitchell
2002-11-07  9:57                         ` Matt Austern
2002-11-07 10:43                         ` Jason Merrill
2002-11-07  8:44                 ` Jakub Jelinek [this message]
2002-11-07 12:18                 ` Geoff Keating
2002-11-07 12:24                   ` Daniel Jacobowitz
2002-11-07 12:32                   ` Mark Mitchell
2002-11-07 13:41                     ` Geoff Keating
2002-11-07 14:06                       ` Mark Mitchell
2002-11-07 14:39                         ` Richard Henderson
2002-11-07 14:53                           ` Mark Mitchell
2002-11-07 15:14                             ` Geoff Keating
2002-11-07 15:37                               ` Mark Mitchell
2002-11-08 11:30                                 ` Geoff Keating
2002-11-07 15:45                             ` Richard Henderson
2002-11-07 16:21                               ` Mark Mitchell
2002-11-07 16:44                                 ` aldyh
2002-11-07 17:06                                 ` Richard Henderson
2002-11-07 17:10                                 ` Jakub Jelinek
2002-11-07 17:29                                   ` Mark Mitchell
2002-11-07 17:43                                     ` Richard Henderson
2002-11-07 17:55                                       ` Mark Mitchell
2002-11-07 17:52                                     ` Jason Merrill
2002-11-07 17:57                                       ` Mark Mitchell
2002-11-07 18:17                                         ` Zack Weinberg
2002-11-07 18:29                                           ` Mark Mitchell
2002-11-07 21:23                                             ` Robert Lipe
2002-11-07 21:32                                               ` Jason Merrill
2002-11-08  4:48                                             ` Nicola Pero
2002-11-08  5:47                                               ` Jakub Jelinek
2002-11-08 10:02                                                 ` Fergus Henderson
2002-11-08 11:24                                                 ` Kai Henningsen
2002-11-08 11:44                                                   ` Jakub Jelinek
2002-11-09  0:11                                                     ` Fergus Henderson
2002-11-08 11:46                                                   ` Mike Stump
2002-11-08 10:02                                             ` Matt Austern
2002-11-11  5:38                                               ` Michael Matz
2002-11-11 12:59                                                 ` Matt Austern
2002-11-12  1:01                                                   ` Michael Matz
2002-11-12  8:20                                                     ` Mark Mitchell
2002-11-12  8:58                                                       ` Michael Matz
2002-11-07 19:28                                         ` Daniel Jacobowitz
2002-11-07 22:07                                 ` Alexandre Oliva
2002-11-08  4:27                                   ` Richard Henderson
2002-11-08  4:54                                     ` Jakub Jelinek
2002-11-08  6:01                                       ` Jakub Jelinek
2002-11-08 11:38                                       ` Mike Stump
2002-11-08 11:25                                     ` Mike Stump
2002-11-08  9:31                                 ` Michael Matz
2002-11-08 11:26                                   ` Hans-Peter Nilsson
2002-11-08 11:48                                     ` Mike Stump
2002-11-07 11:38               ` Zack Weinberg
2002-11-07  9:38             ` Mike Stump
2002-11-07 10:06           ` Richard Henderson
2002-11-07 12:57           ` Hans-Peter Nilsson
2002-11-06 17:58       ` Fergus Henderson
2002-11-06 18:09         ` Fergus Henderson
2002-11-07  0:30         ` Jakub Jelinek
2002-11-06 18:34       ` Geoff Keating
2002-11-07  3:29         ` Fergus Henderson
2002-11-07  4:22           ` Jakub Jelinek
2002-11-07  5:13             ` Fergus Henderson
2002-11-07  5:47               ` Michael Matz
2002-11-07  8:52               ` Aldy Hernandez
2002-11-07 10:00                 ` Mike Stump
2002-11-07 12:36                 ` Alexandre Oliva
2002-11-07 13:06                   ` Aldy Hernandez

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20021107114358.Q10988@devserv.devel.redhat.com \
    --to=jakub@redhat.com \
    --cc=aldyh@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jason@redhat.com \
    --cc=mark@codesourcery.com \
    --cc=matz@suse.de \
    --cc=rth@redhat.com \
    --cc=zack@codesourcery.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).