PERFORCE change 32082 for review

Marcel Moolenaar marcel at FreeBSD.org
Thu May 29 18:11:05 PDT 2003


http://perforce.freebsd.org/chv.cgi?CH=32082

Change 32082 by marcel at marcel_nfs on 2003/05/29 18:10:26

	IFC @32080

Affected files ...

.. //depot/projects/ia64/contrib/amd/conf/transp/transp_sockets.c#2 integrate
.. //depot/projects/ia64/lib/libc/rpc/svc_vc.c#8 integrate
.. //depot/projects/ia64/lib/libpthread/Makefile#7 integrate
.. //depot/projects/ia64/lib/libpthread/pthread.map#1 branch
.. //depot/projects/ia64/lib/libpthread/support/Makefile.inc#1 branch
.. //depot/projects/ia64/lib/libpthread/support/thr_support.c#1 branch
.. //depot/projects/ia64/lib/libpthread/sys/Makefile.inc#4 integrate
.. //depot/projects/ia64/lib/libpthread/thread/Makefile.inc#8 integrate
.. //depot/projects/ia64/lib/libpthread/thread/thr_cond.c#10 integrate
.. //depot/projects/ia64/lib/libpthread/thread/thr_exit.c#5 integrate
.. //depot/projects/ia64/lib/libpthread/thread/thr_init.c#10 integrate
.. //depot/projects/ia64/lib/libpthread/thread/thr_mutex.c#5 integrate
.. //depot/projects/ia64/lib/libpthread/thread/thr_private.h#13 integrate
.. //depot/projects/ia64/lib/libpthread/thread/thr_rtld.c#1 branch
.. //depot/projects/ia64/lib/libpthread/thread/thr_rwlock.c#5 integrate
.. //depot/projects/ia64/lib/libpthread/thread/thr_sig.c#10 integrate
.. //depot/projects/ia64/lib/libpthread/thread/thr_sigprocmask.c#2 integrate
.. //depot/projects/ia64/lib/libpthread/thread/thr_spinlock.c#5 integrate
.. //depot/projects/ia64/lib/libthr/arch/i386/i386/_setcurthread.c#6 integrate
.. //depot/projects/ia64/lib/libthr/thread/thr_cond.c#5 integrate
.. //depot/projects/ia64/lib/libthr/thread/thr_create.c#8 integrate
.. //depot/projects/ia64/lib/libthr/thread/thr_exit.c#6 integrate
.. //depot/projects/ia64/lib/libthr/thread/thr_gc.c#6 integrate
.. //depot/projects/ia64/lib/libthr/thread/thr_join.c#6 integrate
.. //depot/projects/ia64/lib/libthr/thread/thr_mutex.c#6 integrate
.. //depot/projects/ia64/libexec/rtld-elf/Makefile#5 integrate
.. //depot/projects/ia64/libexec/rtld-elf/alpha/rtld_machdep.h#4 integrate
.. //depot/projects/ia64/libexec/rtld-elf/alpha/rtld_start.S#3 integrate
.. //depot/projects/ia64/libexec/rtld-elf/amd64/rtld_machdep.h#2 integrate
.. //depot/projects/ia64/libexec/rtld-elf/i386/lockdflt.c#4 integrate
.. //depot/projects/ia64/libexec/rtld-elf/i386/rtld_machdep.h#4 integrate
.. //depot/projects/ia64/libexec/rtld-elf/ia64/reloc.c#11 integrate
.. //depot/projects/ia64/libexec/rtld-elf/ia64/rtld_machdep.h#3 integrate
.. //depot/projects/ia64/libexec/rtld-elf/ia64/rtld_start.S#2 integrate
.. //depot/projects/ia64/libexec/rtld-elf/libmap.c#5 integrate
.. //depot/projects/ia64/libexec/rtld-elf/powerpc/reloc.c#3 integrate
.. //depot/projects/ia64/libexec/rtld-elf/powerpc/rtld_machdep.h#2 integrate
.. //depot/projects/ia64/libexec/rtld-elf/powerpc/rtld_start.S#2 integrate
.. //depot/projects/ia64/libexec/rtld-elf/rtld.c#15 integrate
.. //depot/projects/ia64/libexec/rtld-elf/rtld.h#6 integrate
.. //depot/projects/ia64/libexec/rtld-elf/rtld_lock.c#1 branch
.. //depot/projects/ia64/libexec/rtld-elf/rtld_lock.h#1 branch
.. //depot/projects/ia64/libexec/rtld-elf/sparc64/reloc.c#7 integrate
.. //depot/projects/ia64/libexec/rtld-elf/sparc64/rtld_machdep.h#4 integrate
.. //depot/projects/ia64/libexec/rtld-elf/sparc64/rtld_start.S#4 integrate
.. //depot/projects/ia64/share/man/man4/axe.4#2 integrate
.. //depot/projects/ia64/share/man/man4/mac_portacl.4#2 integrate
.. //depot/projects/ia64/share/man/man4/man4.i386/pae.4#3 integrate
.. //depot/projects/ia64/share/man/man4/man4.i386/sbni.4#2 integrate
.. //depot/projects/ia64/share/man/man4/man4.i386/vpd.4#2 integrate
.. //depot/projects/ia64/share/man/man4/my.4#2 integrate
.. //depot/projects/ia64/share/man/man4/rndtest.4#2 integrate
.. //depot/projects/ia64/share/man/man4/rue.4#2 integrate
.. //depot/projects/ia64/share/man/man4/sbsh.4#2 integrate
.. //depot/projects/ia64/share/man/man5/libmap.conf.5#2 integrate
.. //depot/projects/ia64/sys/amd64/amd64/amd64-gdbstub.c#1 branch
.. //depot/projects/ia64/sys/amd64/amd64/db_disasm.c#1 branch
.. //depot/projects/ia64/sys/amd64/amd64/db_interface.c#1 branch
.. //depot/projects/ia64/sys/amd64/amd64/db_trace.c#1 branch
.. //depot/projects/ia64/sys/amd64/amd64/support.S#4 integrate
.. //depot/projects/ia64/sys/amd64/include/db_machdep.h#2 integrate
.. //depot/projects/ia64/sys/conf/Makefile.amd64#5 integrate
.. //depot/projects/ia64/sys/conf/files.amd64#6 integrate
.. //depot/projects/ia64/sys/dev/usb/ugen.c#13 integrate
.. //depot/projects/ia64/sys/ia64/ia64/machdep.c#72 integrate
.. //depot/projects/ia64/sys/ia64/ia64/unaligned.c#3 integrate
.. //depot/projects/ia64/sys/ia64/include/cpu.h#15 integrate
.. //depot/projects/ia64/sys/kern/kern_sysctl.c#19 integrate
.. //depot/projects/ia64/sys/kern/subr_mbuf.c#27 integrate
.. //depot/projects/ia64/sys/kern/uipc_syscalls.c#32 integrate
.. //depot/projects/ia64/sys/security/mac_biba/mac_biba.c#16 integrate
.. //depot/projects/ia64/sys/security/mac_mls/mac_mls.c#15 integrate
.. //depot/projects/ia64/sys/sparc64/sparc64/tick.c#10 integrate

