From 706ad1e7af37be1d25fc2359bda006d31fe0d11b Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Wed, 20 May 2020 15:40:35 +0200 Subject: Add the __libc_single_threaded variable The variable is placed in libc.so, and it can be true only in an outer libc, not libcs loaded via dlmopen or static dlopen. Since thread creation from inner namespaces does not work, pthread_create can update __libc_single_threaded directly. Using __libc_early_init and its initial flag, implementation of this variable is very straightforward. A future version may reset the flag during fork (but not in an inner namespace), or after joining all threads except one. Reviewed-by: DJ Delorie --- elf/libc_early_init.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'elf/libc_early_init.c') diff --git a/elf/libc_early_init.c b/elf/libc_early_init.c index f0fcf6448e..86da66d5e0 100644 --- a/elf/libc_early_init.c +++ b/elf/libc_early_init.c @@ -19,13 +19,18 @@ #include #include #include +#include void __libc_early_init (_Bool initial) { /* Initialize ctype data. */ __ctype_init (); + /* Register rseq ABI to the kernel for the main program's libc. */ if (initial) rseq_register_current_thread (); + + /* Only the outer namespace is marked as single-threaded. */ + __libc_single_threaded = initial; } -- cgit 1.4.1