Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 31 Oct 2002 09:35:11 +0000 (GMT)
From:      Doug Rabson <dfr@nlsystems.com>
To:        ak03@gte.com
Cc:        Daniel Eischen <eischen@pcnet1.pcnet.com>, <tlambert2@mindspring.com>, <current@FreeBSD.ORG>
Subject:   Re: [PATCH: libc]Re: gnome on current
Message-ID:  <20021031093249.T36855-100000@herring.nlsystems.com>
In-Reply-To: <20021031000501.3e20a6a6.kabaev@bellatlantic.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, 31 Oct 2002, Alexander Kabaev wrote:

> On Wed, 30 Oct 2002 22:25:12 -0500 (EST)
> Daniel Eischen <eischen@pcnet1.pcnet.com> wrote:
>
> > > If last weak will win, the normal case when Xthrstub is loaded
> > > _after_ libc_r will break. The only way to really fix this is to
> > > export pthread_ symbols as strong in libc_r. Exporting them as weak
> > > sounds like is a mistake which should be fixed.
> >
> > I disagree.  See Solaris 6, 7, 8 & 9 for an example.
> >
> Cool. Then let's be consistent and follow Solaris all the way. Libc on
> Solaris provides full set of pthread_? functions which in turn call
> weakly defined _pthread_?? counterparts. libpthread in turn provides
> strong definitions for _pthread_??.
>
> Since in absolute majority of cases libc is the first library searched
> for symbols, all pthread references will be bound to it and failure
> described by Doug will not happen.
>
> Any library providing strong pthread_ definitions will be able to
> override ones provided by the system.

Something along these lines appears to work nicely and ought to work
either with or without libXThrStub, which is now redundant since libc will
be providing strong symbols that override all the weak symbols in
libXThrStub. We should adjust the XFree86-4-libraries port to avoid
building and using that library.

Index: gen/_pthread_stubs.c
===================================================================
RCS file: /home/ncvs/src/lib/libc/gen/_pthread_stubs.c,v
retrieving revision 1.7
diff -u -r1.7 _pthread_stubs.c
--- gen/_pthread_stubs.c	19 Sep 2002 01:09:49 -0000	1.7
+++ gen/_pthread_stubs.c	31 Oct 2002 09:31:25 -0000
@@ -31,6 +31,9 @@
 #include <pthread.h>
 #include <pthread_np.h>

+void *_pthread_getspecific(pthread_key_t key);
+pthread_t _pthread_self(void);
+
 /*
  * Weak symbols: All libc internal usage of these functions should
  * use the weak symbol versions (_pthread_XXX).  If libpthread is
@@ -42,6 +45,7 @@
  */
 __weak_reference(_pthread_cond_init_stub,	_pthread_cond_init);
 __weak_reference(_pthread_cond_signal_stub,	_pthread_cond_signal);
+__weak_reference(_pthread_cond_broadcast_stub,	_pthread_cond_broadcast);
 __weak_reference(_pthread_cond_wait_stub,	_pthread_cond_wait);
 __weak_reference(_pthread_cond_destroy_stub,	_pthread_cond_destroy);
 __weak_reference(_pthread_getspecific_stub,	_pthread_getspecific);
@@ -87,6 +91,12 @@
 }

 int
