Recognizing the main thread based on its thread descriptor
Adhemerval Zanella
adhemerval.zanella@linaro.org
Wed May 10 12:30:00 GMT 2017
On 10/05/2017 06:28, Florian Weimer wrote:
> Is there an internal way to tell if the current thread is the main thread?
>
> I need this to allocate thread-local state in a particular way (the main thread needs to get a copy of the global variable for backwards compatibility). Currently, this is handled with an initializer for the TLS variable and an override during pthread_create. I want to switch this to dynamic initialization.
>
> I can probably come up with a clever hack to express this, but I would prefer something explicit.
>
> Thanks,
> Florian
Most straightforward way I can think of is add a global variable to hold
main thread pointer and set it on dl_main.
More information about the Libc-alpha
mailing list