Differences ...

==== //depot/projects/ia64/contrib/amd/conf/transp/transp_sockets.c#2 (text+ko) ====

@@ -50,6 +50,9 @@
 #include <am_defs.h>
 #include <amu.h>
 
+#ifndef RPC_MAXDATASIZE
+#define RPC_MAXDATASIZE 9000
+#endif
 
 /*
  * find the IP address that can be used to connect to the local host
@@ -216,6 +219,8 @@
 int
 create_amq_service(int *udp_soAMQp, SVCXPRT **udp_amqpp, int *tcp_soAMQp, SVCXPRT **tcp_amqpp)
 {
+  int maxrec = RPC_MAXDATASIZE;
+
   /* first create TCP service */
   if (tcp_soAMQp) {
     *tcp_soAMQp = socket(AF_INET, SOCK_STREAM, 0);
@@ -231,6 +236,9 @@
       return 2;
     }
   }
+#ifdef SVCSET_CONNMAXREC
+	SVC_CONTROL(*tcp_amqpp, SVCSET_CONNMAXREC, &maxrec);
+#endif
 
   /* next create UDP service */
   if (udp_soAMQp) {

==== //depot/projects/ia64/lib/libc/rpc/svc_vc.c#8 (text+ko) ====

@@ -34,7 +34,7 @@
 static char *sccsid = "@(#)svc_tcp.c	2.2 88/08/01 4.0 RPCSRC";
 #endif
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/lib/libc/rpc/svc_vc.c,v 1.18 2003/05/28 09:16:35 mbr Exp $");
+__FBSDID("$FreeBSD: src/lib/libc/rpc/svc_vc.c,v 1.20 2003/05/29 22:06:06 mbr Exp $");
 
 /*
  * svc_vc.c, Server side for Connection Oriented based RPC. 
@@ -487,6 +487,8 @@
 
 	cfp = (struct cf_conn *)xprt->xp_p1;
 
+	cm = NULL;
+	sa = (struct sockaddr *)xprt->xp_rtaddr.buf;
 	if (cfp->nonblock) {
 		if (sa->sa_family == AF_LOCAL) {
 			cm = (struct cmessage *)xprt->xp_verf.oa_base;
@@ -522,8 +524,6 @@
 		}
 	} while ((pollfd.revents & POLLIN) == 0);
 
-	cm = NULL;
-	sa = (struct sockaddr *)xprt->xp_rtaddr.buf;
 	if (sa->sa_family == AF_LOCAL) {
 		cm = (struct cmessage *)xprt->xp_verf.oa_base;
 		if ((len = __msgread_withcred(sock, buf, len, cm)) > 0) {
@@ -779,8 +779,7 @@
 	bcopy(&cm.cmsg, &cmp->cmsg, sizeof(cmp->cmsg));
 	bcopy(CMSG_DATA(&cm), &cmp->cmcred, sizeof(cmp->cmcred));
 
-	if (msg.msg_controllen == 0 ||
-	   (msg.msg_flags & MSG_CTRUNC) != 0)
+	if ((msg.msg_flags & MSG_CTRUNC) != 0)
 		return (-1);
 
 	return (ret);

==== //depot/projects/ia64/lib/libpthread/Makefile#7 (text+ko) ====

@@ -1,4 +1,4 @@
-# $FreeBSD: src/lib/libpthread/Makefile,v 1.41 2003/04/25 01:31:56 deischen Exp $
+# $FreeBSD: src/lib/libpthread/Makefile,v 1.42 2003/05/30 00:21:51 kan Exp $
 #
 # All library objects contain FreeBSD revision strings by default; they may be
 # excluded as a space-saving measure.  To produce a library that does
@@ -14,12 +14,16 @@
 	-I${.CURDIR}/../../include
 CFLAGS+=-I${.CURDIR}/arch/${MACHINE_ARCH}/include
 CFLAGS+=-I${.CURDIR}/sys
+CFLAGS+=-I${.CURDIR}/../../libexec/rtld-elf
+CFLAGS+=-fno-builtin
 
 # Uncomment this if you want libpthread to contain debug information for
 # thread locking.
 CFLAGS+=-D_LOCK_DEBUG
 #CFLAGS+= -g
 
+LDADD+= -Wl,--version-script=${.CURDIR}/pthread.map
+
 # enable extra internal consistancy checks
 CFLAGS+=-D_PTHREADS_INVARIANTS -Wall
 
@@ -28,5 +32,6 @@
 
 .include "${.CURDIR}/thread/Makefile.inc"
 .include "${.CURDIR}/sys/Makefile.inc"
+.include "${.CURDIR}/support/Makefile.inc"
 
 .include <bsd.lib.mk>

==== //depot/projects/ia64/lib/libpthread/sys/Makefile.inc#4 (text+ko) ====

@@ -1,6 +1,7 @@
-# $FreeBSD: src/lib/libpthread/sys/Makefile.inc,v 1.13 2003/04/18 05:02:39 deischen Exp $
+# $FreeBSD: src/lib/libpthread/sys/Makefile.inc,v 1.14 2003/05/30 00:21:52 kan Exp $
 
 .PATH:	 ${.CURDIR}/sys ${.CURDIR}/arch/${MACHINE_ARCH}/${MACHINE_ARCH}
 
 SRCS+=	thr_error.c _atomic_lock.S ksd.c thr_enter_uts.S thr_getcontext.S \
 	thr_switch.S lock.c
+

==== //depot/projects/ia64/lib/libpthread/thread/Makefile.inc#8 (text+ko) ====

@@ -1,4 +1,4 @@
-# $FreeBSD: src/lib/libpthread/thread/Makefile.inc,v 1.40 2003/04/22 20:29:16 deischen Exp $
+# $FreeBSD: src/lib/libpthread/thread/Makefile.inc,v 1.41 2003/05/30 00:21:52 kan Exp $
 
 # thr sources
 .PATH: ${.CURDIR}/thread
@@ -71,6 +71,7 @@
 	thr_read.c \
 	thr_readv.c \
 	thr_resume_np.c \
+	thr_rtld.c \
 	thr_rwlock.c \
 	thr_rwlockattr.c \
 	thr_select.c \

==== //depot/projects/ia64/lib/libpthread/thread/thr_cond.c#10 (text+ko) ====

@@ -29,7 +29,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/lib/libpthread/thread/thr_cond.c,v 1.42 2003/05/24 02:29:25 deischen Exp $
+ * $FreeBSD: src/lib/libpthread/thread/thr_cond.c,v 1.43 2003/05/30 00:21:52 kan Exp $
  */
 #include <stdlib.h>
 #include <errno.h>
@@ -355,6 +355,8 @@
 	return (rval);
 }
 
