libthr and libc
ale at FreeBSD.org
Tue Sep 7 10:02:11 UTC 2010
Alexander Pyhalov ha scritto:
> Can someone explain why this stubs are in libc? Why didn't linker just
> throw a linking error?
Simple explanation: the stubs are there because you can create a
thread-safe library and use it in a single-threaded or multi-threaded
program. Once linked to a multi-threaded program (with -pthread) the
library gets access to the real libthr implementations of the pthread_*
functions, while in the single-threaded program the library will use the
libc stubs without affecting performance.
If you encounter errors probably your program/libraries dynamically
loads shared libraries that link with libthr and so you eventually call
some pthread_* functions from libc and others from libthr.
More information about the freebsd-ports