Help: Unwinding the C++ stack...throw, longjmp & threads
Ulrich Drepper
drepper@cygnus.com
Wed Aug 25 08:37:00 GMT 1999
"George T. Talbot" <george@moberg.com> writes:
> I asked the author of Programming POSIX Threads (David Butenhof) who
> said that the standard doesn't really define that case, but that
> programs which use return to avoid pthread_cleanup_pop() aren't
> portable.
I don't care whether it's unportable, I need this for the implementation.
> By the way, won't the current implementation have a problem with this
> case?
No, since I call the underlying function.
> { \
> void (*__function) (void *) = blah; |
> void *__arg = arg; | pthread_cleanup_push()
> |
> __try |
> { /
> ...
> do_work();
> ...
> } \
> __catch (...) |
> { | pthread_cleanup_pop()
> __function(arg); |
> __throw; |
> } |
> if (execute) __function(arg); |
> } /
What I hope to get are optimizations. E.g., the function is constant.
Therefore the compiler should put a function pointer in an appropriate
place where it does not have to be loaded each time. Since the access
in the __catch part is generated by the compiler as well it can know
where to get the value from.
> (I'm not sure whether the above should be __catch(...) or
> __catch(POSIX_cancel c). I could argue for either one.)
The latter.
> I agree that this needs to be done. I'm just saying that it's a problem
> that I don't know that I could get right, as I don't have enough
> experience and familiarity with the C library. Is there an automated
> way of doing this?
One could find this out partially using some scripts but they need in
some cases help from people and also have to rerun after every change.
--
---------------. drepper at gnu.org ,-. 1325 Chesapeake Terrace
Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA
Cygnus Solutions `--' drepper at cygnus.com `------------------------
More information about the Libc-alpha
mailing list