+__strong_reference(_pthread_cond_wait, _thr_cond_wait);
+
 int
 __pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
 {
@@ -632,6 +634,8 @@
 	return (rval);
 }
 
+__strong_reference(_pthread_cond_signal, _thr_cond_signal);
+
 int
 _pthread_cond_broadcast(pthread_cond_t * cond)
 {
@@ -673,7 +677,7 @@
 			/* There are no more waiting threads: */
 			(*cond)->c_mutex = NULL;
 			break;
-	
+
 		/* Trap invalid condition variable types: */
 		default:
 			/* Return an invalid argument error: */
@@ -689,6 +693,8 @@
 	return (rval);
 }
 
+__strong_reference(_pthread_cond_broadcast, _thr_cond_broadcast);
+
 void
 _cond_wait_backout(struct pthread *curthread)
 {

==== //depot/projects/ia64/lib/libpthread/thread/thr_exit.c#5 (text+ko) ====

@@ -29,7 +29,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/lib/libpthread/thread/thr_exit.c,v 1.32 2003/05/16 19:58:29 deischen Exp $
+ * $FreeBSD: src/lib/libpthread/thread/thr_exit.c,v 1.33 2003/05/30 00:21:52 kan Exp $
  */
 #include <errno.h>
 #include <unistd.h>
@@ -47,16 +47,12 @@
 void
 _thr_exit(char *fname, int lineno, char *msg)
 {
-	char s[256];
 
-	/* Prepare an error message string: */
-	snprintf(s, sizeof(s),
+	/* Write an error message to the standard error file descriptor: */
+	_thread_printf(2,
 	    "Fatal error '%s' at line %d in file %s (errno = %d)\n",
 	    msg, lineno, fname, errno);
 
-	/* Write the string to the standard error file descriptor: */
-	__sys_write(2, s, strlen(s));
-
 	abort();
 }
 

==== //depot/projects/ia64/lib/libpthread/thread/thr_init.c#10 (text+ko) ====

@@ -30,7 +30,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/lib/libpthread/thread/thr_init.c,v 1.52 2003/05/16 19:58:29 deischen Exp $
+ * $FreeBSD: src/lib/libpthread/thread/thr_init.c,v 1.54 2003/05/30 00:21:52 kan Exp $
  */
 
 /* Allocate space for global thread variables here: */
@@ -304,6 +304,8 @@
 	_thr_initial->kse->k_curthread = _thr_initial;
 	_thr_initial->kse->k_flags |= KF_INITIALIZED;
 	_kse_initial->k_curthread = _thr_initial;
+	
+	_thr_rtld_init();
 }
 
 /*
@@ -515,6 +517,7 @@
 	if (_lock_init(&_keytable_lock, LCK_ADAPTIVE,
 	    _thr_lock_wait, _thr_lock_wakeup) != 0)
 		PANIC("Cannot initialize thread specific keytable lock");
+	_thr_spinlock_init();
 
 	/* Clear pending signals and get the process signal mask. */
 	sigemptyset(&_thr_proc_sigpending);

==== //depot/projects/ia64/lib/libpthread/thread/thr_mutex.c#5 (text+ko) ====

@@ -29,7 +29,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/lib/libpthread/thread/thr_mutex.c,v 1.35 2003/05/16 19:58:29 deischen Exp $
+ * $FreeBSD: src/lib/libpthread/thread/thr_mutex.c,v 1.36 2003/05/30 00:21:52 kan Exp $
  */
 #include <stdlib.h>
 #include <errno.h>
@@ -718,6 +718,8 @@
 	return (ret);
 }
 