+_pthread_cond_broadcast_stub(pthread_cond_t *cond)
+{
+	return (0);
+}
+
+int
 _pthread_cond_wait_stub(pthread_cond_t *cond, pthread_mutex_t *mutex)
 {
 	return (0);
@@ -235,4 +245,174 @@
 _pthread_sigmask_stub(int how, const sigset_t *set, sigset_t *oset)
 {
 	return (0);
+}
+
+int
+pthread_cond_init(pthread_cond_t *cond,
+    const pthread_condattr_t *cond_attr)
+{
+	return (_pthread_cond_init(cond, cond_attr));
+}
+
+int
+pthread_cond_signal(pthread_cond_t *cond)
+{
+	return (_pthread_cond_signal(cond));
+}
+
+int
+pthread_cond_broadcast(pthread_cond_t *cond)
+{
+	return (_pthread_cond_broadcast(cond));
+}
+
+int
+pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
+{
+	return (_pthread_cond_wait(cond, mutex));
+}
+
+int
+pthread_cond_destroy(pthread_cond_t *cond)
+{
+	return (_pthread_cond_destroy(cond));
+}
+
+void *
+pthread_getspecific(pthread_key_t key)
+{
+	return (_pthread_getspecific(key));
+}
+
+int
+pthread_key_create(pthread_key_t *key, void (*destructor) (void *))
+{
+	return (_pthread_key_create(key, destructor));
+}
+
+int
+pthread_key_delete(pthread_key_t key)
+{
+	return (_pthread_key_delete(key));
+}
+
+int
+pthread_main_np()
+{
+	return (_pthread_main_np());
+}
+
+int
+pthread_mutex_destroy(pthread_mutex_t *mattr)
+{
+	return (_pthread_mutex_destroy(mattr));
+}
+
+int
+pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *mattr)
+{
+	return (_pthread_mutex_init(mutex, mattr));
+}
+
+int
+pthread_mutex_lock(pthread_mutex_t *mutex)
+{
+	return (_pthread_mutex_lock(mutex));
+}
+
+int
+pthread_mutex_trylock(pthread_mutex_t *mutex)
+{
+	return (_pthread_mutex_trylock(mutex));
+}
+
+int
+pthread_mutex_unlock(pthread_mutex_t *mutex)
+{
+	return (_pthread_mutex_unlock(mutex));
+}
+
+int
+pthread_mutexattr_init(pthread_mutexattr_t *mattr)
+{
+	return (_pthread_mutexattr_init(mattr));
+}
+
+int
+pthread_mutexattr_destroy(pthread_mutexattr_t *mattr)
+{
+	return (_pthread_mutexattr_destroy(mattr));
+}
+
+int
+pthread_mutexattr_settype(pthread_mutexattr_t *mattr, int type)
+{
+	return (_pthread_mutexattr_settype(mattr, type));
+}
+
+int
+pthread_once(pthread_once_t *once_control, void (*init_routine) (void))
+{
+	return (_pthread_once(once_control, init_routine));
+}
+
+int
+pthread_rwlock_init(pthread_rwlock_t *rwlock,
+    const pthread_rwlockattr_t *attr)
+{
+	return (_pthread_rwlock_init(rwlock, attr));
+}
+
+int
+pthread_rwlock_destroy(pthread_rwlock_t *rwlock)
+{
+	return (_pthread_rwlock_destroy(rwlock));
+}
+
+int
+pthread_rwlock_rdlock(pthread_rwlock_t *rwlock)
+{
+	return (_pthread_rwlock_rdlock(rwlock));
+}
+
+int
+pthread_rwlock_tryrdlock(pthread_rwlock_t *rwlock)
+{
+	return (_pthread_rwlock_tryrdlock(rwlock));
+}
+
+int
+pthread_rwlock_trywrlock(pthread_rwlock_t *rwlock)
+{
+	return (_pthread_rwlock_trywrlock(rwlock));
+}
+
+int
+pthread_rwlock_unlock(pthread_rwlock_t *rwlock)
+{
+	return (_pthread_rwlock_unlock(rwlock));
+}
+
+int
+pthread_rwlock_wrlock(pthread_rwlock_t *rwlock)
+{
+	return (_pthread_rwlock_wrlock(rwlock));
+}
+
+pthread_t
+pthread_self(void)
+{
+	return (_pthread_self());
+}
+
+int
+pthread_setspecific(pthread_key_t key, const void *value)
+{
+	return (_pthread_setspecific(key, value));
+}
+
+int
+pthread_sigmask(int how, const sigset_t *set, sigset_t *oset)
+{
+	return (_pthread_sigmask(how, set, oset));
 }
Index: include/namespace.h
===================================================================
RCS file: /home/ncvs/src/lib/libc/include/namespace.h,v
retrieving revision 1.9
diff -u -r1.9 namespace.h
--- include/namespace.h	29 Mar 2002 22:43:42 -0000	1.9
+++ include/namespace.h	30 Oct 2002 20:04:44 -0000
@@ -77,6 +77,7 @@
 #define		open				_open
 #define		poll				_poll
 #define		pthread_cond_signal		_pthread_cond_signal
+#define		pthread_cond_broadcast		_pthread_cond_broadcast
 #define		pthread_cond_wait		_pthread_cond_wait
 #define		pthread_cond_init		_pthread_cond_init
 #define		pthread_exit			_pthread_exit
Index: include/reentrant.h
===================================================================
RCS file: /home/ncvs/src/lib/libc/include/reentrant.h,v
retrieving revision 1.1
diff -u -r1.1 reentrant.h
--- include/reentrant.h	19 Mar 2001 12:49:49 -0000	1.1
+++ include/reentrant.h	30 Oct 2002 20:04:44 -0000
@@ -109,6 +109,8 @@
 #define cond_init(c, a, p)	_pthread_cond_init(c, a)
 #define cond_signal(m)		if (__isthreaded) \
 				_pthread_cond_signal(m)
+#define cond_broadcast(m)	if (__isthreaded) \
+				_pthread_cond_broadcast(m)
 #define cond_wait(c, m)		if (__isthreaded) \
 				_pthread_cond_wait(c, m)


-- 
Doug Rabson				Mail:  dfr@nlsystems.com
					Phone: +44 20 8348 6160



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?20021031093249.T36855-100000>