[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: pthread_cleanup_push & pthread_cleanup_pop usage
- To: freebsd-threads_(_at_)_freebsd_(_dot_)_org
- Subject: Re: pthread_cleanup_push & pthread_cleanup_pop usage
- From: John Baldwin <jhb_(_at_)_freebsd_(_dot_)_org>
- Date: Wed, 8 Oct 2008 14:09:31 -0400
- Cc: John Hein <jhein_(_at_)_timing_(_dot_)_com>
On Tuesday 07 October 2008 11:28:33 pm John Hein wrote:
> In June pthread_cleanup_push & pthread_cleanup_pop were changed to macros
> that look like so...
>
> +#define pthread_cleanup_push(cleanup_routine, cleanup_arg)
\
> + {
\
> + struct _pthread_cleanup_info __cleanup_info__;
\
> + __pthread_cleanup_push_imp(cleanup_routine,
cleanup_arg,\
> + &__cleanup_info__);
\
> + {
> +
> +#define pthread_cleanup_pop(execute)
\
> + }
\
> + __pthread_cleanup_pop_imp(execute);
\
> + }
> +
>
>
> This breaks code where the pop is done in an inner block level.
>
> simplified example:
>
> pthread_cleanup_push(docleanup, &foo);
> try
> {
> dostuff();
> }
> catch (...)
> {
> pthread_cleanup_pop(1);
> throw;
> }
> pthread_cleanup_pop(1);
>
> Does anyone have a recommended fix?
Don't Do That (tm). The spec explicitly states that they can be defined as
macros and that code using it needs to put them in the same block.
--
John Baldwin
_______________________________________________
freebsd-threads_(_at_)_freebsd_(_dot_)_org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-threads
To unsubscribe, send any mail to "freebsd-threads-unsubscribe_(_at_)_freebsd_(_dot_)_org"
Visit your host, monkey.org