+__strong_reference(__pthread_mutex_lock, _thr_mutex_lock);
+
 int
 _pthread_mutex_lock(pthread_mutex_t *m)
 {
@@ -748,6 +750,8 @@
 	return (mutex_unlock_common(m, /* add reference */ 0));
 }
 
+__strong_reference(_pthread_mutex_unlock, _thr_mutex_unlock);
+
 int
 _mutex_cv_unlock(pthread_mutex_t *m)
 {

==== //depot/projects/ia64/lib/libpthread/thread/thr_private.h#13 (text+ko) ====

@@ -31,7 +31,7 @@
  *
  * Private thread definitions for the uthread kernel.
  *
- * $FreeBSD: src/lib/libpthread/thread/thr_private.h,v 1.87 2003/05/16 19:58:29 deischen Exp $
+ * $FreeBSD: src/lib/libpthread/thread/thr_private.h,v 1.89 2003/05/30 00:21:52 kan Exp $
  */
 
 #ifndef _THR_PRIVATE_H
@@ -794,6 +794,11 @@
 	struct pthread_specific_elem	*specific;
 	int				specific_data_count;
 
+	/*
+	 * Current locks bitmap for rtld.
+	 */
+	int	rtld_bits;
+
 	/* Cleanup handlers Link List */
 	struct pthread_cleanup *cleanup;
 	char			*fname;	/* Ptr to source file name  */
@@ -1084,6 +1089,8 @@
 int	_pthread_mutexattr_destroy(pthread_mutexattr_t *);
 int	_pthread_mutexattr_settype(pthread_mutexattr_t *, int);
 int	_pthread_once(pthread_once_t *, void (*) (void));
+int	_pthread_rwlock_init(pthread_rwlock_t *, const pthread_rwlockattr_t *);
+int	_pthread_rwlock_destroy (pthread_rwlock_t *);
 struct pthread *_pthread_self(void);
 int	_pthread_setspecific(pthread_key_t, const void *);
 struct pthread *_thr_alloc(struct pthread *);
@@ -1114,6 +1121,7 @@
 void	_thr_sched_switch(struct pthread *);
 void	_thr_sched_switch_unlocked(struct pthread *);
 void    _thr_set_timeout(const struct timespec *);
+void	_thr_seterrno(struct pthread *, int);
 void    _thr_sig_handler(int, siginfo_t *, ucontext_t *);
 void    _thr_sig_check_pending(struct pthread *);
 void	_thr_sig_rundown(struct pthread *, ucontext_t *,
@@ -1121,12 +1129,25 @@
 void	_thr_sig_send(struct pthread *pthread, int sig);
 void	_thr_sig_wrapper(void);
 void	_thr_sigframe_restore(struct pthread *thread, struct pthread_sigframe *psf);
-void	_thr_seterrno(struct pthread *, int);
+void	_thr_spinlock_init(void);
 void	_thr_enter_cancellation_point(struct pthread *);
 void	_thr_leave_cancellation_point(struct pthread *);
 int	_thr_setconcurrency(int new_level);
 int	_thr_setmaxconcurrency(void);
 
+/*
+ * Aliases for _pthread functions. Should be called instead of
+ * originals if PLT replocation is unwanted at runtme.
+ */
+int	_thr_cond_broadcast(pthread_cond_t *);
+int	_thr_cond_signal(pthread_cond_t *);
+int	_thr_cond_wait(pthread_cond_t *, pthread_mutex_t *);
+int	_thr_mutex_lock(pthread_mutex_t *);
+int	_thr_mutex_unlock(pthread_mutex_t *);
+int	_thr_rwlock_rdlock (pthread_rwlock_t *);
+int	_thr_rwlock_wrlock (pthread_rwlock_t *);
+int	_thr_rwlock_unlock (pthread_rwlock_t *);
+
 /* XXX - Stuff that goes away when my sources get more up to date. */
 /* #include <sys/kse.h> */
 #ifdef SYS_KSE_H

==== //depot/projects/ia64/lib/libpthread/thread/thr_rwlock.c#5 (text+ko) ====

@@ -23,7 +23,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/lib/libpthread/thread/thr_rwlock.c,v 1.11 2003/04/18 05:04:16 deischen Exp $
+ * $FreeBSD: src/lib/libpthread/thread/thr_rwlock.c,v 1.12 2003/05/30 00:21:52 kan Exp $
  */
 
 #include <errno.h>
@@ -46,7 +46,6 @@
 __weak_reference(_pthread_rwlock_unlock, pthread_rwlock_unlock);
 __weak_reference(_pthread_rwlock_wrlock, pthread_rwlock_wrlock);
 
-
 /*
  * Prototypes
  */
@@ -158,16 +157,16 @@
 	}
 
 	/* grab the monitor lock */
-	if ((ret = _pthread_mutex_lock(&prwlock->lock)) != 0)
+	if ((ret = _thr_mutex_lock(&prwlock->lock)) != 0)
 		return (ret);
 
 	/* give writers priority over readers */
 	while (prwlock->blocked_writers || prwlock->state < 0) {
-		ret = _pthread_cond_wait(&prwlock->read_signal, &prwlock->lock);
+		ret = _thr_cond_wait(&prwlock->read_signal, &prwlock->lock);
 
 		if (ret != 0) {
 			/* can't do a whole lot if this fails */
-			_pthread_mutex_unlock(&prwlock->lock);
+			_thr_mutex_unlock(&prwlock->lock);
 			return (ret);
 		}
 	}
@@ -184,11 +183,13 @@
 	 * lock.  Decrementing 'state' is no good because we probably
 	 * don't have the monitor lock.
 	 */
-	_pthread_mutex_unlock(&prwlock->lock);
+	_thr_mutex_unlock(&prwlock->lock);
 
 	return (ret);
 }
 
