[PATCH] Pthreads cleanup push/pop changes

Peter Dufault dufault at hda.com
Fri Jul 5 19:05:58 UTC 2013


On Jul 5, 2013, at 12:22 , Sebastian Huber <sebastian.huber at embedded-brains.de> wrote:

> On 05/07/13 17:21, Gedare Bloom wrote:
>>> +#define pthread_cleanup_push(_routine, _arg) \
>>>> +  do { \
>>>> +    struct _pthread_cleanup_context _pthread_clup_ctx; \
>>>> +    _pthread_cleanup_push(&_pthread_clup_ctx, (_routine), (_arg))
>>>> +
>> Does this macro work with the do-while split across two CPP defines,
>> or do you need " } while (0)" here?
>> 
>>>> +#define pthread_cleanup_pop(_execute) \
>> Does this macro work, or do you need " do { \" here?
>>>> +    _pthread_cleanup_pop(&_pthread_clup_ctx, (_execute)); \
>>>> +  } while (0)
> 
> This split is intentional and explicitly mentioned in the POSIX 
> specification.  Its also the way glibc does it.
> 

It's clear, maybe add "pthread_cleanup_push() begins a stack scope balanced by the matching end in pthread_cleanup_pop()" comment for anyone momentarily confused.

Peter
-----------------
Peter Dufault
HD Associates, Inc.      Software and System Engineering





More information about the devel mailing list