This is the mail archive of the
mailing list for the GCC project.
Re: [basic-improvements] try/finally support for c/c++ - more tests
- From: Mark Mitchell <mark at codesourcery dot com>
- To: Geoff Keating <geoffk at geoffk dot org>
- Cc: "zack at codesourcery dot com" <zack at codesourcery dot com>, "rth at redhat dot com" <rth at redhat dot com>, "jakub at redhat dot com" <jakub at redhat dot com>, "aldyh at redhat dot com" <aldyh at redhat dot com>, "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, "jason at redhat dot com" <jason at redhat dot com>
- Date: Thu, 07 Nov 2002 14:03:55 -0800
- Subject: Re: [basic-improvements] try/finally support for c/c++ - more tests
You'd have to have sigpause (and the other cancellable calls)
conditionalised on __cplusplus, and then to permit users to write
programs in a mix of C and C++ you'd have to define some way to
convert the exceptions thrown in C++ to the sj/lj calls in C.
OK, I think I see the problem.
Suppose the dynamic stack of your code looks like:
C++ -> C -> C++ -> sigpause
When cancellation occurs, you want to have sigpause throw an exception,
run cleanups in C++, then run the pthread_cleanup_push stuff in C,
the outer C++ cleanups agagin, etc.
If the -> transitions are shared library boundaries, you have no problem;
you can have your personality routines do the right thing. In fact, you
can do that anyhow, if you mark your .o's as being C or C++.
In C, you have pthread_cleanup_push keep a stack of cleanups.
When unwinding through a a C .o, you run the stack. In C++, you use
my pthread_cleanup_push class so that it just happens by itself.
You have sigpause throw an exception, and you have a handler at the top
of the stack, to finish the thread exit. (This last bit is what was
going to happen with try/finally anyhow, I assume.)
Mark Mitchell email@example.com
CodeSourcery, LLC http://www.codesourcery.com