+__strong_reference(_pthread_rwlock_rdlock, _thr_rwlock_rdlock);
+
 int
 _pthread_rwlock_tryrdlock (pthread_rwlock_t *rwlock)
 {
@@ -276,28 +277,30 @@
 		return (EINVAL);
 
 	/* grab the monitor lock */
-	if ((ret = _pthread_mutex_lock(&prwlock->lock)) != 0)
+	if ((ret = _thr_mutex_lock(&prwlock->lock)) != 0)
 		return (ret);
 
 	if (prwlock->state > 0) {
 		if (--prwlock->state == 0 && prwlock->blocked_writers)
-			ret = _pthread_cond_signal(&prwlock->write_signal);
+			ret = _thr_cond_signal(&prwlock->write_signal);
 	} else if (prwlock->state < 0) {
 		prwlock->state = 0;
 
 		if (prwlock->blocked_writers)
-			ret = _pthread_cond_signal(&prwlock->write_signal);
+			ret = _thr_cond_signal(&prwlock->write_signal);
 		else
-			ret = _pthread_cond_broadcast(&prwlock->read_signal);
+			ret = _thr_cond_broadcast(&prwlock->read_signal);
 	} else
 		ret = EINVAL;
 
 	/* see the comment on this in pthread_rwlock_rdlock */
-	_pthread_mutex_unlock(&prwlock->lock);
+	_thr_mutex_unlock(&prwlock->lock);
 
 	return (ret);
 }
 
+__strong_reference(_pthread_rwlock_unlock, _thr_rwlock_unlock);
+
 int
 _pthread_rwlock_wrlock (pthread_rwlock_t *rwlock)
 {
@@ -318,17 +321,17 @@
 	}
 
 	/* grab the monitor lock */
-	if ((ret = _pthread_mutex_lock(&prwlock->lock)) != 0)
+	if ((ret = _thr_mutex_lock(&prwlock->lock)) != 0)
 		return (ret);
 
 	while (prwlock->state != 0) {
 		++prwlock->blocked_writers;
 
-		ret = _pthread_cond_wait(&prwlock->write_signal, &prwlock->lock);
+		ret = _thr_cond_wait(&prwlock->write_signal, &prwlock->lock);
 
 		if (ret != 0) {
 			--prwlock->blocked_writers;
-			_pthread_mutex_unlock(&prwlock->lock);
+			_thr_mutex_unlock(&prwlock->lock);
 			return (ret);
 		}
 
@@ -339,7 +342,9 @@
 	prwlock->state = -1;
 
 	/* see the comment on this in pthread_rwlock_rdlock */
-	_pthread_mutex_unlock(&prwlock->lock);
+	_thr_mutex_unlock(&prwlock->lock);
 
 	return (ret);
 }
+
+__strong_reference(_pthread_rwlock_wrlock, _thr_rwlock_wrlock);

==== //depot/projects/ia64/lib/libpthread/thread/thr_sig.c#10 (text+ko) ====

@@ -29,7 +29,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/lib/libpthread/thread/thr_sig.c,v 1.51 2003/05/24 02:29:25 deischen Exp $
+ * $FreeBSD: src/lib/libpthread/thread/thr_sig.c,v 1.52 2003/05/29 17:10:45 deischen Exp $
  */
 #include <sys/param.h>
 #include <sys/types.h>
