This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
RE: Using EH from C
- From: Stelios Xanthakis <sxanth at ceid dot upatras dot gr>
- To: david daney <ddaney at avtrex dot com>
- Cc: Richard Henderson <rth at redhat dot com>, gcc at gcc dot gnu dot org
- Date: Sun, 2 May 2004 12:17:24 +0300 (EET DST)
- Subject: RE: Using EH from C
On Sat, 1 May 2004, david daney wrote:
>
> I would setjump and set an attfibute(cleanup(function))
> at the catch point, and then longjump from the cleanup function.
>
Not a bad idea. Like this?
if (setjmp (&context)) {
struct pseudo_object X __attribute__((cleanup(pdtor)));
X.normal_termination = 0;
X.ctx = &context;
/* ... */
X.normal_termination = 1;
} else {
}
And pdtor() will either just return or longjmp to ctx depending
on normal_termination.
There's still a minor cost but I guess it's ok.
Thanks,
Stelios