Interleaving pthread_cleanups in C and C++

Daniel Jacobowitz drow@mvista.com
Mon May 5 23:59:00 GMT 2003


On Mon, May 05, 2003 at 08:10:56PM -0300, Alexandre Oliva wrote:
> On May  5, 2003, Mark Mitchell <mark@codesourcery.com> wrote:
> 
> >> Perhaps even
> >> 
> >> #define pthread_cleanup_push(H, A) \
> >> { struct __pthread_cleanup __pc = { (H), (A), true } \
> >> __attribute__((cleanup (__pthread_cleanup_routine)));
> 
> > This is a good idea.
> 
> The only thing I find sad about this is that it doesn't seem to enable
> one to define __try and __finally as macros with the expected
> behavior, such that, when __try/__finally make it to the standards,
> and/or people realize it was a mistake to not put it in in the first
> place, it's easy to rearrange code to take advantage of this.
> 
> I'd much rather introduce a feature that *could* actually be used to
> implement __try/__finally by means of preprocessor macros.  I'd love
> to be proved wrong, but I can't see how this proposal would enable
> this use :-(

I think I don't understand the logic which permits
__attribute__((cleanup)) but not try/finally.  The primary difference
is that the attribute uses a nonstandard syntax which we already have
instead of introducing a new one (which other vendors have). 
Conceptually, they exercise the same behavior, except that the cleanup
is restricted to being a function call instead of living in the local
scope.

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer



More information about the Gcc mailing list