@@ -175,7 +175,7 @@
 void
 _thr_sig_handler(int sig, siginfo_t *info, ucontext_t *ucp)
 {
-	void (*sigfunc)(int, siginfo_t *, void *);
+	__siginfohandler_t *sigfunc;
 	struct kse *curkse;
 
 	curkse = _get_curkse();
@@ -184,7 +184,8 @@
 		sigfunc = _thread_sigact[sig - 1].sa_sigaction;
 		ucp->uc_sigmask = _thr_proc_sigmask;
 		if (((__sighandler_t *)sigfunc != SIG_DFL) &&
-		    ((__sighandler_t *)sigfunc != SIG_IGN)) {
+		    ((__sighandler_t *)sigfunc != SIG_IGN) &&
+		    (sigfunc != (__siginfohandler_t *)_thr_sig_handler)) {
 			if (((_thread_sigact[sig - 1].sa_flags & SA_SIGINFO)
 			    != 0) || (info == NULL))
 				(*(sigfunc))(sig, info, ucp);

==== //depot/projects/ia64/lib/libpthread/thread/thr_sigprocmask.c#2 (text+ko) ====

@@ -29,7 +29,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/lib/libpthread/thread/thr_sigprocmask.c,v 1.13 2002/09/16 08:45:36 mini Exp $
+ * $FreeBSD: src/lib/libpthread/thread/thr_sigprocmask.c,v 1.14 2003/05/30 00:09:22 deischen Exp $
  */
 #include <sys/param.h>
 #include <sys/types.h>
@@ -44,5 +44,8 @@
 int
 _sigprocmask(int how, const sigset_t *set, sigset_t *oset)
 {
-	return (pthread_sigmask(how, set, oset));
+	if (_kse_isthreaded() != 0)
+		return (pthread_sigmask(how, set, oset));
+	else
+		return (__sys_sigprocmask(how, set, oset));
 }

==== //depot/projects/ia64/lib/libpthread/thread/thr_spinlock.c#5 (text+ko) ====

@@ -29,7 +29,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/lib/libpthread/thread/thr_spinlock.c,v 1.15 2003/04/28 23:56:12 deischen Exp $
+ * $FreeBSD: src/lib/libpthread/thread/thr_spinlock.c,v 1.16 2003/05/29 17:10:45 deischen Exp $
  *
  */
 
@@ -40,6 +40,20 @@
 #include "spinlock.h"
 #include "thr_private.h"
 
+#define	MAX_SPINLOCKS	5
+
+struct spinlock_extra {
+	struct lock	lock;
+	kse_critical_t	crit;
+};
+
+static void	init_spinlock(spinlock_t *lck);
+
+static struct lock		spinlock_static_lock;
+static struct spinlock_extra	extra[MAX_SPINLOCKS];
+static int			spinlock_count = 0;
+static int			initialized = 0;
+
 /*
  * These are for compatability only.  Spinlocks of this type
  * are deprecated.
@@ -48,12 +62,13 @@
 void
 _spinunlock(spinlock_t *lck)
 {
+	struct spinlock_extra *extra;
 	kse_critical_t crit;
 
-	crit = (kse_critical_t)lck->fname;
-	atomic_store_rel_long(&lck->access_lock, 0);
-	if (crit != NULL)
-		_kse_critical_leave(crit);
+	extra = (struct spinlock_extra *)lck->fname;
+	crit = extra->crit;
+	KSE_LOCK_RELEASE(_get_curkse(), &extra->lock);
+	_kse_critical_leave(crit);
 }
 
 
@@ -66,21 +81,21 @@
 void
 _spinlock(spinlock_t *lck)
 {
+	struct spinlock_extra *extra;
 	kse_critical_t crit;
 
+	THR_ASSERT(__isthreaded != 0, "Spinlock called when not threaded.");
+	THR_ASSERT(initialized != 0, "Spinlocks not initialized.");
 	/*
 	 * Try to grab the lock and loop if another thread grabs
 	 * it before we do.
 	 */
-	if (_kse_isthreaded())
-		crit = _kse_critical_enter();
-	else
-		crit = NULL;
-	while(_atomic_lock(&lck->access_lock)) {
-		while (lck->access_lock)
-			;
-	}
-	lck->fname = (char *)crit;
+	crit = _kse_critical_enter();
+	if (lck->fname == NULL)
+		init_spinlock(lck);
+	extra = (struct spinlock_extra *)lck->fname;
+	KSE_LOCK_ACQUIRE(_get_curkse(), &extra->lock);
+	extra->crit = crit;
 }
 
 /*
@@ -98,3 +113,40 @@
 {
 	_spinlock(lck);
 }
+
+static void
+init_spinlock(spinlock_t *lck)
+{
+	struct kse *curkse = _get_curkse();
+
+	KSE_LOCK_ACQUIRE(curkse, &spinlock_static_lock);
+	if ((lck->fname == NULL) && (spinlock_count < MAX_SPINLOCKS)) {
+		lck->fname = (char *)&extra[spinlock_count];
+		spinlock_count++;
+	}
+	KSE_LOCK_RELEASE(curkse, &spinlock_static_lock);
+	THR_ASSERT(lck->fname != NULL, "Exceeded max spinlocks");
+}
+
+void
+_thr_spinlock_init(void)
+{
+	int i;
+
+	if (initialized != 0) {
+		_lock_destroy(&spinlock_static_lock);
+		for (i = 0; i < MAX_SPINLOCKS; i++) {
+			_lock_destroy(&extra[i].lock);
+		}
+	}
+
+	if (_lock_init(&spinlock_static_lock, LCK_ADAPTIVE,
+	    _kse_lock_wait, _kse_lock_wakeup) != 0)
+		PANIC("Cannot initialize spinlock_static_lock");
+	for (i = 0; i < MAX_SPINLOCKS; i++) {
+		if (_lock_init(&extra[i].lock, LCK_ADAPTIVE,
+		    _kse_lock_wait, _kse_lock_wakeup) != 0)
+			PANIC("Cannot initialize spinlock extra");
+	}
+	initialized = 1;
+}

==== //depot/projects/ia64/lib/libthr/arch/i386/i386/_setcurthread.c#6 (text+ko) ====

@@ -23,7 +23,7 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: src/lib/libthr/arch/i386/i386/_setcurthread.c,v 1.8 2003/05/25 22:40:57 mtm Exp $
+ * $FreeBSD: src/lib/libthr/arch/i386/i386/_setcurthread.c,v 1.9 2003/05/29 20:49:17 mtm Exp $
  */
 
 #include <sys/types.h>
@@ -111,6 +111,8 @@
 	if (ldt_free == NULL) {
 		/* Concurrent thread limit reached */
 		*err = curthread->error = EAGAIN;
+		if (thr != _thread_initial)
+			_SPINUNLOCK(&ldt_lock);
 		return (NULL);
 	}
 

==== //depot/projects/ia64/lib/libthr/thread/thr_cond.c#5 (text+ko) ====

@@ -29,7 +29,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/lib/libthr/thread/thr_cond.c,v 1.6 2003/05/24 01:02:16 mtm Exp $
+ * $FreeBSD: src/lib/libthr/thread/thr_cond.c,v 1.7 2003/05/29 20:54:00 mtm Exp $
  */
 #include <stdlib.h>
 #include <errno.h>
@@ -38,8 +38,15 @@
 #include "thr_private.h"
 
 /*
+ * Proctect two different threads calling a pthread_cond_* function
+ * from accidentally initializing the condition variable twice.
+ */
+static spinlock_t static_cond_lock = _SPINLOCK_INITIALIZER;
+
+/*
  * Prototypes
  */
+static inline int	cond_init(pthread_cond_t *);
 static pthread_t	cond_queue_deq(pthread_cond_t);
 static void		cond_queue_remove(pthread_cond_t, pthread_t);
 static void		cond_queue_enq(pthread_cond_t, pthread_t);
@@ -202,7 +209,7 @@
 	 * If the condition variable is statically initialized, perform dynamic
 	 * initialization.
 	 */
-	if (*cond == NULL && (rval = pthread_cond_init(cond, NULL)) != 0)
+	if (*cond == PTHREAD_COND_INITIALIZER && (rval = cond_init(cond)) != 0)
 		return (rval);
 
 
@@ -363,7 +370,7 @@
         * If the condition variable is statically initialized, perform dynamic
         * initialization.
         */
-	if (*cond == NULL && (rval = pthread_cond_init(cond, NULL)) != 0)
+	if (*cond == PTHREAD_COND_INITIALIZER && (rval = cond_init(cond)) != 0)
 		return (rval);
 
 	COND_LOCK(*cond);
@@ -518,3 +525,14 @@
 	pthread->flags |= PTHREAD_FLAGS_IN_CONDQ;
 	pthread->data.cond = cond;
 }
