[Dri-devel] Re: OpenGL and the LinuxThreads pthread_descr structure

Jakub Jelinek jakub@redhat.com
Fri May 17 00:26:00 GMT 2002


On Fri, May 17, 2002 at 10:22:23AM +0300, Momchil Velikov wrote:
> >>>>> "Jakub" == Jakub Jelinek <jakub@redhat.com> writes:
> 
> >> How do you detect threading without making these calls to libpthreads.so?
> 
> Jakub> Weak symbols.
> 
> Jakub> extern pthread_t pthread_self (void) __attribute__ ((weak));
> 
> Jakub> (resp. #pragma weak pthread_self).
> Jakub> Then if (&pthread_self) { application was linked against -lpthread } else { not threaded }
> Jakub> Note all calls to pthread library has to be weak.
> 
> Hmm, if all the references to libpthread are weak, what will pull
> libpthread in ?

Nothing, that's the point.
If an application is threaded, it has to be linked with -lpthread (or some
of its libraries). In that case the weak symbols in libGL will resolve to
that library and libGL will be thread-safe.
If an application is not threaded, you don't want to link against -lpthread.

	Jakub



More information about the Libc-alpha mailing list