about summary refs log tree commit diff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2007-08-15 06:39:43 +0000
committerUlrich Drepper <drepper@redhat.com>2007-08-15 06:39:43 +0000
commitc20455999c80f6d0f80d99e317ba05a803b76f60 (patch)
treeaa01ef93db5f624436c11dfc3ed1ad6847fe0340
parent467d1345e0b6e379954d255f88504b8fe1af6e7b (diff)
downloadglibc-c20455999c80f6d0f80d99e317ba05a803b76f60.tar.gz
glibc-c20455999c80f6d0f80d99e317ba05a803b76f60.tar.xz
glibc-c20455999c80f6d0f80d99e317ba05a803b76f60.zip
(__pthread_cond_broadcast): Pass LLL_PRIVATE to lll_* and or FUTEX_PRIVATE_FLAG into SYS_futex op if cv is process private. Don't use FUTEX_CMP_REQUEUE if dep_mutex is not process private.
-rw-r--r--nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_broadcast.S54
1 files changed, 50 insertions, 4 deletions
diff --git a/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_broadcast.S b/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_broadcast.S
index b173f2d8bf..7dff15ac52 100644
--- a/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_broadcast.S
+++ b/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_broadcast.S
@@ -93,13 +93,24 @@ __pthread_cond_broadcast:
 	bt/s	9f
 	 add	#cond_futex, r4
 
-	/* XXX: The kernel so far doesn't support requeue to PI futex.  */
+	/* XXX: The kernel only supports FUTEX_CMP_REQUEUE to the same
+	   type of futex (private resp. shared).  */
 	mov.l	@(MUTEX_KIND,r9), r0
-	tst	#PI_BIT, r0
+	tst	#(PI_BIT|PS_BIT), r0
 	bf	9f
 
 	/* Wake up all threads.  */
-	mov	#FUTEX_CMP_REQUEUE, r5
+#ifdef __ASSUME_PRIVATE_FUTEX
+	mov	#(FUTEX_CMP_REQUEUE|FUTEX_PRIVATE_FLAG), r5
+	extu.b	r5, r5
+#else
+	stc	gbr, r1
+	mov.w	.Lpfoff, r2
+	add	r2, r1
+	mov.l	@r1, r5
+	mov	#FUTEX_CMP_REQUEUE, r0
+	or	r0, r5
+#endif
 	mov	#1, r6
 	mov	#-1, r7
 	shlr	r7		/* r7 = 0x7fffffff */
@@ -156,7 +167,12 @@ __pthread_cond_broadcast:
 #if cond_lock != 0
 	add	#cond_lock, r5
 #endif
+	mov.l	@(dep_mutex,r8), r0
+	cmp/eq	#-1, r0
+	bf/s	99f
+	 mov	#LLL_PRIVATE, r6
 	mov	#LLL_SHARED, r6
+99:	
 	extu.b	r6, r6
 	mov.l	.Lwait5, r1
 	bsrf	r1
@@ -171,7 +187,12 @@ __pthread_cond_broadcast:
 #if cond_lock != 0
 	add	#cond_lock, r4
 #endif
+	mov.l	@(dep_mutex,r8), r0
+	cmp/eq	#-1, r0
+	bf/s	99f
+	 mov	#LLL_PRIVATE, r5
 	mov	#LLL_SHARED, r5
+99:	
 	mov.l	.Lwake5, r1
 	bsrf	r1
 	 extu.b	r5, r5
@@ -185,7 +206,12 @@ __pthread_cond_broadcast:
 #if cond_lock != 0
 	add	#cond_lock, r4
 #endif
+	mov	#-1, r0
+	cmp/eq	r0, r9
+	bf/s	99f
+	 mov	#LLL_PRIVATE, r5
 	mov	#LLL_SHARED, r5
+99:	
 	mov.l	.Lwake6, r1
 	bsrf	r1
 	 extu.b	r5, r5
@@ -194,7 +220,22 @@ __pthread_cond_broadcast:
 	 nop
 
 9:
-	mov	#FUTEX_WAKE, r5
+	mov	#-1, r0
+	cmp/eq	r0, r9
+	bt/s	99f
+	 mov	#FUTEX_WAKE, r5
+#ifdef __ASSUME_PRIVATE_FUTEX
+	mov	#(FUTEX_WAKE|FUTEX_PRIVATE_FLAG), r5
+	extu.b	r5, r5
+#else
+	stc	gbr, r1
+	mov.w	.Lpfoff, r2
+	add	r2, r1
+	mov.l	@r1, r5
+	mov	#FUTEX_WAKE, r0
+	or	r0, r5
+#endif
+99:	
 	mov	#-1, r6
 	shlr	r6		/* r6 = 0x7fffffff */
 	mov	#0, r7
@@ -205,6 +246,11 @@ __pthread_cond_broadcast:
 	bra	10b
 	 nop
 
+#ifndef __ASSUME_PRIVATE_FUTEX
+.Lpfoff:
+	.word	PRIVATE_FUTEX - TLS_PRE_TCB_SIZE
+#endif
+
 	.align	2
 .Lwait5:
 	.long	__lll_lock_wait-.Lwait5b