[PATCH v2 2/2] Add single-threaded fast path to rand()
Wilco Dijkstra
Wilco.Dijkstra@arm.com
Wed Dec 13 14:00:12 GMT 2023
Hi,
>> Since random.c is sort-of shared with gnulib, would there be any harm
>> in using the user-visible "#include <sys/single_threaded.h>" and
>> __libc_single_threaded instead? That would lessen the differences
>> between the two source files. (I don't know why glibc code sometimes
>> includes <sys/single_threaded.h> and sometimes <single-thread.h>.)
Which header should be used is confusing indeed. It seems that
sys/single_threaded.h is more frequently used, so I'll change it to that.
> We can put the whole optimization into an #ifdef _LIBC block.
> SINGLE_THREAD_P is more optimized than the global __libc_single_threaded
> variable, and the difference is likely going to be visible on some
> architectures on some architectures.
Given there are many uses of SINGLE_THREAD_P scattered around GLIBC
this should really be done in the header or alternatively gnulib could define
its own SINGLE_THREAD_P (no idea how it works today given that stdio and
malloc have many uses).
Cheers,
Wilco
More information about the Libc-alpha
mailing list