This is the mail archive of the pthreads-win32@sourceware.org mailing list for the pthreas-win32 project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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.

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]