Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 31 Oct 2002 10:28:44 -0500 (EST)
From:      Daniel Eischen <eischen@pcnet1.pcnet.com>
To:        Doug Rabson <dfr@nlsystems.com>
Cc:        ak03@gte.com, tlambert2@mindspring.com, current@FreeBSD.ORG
Subject:   Re: [PATCH: libc]Re: gnome on current
Message-ID:  <Pine.GSO.4.10.10210311020180.3821-100000@pcnet1.pcnet.com>
In-Reply-To: <20021031144953.E69202-100000@herring.nlsystems.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 31 Oct 2002, Doug Rabson wrote:
> On Thu, 31 Oct 2002, Daniel Eischen wrote:
> > You can also play the libgcc game inside of libc for those applications
> > or libraries that are too lazy to do it for themselves.  Have the
> > libc pthread stubs key on a weak reference to pthread_create and
> > call the pthread_* if they are present.  libXThrStub should be
> > able to do that though.
> 
> It almost doesn't matter which of the solutions we use as long as we do
> something. What we currently have is clearly wrong but I'll list it along
> with the others. Solutions so far proposed are:
> 
> 0. (Current behaviour). Define _pthread_* weakly in libc. A pthreads
> implementation defines strong _pthread_* symbols and weak pthread_*
> aliases for them. Anyone else which defines pthread_* symbols (either weak
> or strong) can take over and will normally end up breaking libc.

We only use _pthread_* in libc, so it doesn't break libc unless
they provide strong symbols for _pthread_*.  Our implementation
relies on the use of single underscore versions in libc so we
can tell the difference between the implementation locks and
application locks.  The weak references from pthread_* in libc_r
are to the double underscore versions (mostly, the locking
functions) so that applications actually resolve to __pthread_mutex_lock
and libc uses will resolve to _pthread_mutex_lock.

> 1. Define pthread_* strongly in libc. Make these strong symbols call weak
> _pthread_* counterparts also defined in libc. A pthreads implementation
> defines strong _pthread_* symbols allowing it to 'take over' from libc.
> 
> 2. Define weak _pthread_* symbols in libc and probably weak pthread_*
> symbols either in libc or somewhere else (libXThrStub?). A pthreads
> implementation defines strong _pthread_* and strong pthread_*. This is the
> linux solution (without the _pthread_* indirection).
> 
> 3. Like (0) but rewrite X11's thread code so that every call looks
> something like:
> 
> 	if (pthreads)
> 		return pthread_foo(args);
> 	else
> 		return 0;
> 
> This isn't likely to be easy to get back into the XFree86 codebase and
> makes us gratuitously different from the rest of the world, most of which
> neither need nor have libXThrStub.
> 
> 4. Something else, e.g. more fine-grained control over symbol resolution
> beyond strong/weak. Probably not worth the effort.
> 
> Right now, I can't tell what Solaris does. Alexander suggested that it was
> (1) but you disagree. It would be interesting to see the output of 'nm |
> grep pthread' for both libc.so and libpthread.so.

I've already done that and posted it.  Here it is again.

bash-2.05$ uname -rvs  
SunOS 5.8 Generic_108528-12
bash-2.05$ nm /usr/lib/libc.so.1 | grep pthread_mutex_
0000000000054a08 t _libc_pthread_mutex_init
0000000000096bc0 W _pthread_mutex_destroy
0000000000096be8 W _pthread_mutex_getprioceiling
0000000000096c10 W _pthread_mutex_init
0000000000096c38 W _pthread_mutex_lock
0000000000096c60 W _pthread_mutex_setprioceiling
0000000000096c88 W _pthread_mutex_trylock
0000000000096cb0 W _pthread_mutex_unlock
0000000000096bc0 W pthread_mutex_destroy
0000000000096be8 W pthread_mutex_getprioceiling
0000000000096c10 W pthread_mutex_init
0000000000096c38 W pthread_mutex_lock
0000000000096c60 W pthread_mutex_setprioceiling
0000000000096c88 W pthread_mutex_trylock
0000000000096cb0 W pthread_mutex_unlock
bash-2.05$ nm /usr/lib/libpthread.so.1 | grep pthread_mutex_
0000000000003d28 T _pthread_mutex_attr_gettype
0000000000003d20 T _pthread_mutex_attr_settype
0000000000003c38 T _pthread_mutex_consistent_np
0000000000003c78 T _pthread_mutex_destroy
0000000000003ca0 T _pthread_mutex_getprioceiling
0000000000003c70 T _pthread_mutex_init
0000000000003c80 T _pthread_mutex_lock
0000000000003c98 T _pthread_mutex_setprioceiling
0000000000003c90 T _pthread_mutex_trylock
0000000000003c88 T _pthread_mutex_unlock
0000000000003d28 W pthread_mutex_attr_gettype
0000000000003d20 W pthread_mutex_attr_settype
0000000000003c38 W pthread_mutex_consistent_np
0000000000003c78 W pthread_mutex_destroy
0000000000003ca0 W pthread_mutex_getprioceiling
0000000000003c70 W pthread_mutex_init
0000000000003c80 W pthread_mutex_lock
0000000000003c98 W pthread_mutex_setprioceiling
0000000000003c90 W pthread_mutex_trylock
0000000000003c88 W pthread_mutex_unlock

-- 
Dan Eischen


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.GSO.4.10.10210311020180.3821-100000>