This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC 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: Interleaving pthread_cleanups in C and C++


> Perhaps even
> 
> #define pthread_cleanup_push(H, A) \
>  { struct __pthread_cleanup __pc = { (H), (A), true } \
>           __attribute__((cleanup (__pthread_cleanup_routine)));

This is a good idea.

I still have at least one concern here, though.

What happens if a pthread cleanup routine throws an exception?  (Let's
assume the cleanup routine is written in C++.)  The right answer, in
C++, would be to call std::terminate because that's what happens when
destructors throw exceptions during stack unwinding.  I'm not sure what
happens in analogous situations in other languages.  Anyhow, this is a
detail independent of the mechanism.

I will not try to dissuade anybody from implementing or checking in the
attribute you suggest.

-- 
Mark Mitchell <mark@codesourcery.com>
CodeSourcery, LLC


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