[PATCH] Provide pthread_atfork in libc_nonshared.a and libc.a.

Jakub Jelinek jakub@redhat.com
Wed Oct 2 21:43:00 GMT 2013


On Wed, Oct 02, 2013 at 05:36:04PM -0400, Rich Felker wrote:
> On Wed, Oct 02, 2013 at 05:31:13PM -0400, Carlos O'Donell wrote:
> > The standard design pattern for making it optional to link against
> > libpthread is to mark the function weak, test if the function
> > address is non-zero and call the function, otherwise use a fallback.
> 
> This idiom is completely wrong; it does not work with static linking.

No, that idiom is not wrong, is pretty standard practice for many years,
e.g. libgcc, libstdc++ etc. use it heavily and GCC/binutils extensions
have been designed for it (weakref).

Static linking is much less important than dynamic linking, and forcing
libpthread upon everybody that uses some shared library that should be
thread aware but doesn't really require it is just a bad idea.

There is really no cost in making pthread_atfork not require -lpthread,
because __register_atfork is implemented in libc already.

	Jakub



More information about the Libc-alpha mailing list