pthread_cleanup_push

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

pthread_cleanup_push

Maksym Yehorov
Broken macro pthread_cleanup_push in glibc-2.5.

diff -Naur glibc-2.5/nptl/sysdeps/pthread/pthread.h
glibc-2.5-pthread_cleanup_push_fix/nptl/sysdeps/pthread/pthread.h
--- glibc-2.5/nptl/sysdeps/pthread/pthread.h    2006-06-05
02:59:07.000000000 +0300
+++ glibc-2.5-pthread_cleanup_push_fix/nptl/sysdeps/pthread/pthread.h
 2007-06-15 17:18:42.000000000 +0300
@@ -541,8 +541,7 @@
    pthread_cleanup_push and pthread_cleanup_pop are macros and must always
    be used in matching pairs at the same nesting level of braces.  */
 #  define pthread_cleanup_push(routine, arg) \
-  do {                                                                       \
-    __pthread_cleanup_class __clframe (routine, arg)
+  do { __pthread_cleanup_class __clframe (routine, arg); } while(0)

 /* Remove a cleanup handler installed by the matching pthread_cleanup_push.
    If EXECUTE is non-zero, the handler function is called. */


--
Sincerely yours,
Max Yegorov
mail-to: [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: pthread_cleanup_push

Daniel Jacobowitz-2
On Fri, Jun 15, 2007 at 06:16:38PM +0300, Maksym Yehorov wrote:
> Broken macro pthread_cleanup_push in glibc-2.5.

No, it's doing exacty what it's supposed to.  Read the comment quoted
at the top of your patch.

--
Daniel Jacobowitz
CodeSourcery
Reply | Threaded
Open this post in threaded view
|

Re: pthread_cleanup_push

Maksym Yehorov
That means that I can not use pthread_cleanup_push for deferred
cleanup of some resources after the thread is finished?
It seems that it can work that way.

On 6/15/07, Daniel Jacobowitz <[hidden email]> wrote:

> On Fri, Jun 15, 2007 at 06:16:38PM +0300, Maksym Yehorov wrote:
> > Broken macro pthread_cleanup_push in glibc-2.5.
>
> No, it's doing exacty what it's supposed to.  Read the comment quoted
> at the top of your patch.
>
> --
> Daniel Jacobowitz
> CodeSourcery
>


--
Sincerely yours,
Max Yegorov
mail-to: [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: pthread_cleanup_push

Daniel Jacobowitz-2
On Fri, Jun 15, 2007 at 06:24:48PM +0300, Maksym Yehorov wrote:
> That means that I can not use pthread_cleanup_push for deferred
> cleanup of some resources after the thread is finished?
> It seems that it can work that way.

No, you can only use it the way it's described in POSIX.

--
Daniel Jacobowitz
CodeSourcery