problem in pthread.h

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

problem in pthread.h

Romano Paolo Tenca
In pthread.h  2.7.0 line 762 i find:

#define pthread_cleanup_push( _rout, _arg ) \
        { \
            ptw32_cleanup_t     _cleanup; \
            \
            ptw32_push_cleanup( &_cleanup, (ptw32_cleanup_callback_t)
(_rout), (_arg) ); \

#define pthread_cleanup_pop( _execute ) \
            (void) ptw32_pop_cleanup( _execute ); \
        }

It seems to me that it must be:

#define pthread_cleanup_push( _rout, _arg ) \
        { \
            ptw32_cleanup_t     _cleanup; \
            ptw32_push_cleanup( &_cleanup, (ptw32_cleanup_callback_t)
(_rout), (_arg) ); \
        }

#define pthread_cleanup_pop( _execute ) \
       (void) ptw32_pop_cleanup( _execute );



--
Romano Paolo Tenca

Reply | Threaded
Open this post in threaded view
|

RE: problem in pthread.h

Bossom, John
The pthread_cleanup_push defines a scoped block that is completed by the
pop macro.
This scoping is necessary in order that the internal local variable,
_cleanup, still exists at when the pop is actually called. The pop
expects the values in the _cleanup to still be available.



-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of Romano Paolo
Tenca
Sent: Monday, June 05, 2006 2:06 PM
To: Pthreads-Win32 list
Subject: problem in pthread.h

In pthread.h  2.7.0 line 762 i find:

#define pthread_cleanup_push( _rout, _arg ) \
        { \
            ptw32_cleanup_t     _cleanup; \
            \
            ptw32_push_cleanup( &_cleanup, (ptw32_cleanup_callback_t)
(_rout), (_arg) ); \

#define pthread_cleanup_pop( _execute ) \
            (void) ptw32_pop_cleanup( _execute ); \
        }

It seems to me that it must be:

#define pthread_cleanup_push( _rout, _arg ) \
        { \
            ptw32_cleanup_t     _cleanup; \
            ptw32_push_cleanup( &_cleanup, (ptw32_cleanup_callback_t)
(_rout), (_arg) ); \
        }

#define pthread_cleanup_pop( _execute ) \
       (void) ptw32_pop_cleanup( _execute );



--
Romano Paolo Tenca
 
     This message may contain privileged and/or confidential information.  If you have received this e-mail in error or are not the intended recipient, you may not use, copy, disseminate or distribute it; do not open any attachments, delete it immediately from your system and notify the sender promptly by e-mail that you have done so.  Thank you.
Reply | Threaded
Open this post in threaded view
|

Re: problem in pthread.h

Romano Paolo Tenca
Bossom, John wrote:
> The pthread_cleanup_push defines a scoped block that is completed by the
> pop macro.
> This scoping is necessary in order that the internal local variable,
> _cleanup, still exists at when the pop is actually called. The pop
> expects the values in the _cleanup to still be available.
>
>  
Yes, but check the original code: the block is closed in the wrong position.

> In pthread.h  2.7.0 line 762 i find:
>
> #define pthread_cleanup_push( _rout, _arg ) \
>         { \
>             ptw32_cleanup_t     _cleanup; \
>             \
>             ptw32_push_cleanup( &_cleanup, (ptw32_cleanup_callback_t)
> (_rout), (_arg) ); \
>
> #define pthread_cleanup_pop( _execute ) \
>             (void) ptw32_pop_cleanup( _execute ); \
>         }
>
> It seems to me that it must be:
>
> #define pthread_cleanup_push( _rout, _arg ) \
>         { \
>             ptw32_cleanup_t     _cleanup; \
>             ptw32_push_cleanup( &_cleanup, (ptw32_cleanup_callback_t)
> (_rout), (_arg) ); \
>         }
>
> #define pthread_cleanup_pop( _execute ) \
>        (void) ptw32_pop_cleanup( _execute );
>
>
>  
--

Romano Paolo Tenca

Reply | Threaded
Open this post in threaded view
|

Re: problem in pthread.h

Romano Paolo Tenca
In reply to this post by Bossom, John
Bossom, John wrote:
> The pthread_cleanup_push defines a scoped block that is completed by the
> pop macro.
> This scoping is necessary in order that the internal local variable,
> _cleanup, still exists at when the pop is actually called. The pop
> expects the values in the _cleanup to still be available.
>  
Oh, now i understand! I must use the pair of push/pop macro. (RTFM)
Thank you for the help.

---
Romano Paolo Tenca

Reply | Threaded
Open this post in threaded view
|

RE: problem in pthread.h

Bossom, John
In reply to this post by Romano Paolo Tenca
You're welcome.

-----Original Message-----
From: Romano Paolo Tenca [mailto:[hidden email]]
Sent: Monday, June 05, 2006 3:17 PM
To: Bossom, John
Cc: Pthreads-Win32 list
Subject: Re: problem in pthread.h

Bossom, John wrote:
> The pthread_cleanup_push defines a scoped block that is completed by
> the pop macro.
> This scoping is necessary in order that the internal local variable,
> _cleanup, still exists at when the pop is actually called. The pop
> expects the values in the _cleanup to still be available.
>  
Oh, now i understand! I must use the pair of push/pop macro. (RTFM)
Thank you for the help.

---
Romano Paolo Tenca
 
     This message may contain privileged and/or confidential information.  If you have received this e-mail in error or are not the intended recipient, you may not use, copy, disseminate or distribute it; do not open any attachments, delete it immediately from your system and notify the sender promptly by e-mail that you have done so.  Thank you.