This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Destructor support for C++11 thread_local variables
- From: Roland McGrath <roland at hack dot frob dot com>
- To: Siddhesh Poyarekar <siddhesh at redhat dot com>
- Cc: libc-alpha at sourceware dot org, Jakub Jelinek <jakub at redhat dot com>, Jason Merrill <jason at redhat dot com>
- Date: Wed, 10 Oct 2012 16:20:19 -0700 (PDT)
- Subject: Re: [PATCH] Destructor support for C++11 thread_local variables
- References: <20121010210546.7322c6fa@spoyarek>
I really hope there will be a way to use this from C, e.g.
__thread type x;
static void __attribute__((thread_destructor (x))) foo (type *x_ptr) { ... }
I'm pretty disinclined to add features to libc whose only possible use
is via C++.
Who says preventing DSO unloading is the right semantics? The obvious
analog to global destructors is to run them all on dlclose. That's
difficult to do if the semantics are that the destructor runs on the
thread owning the variable. (They'd be running inside a signal
handler or something scary like that.) It's not so hard if the
destructor takes the specific object pointer as a parameter and might
run on any thread. What is supposed to happen when you dlopen an
object defining thread_local variables with constructors when there
are already multiple threads?
Thanks,
Roland