+
+static inline int
+cond_init(pthread_cond_t *cond)
+{
+	_SPINLOCK(&static_cond_lock);
+	if (*cond == PTHREAD_COND_INITIALIZER)
+		return (_pthread_cond_init(cond, NULL));
+	_SPINUNLOCK(&static_cond_lock);
+	return (0);
+}
+

==== //depot/projects/ia64/lib/libthr/thread/thr_create.c#8 (text+ko) ====

@@ -29,7 +29,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/lib/libthr/thread/thr_create.c,v 1.9 2003/05/26 00:37:07 mtm Exp $
+ * $FreeBSD: src/lib/libthr/thread/thr_create.c,v 1.10 2003/05/29 20:40:50 mtm Exp $
  */
 #include <errno.h>
 #include <stdlib.h>
@@ -171,7 +171,6 @@
 	new_thread->uniqueid = next_uniqueid++;
 
 	THREAD_LIST_LOCK;
-	_thread_critical_enter(new_thread);
 
 	/*
 	 * Check if the garbage collector thread
@@ -182,8 +181,6 @@
 	/* Add the thread to the linked list of all threads: */
 	TAILQ_INSERT_HEAD(&_thread_list, new_thread, tle);
 
-	THREAD_LIST_UNLOCK;
-
 	/*
 	 * Create the thread.
 	 *
@@ -200,11 +197,11 @@
 		PANIC("thr_create");
 	}
 
+	THREAD_LIST_UNLOCK;
+
 	/* Return a pointer to the thread structure: */
 	(*thread) = new_thread;
 
