[PATCH 1/2] Add the __libc_single_threaded variable

Szabolcs Nagy szabolcs.nagy@arm.com
Thu May 21 13:07:21 GMT 2020


The 05/20/2020 20:12, Florian Weimer via Libc-alpha wrote:
> 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.
> ---
...
> +* The GNU C Library now provides the header file <sys/single_threaded.h>
> +  which declares the variable __libc_single_threaded.  Applications are
> +  encouraged to use this variable for single-thread optimizations,
> +  instead of weak references to symbols historically defined in
> +  libpthread.

i wonder if the new header can be included into
threads.h and pthread.h, and a feature macro added
for it, so users can avoid doing a header check.

if the name is already in implementation reserved
namespace this should be possible, i'm not sure
if such indirect include is best practice though.


More information about the Libc-alpha mailing list