This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc 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: Thread-local support for non-POD data objects


On Fri, Jul 12, 2013 at 10:51:28PM +0530, Siddhesh Poyarekar wrote:
> hi,
> 
> There's an item on the glibc TODO master that mentions glibc support
> for non-POD objects.  I believe the glibc support required here is
> limited to providing support for registering destructors and executing
> them on thread exit.  This is true for C++11 thread_local as well as
> openmp thread local objects.  This feature has been provided in glibc
> for 2.18, so I believe we could remove this item from the list.  Does
> anybody have any objections to that?
> 
> There's still the question of providing a C extension that implements
> a similar requirement, but that only needs compiler support now
> afaict.

Why is this needed in libc at all? My understanding is that the
thread-local ctors run when the C++ thread-creation function is used,
because pthread_create is called with a C++-implementation-internal
start function wrapping the application-provided start function. If
this is correct, then the start function provided by C++ could simply
use pthread_cleanup_push to install a cleanup handler that runs the
dtors, and run them manually with pthread_cleanup_pop(1) if the
application's start function returns. This would cover both
cancellation and pthread_exit or equivalent.

Am I missing some obvious reason this would not work?

Rich


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