-	_thread_critical_exit(new_thread);
-
 	/*
 	 * Start a garbage collector thread
 	 * if necessary.

==== //depot/projects/ia64/lib/libthr/thread/thr_exit.c#6 (text+ko) ====

@@ -29,7 +29,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/lib/libthr/thread/thr_exit.c,v 1.7 2003/05/27 21:48:42 mtm Exp $
+ * $FreeBSD: src/lib/libthr/thread/thr_exit.c,v 1.8 2003/05/29 20:46:53 mtm Exp $
  */
 #include <errno.h>
 #include <unistd.h>
@@ -173,28 +173,30 @@
 	PTHREAD_SET_STATE(curthread, PS_DEAD);
 	_thread_critical_exit(curthread);
 	
+	/* If we're the last thread, call it quits */
+	if (TAILQ_EMPTY(&_thread_list))
+		exitNow = 1;
+
+	THREAD_LIST_UNLOCK;
+
 	/*
 	 * Signal the garbage collector thread that there is something
-	 * to clean up.
+	 * to clean up. But don't allow it to free the memory until after
+	 * it is retired by holding on to the dead list lock.
 	 */
 	if (pthread_cond_signal(&_gc_cond) != 0)
 		PANIC("Cannot signal gc cond");
 
-	/* If we're the last thread, call it quits */
-	if (TAILQ_EMPTY(&_thread_list))
-		exitNow = 1;
+	if (exitNow)
+		exit(0);
 
-	THREAD_LIST_UNLOCK;
 	DEAD_LIST_UNLOCK;
 
-	if (exitNow)
-		exit(0);
-
 	/*
-	 * Retire the architecture specific id so that it can be used for
-	 * new threads.
+	 * This function will not return unless we are the last
+	 * thread, which we can't be because we've already checked
+	 * for that.
 	 */
-	_retire_thread(curthread->arch_id);
 	_thr_exit();
 
 	/* This point should not be reached. */

==== //depot/projects/ia64/lib/libthr/thread/thr_gc.c#6 (text+ko) ====

@@ -29,7 +29,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/lib/libthr/thread/thr_gc.c,v 1.5 2003/05/26 00:37:07 mtm Exp $
+ * $FreeBSD: src/lib/libthr/thread/thr_gc.c,v 1.6 2003/05/29 20:46:53 mtm Exp $
  *
  * Garbage collector thread. Frees memory allocated for dead threads.
  *
@@ -142,6 +142,13 @@
 			pthread_cln = pthread;
 
 			_SPINUNLOCK(&pthread->lock);
+
+			/*
+		 	 * Retire the architecture specific id so it may be
+		 	 * used for new threads.
+			 */
+			_retire_thread(pthread_cln->arch_id);
+
 		}
 
 		/*

==== //depot/projects/ia64/lib/libthr/thread/thr_join.c#6 (text+ko) ====

@@ -29,7 +29,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/lib/libthr/thread/thr_join.c,v 1.7 2003/05/27 21:43:49 mtm Exp $
+ * $FreeBSD: src/lib/libthr/thread/thr_join.c,v 1.8 2003/05/29 20:46:53 mtm Exp $
  */
 #include <errno.h>
 #include <pthread.h>
@@ -160,9 +160,9 @@
 		/* Make the thread collectable by the garbage collector. */
 		pthread->attr.flags |= PTHREAD_DETACHED;
 		_SPINUNLOCK(&pthread->lock);
+		THREAD_LIST_UNLOCK;
 		if (pthread_cond_signal(&_gc_cond) != 0)
 			PANIC("Cannot signal gc cond");
-		THREAD_LIST_UNLOCK;
 		DEAD_LIST_UNLOCK;
 	}
 

==== //depot/projects/ia64/lib/libthr/thread/thr_mutex.c#6 (text+ko) ====

@@ -29,7 +29,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/lib/libthr/thread/thr_mutex.c,v 1.8 2003/05/23 09:48:20 mtm Exp $
+ * $FreeBSD: src/lib/libthr/thread/thr_mutex.c,v 1.9 2003/05/29 20:58:31 mtm Exp $
  */
 #include <stdlib.h>
 #include <errno.h>
@@ -101,7 +101,7 @@
 
 	if (mutex == NULL)
 		ret = EINVAL;
-	else if (*mutex == NULL)
+	else if (*mutex == PTHREAD_MUTEX_INITIALIZER)
 		ret = _pthread_mutex_init(mutex, NULL);
 	else {
 		/*
@@ -269,35 +269,25 @@
 static int
 init_static(pthread_mutex_t *mutex)
 {
-	int	ret;
-
 	_SPINLOCK(&static_init_lock);
-
-	if (*mutex == NULL)
-		ret = _pthread_mutex_init(mutex, NULL);
-	else
-		ret = 0;
-
+	if (*mutex == PTHREAD_MUTEX_INITIALIZER) {
+		_SPINUNLOCK(&static_init_lock);
+		return(_pthread_mutex_init(mutex, NULL));
+	}
 	_SPINUNLOCK(&static_init_lock);
-
-	return (ret);
+	return (0);
 }
 
 static int
 init_static_private(pthread_mutex_t *mutex)
 {
-	int	ret;
-
 	_SPINLOCK(&static_init_lock);
-
-	if (*mutex == NULL)

>>> TRUNCATED FOR MAIL (1000 lines) <<<


More information about the p4-projects mailing list