about summary refs log tree commit diff
path: root/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_wait.S
diff options
context:
space:
mode:
Diffstat (limited to 'nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_wait.S')
-rw-r--r--nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_wait.S73
1 files changed, 70 insertions, 3 deletions
diff --git a/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_wait.S b/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_wait.S
index b9190ab135..2d6b685668 100644
--- a/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_wait.S
+++ b/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_wait.S
@@ -107,6 +107,10 @@ __pthread_cond_wait:
 	mov.l	@(cond_futex,r8),r0
 	add	r2, r0
 	mov.l	r0,@(cond_futex,r8)
+	mov	#(1 << clock_bits), r2
+	mov.l	@(cond_nwaiters,r8), r0
+	add	r2, r0
+	mov.l	r0, @(cond_nwaiters,r8)
 
 	/* Get and store current wakeup_seq value.  */
 	mov.l	@(wakeup_seq,r8), r10
@@ -192,7 +196,36 @@ __pthread_cond_wait:
 	mov.l	r0,@(woken_seq,r8)
 	mov.l	r1,@(woken_seq+4,r8)
 
-16:	
+16:
+	mov	#(1 << clock_bits), r2
+	mov.l	@(cond_nwaiters,r8),r0
+	sub	r2, r0
+	mov.l	r0,@(cond_nwaiters,r8)
+
+	/* Wake up a thread which wants to destroy the condvar object.  */
+	mov.l	@(total_seq,r8),r0
+	mov.l	@(total_seq+4,r8),r1
+	and	r1, r0
+	not	r0, r0
+	cmp/eq	#0, r0
+	bf/s	17f
+	 mov	#((1 << clock_bits) - 1), r1
+	not	r1, r1
+	mov.l	@(cond_nwaiters,r8),r0
+	tst	r1, r0
+	bf	17f
+
+	mov	r8, r4
+	add	#cond_nwaiters, r4
+	mov	#FUTEX_WAKE, r5
+	mov	#1, r6
+	mov	#0, r7
+	mov	#SYS_futex, r3
+	extu.b	r3, r3
+	trapa	#0x14
+	SYSCALL_INST_PAD
+
+17:
 #if cond_lock != 0
 	DEC (@(cond_lock,r8), r2)
 #else
@@ -371,7 +404,38 @@ __condvar_w_cleanup:
 	mov.l	r0,@(woken_seq,r8)
 	mov.l	r1,@(woken_seq+4,r8)
 
-3:	
+3:
+	mov	#(1 << clock_bits), r2
+	mov.l	@(cond_nwaiters,r8),r0
+	sub	r2, r0
+	mov.l	r0,@(cond_nwaiters,r8)
+
+	/* Wake up a thread which wants to destroy the condvar object.  */
+	mov	#0, r10
+	mov.l	@(total_seq,r8),r0
+	mov.l	@(total_seq+4,r8),r1
+	and	r1, r0
+	not	r0, r0
+	cmp/eq	#0, r0
+	bf/s	4f
+	 mov	#((1 << clock_bits) - 1), r1
+	not	r1, r1
+	mov.l	@(cond_nwaiters,r8),r0
+	tst	r1, r0
+	bf	4f
+
+	mov	r8, r4
+	add	#cond_nwaiters, r4
+	mov	#FUTEX_WAKE, r5
+	mov	#1, r6
+	mov	#0, r7
+	mov	#SYS_futex, r3
+	extu.b	r3, r3
+	trapa	#0x14
+	SYSCALL_INST_PAD
+	mov	#1, r10
+
+4:
 #if cond_lock != 0
 	DEC (@(cond_lock,r8), r2)
 #else
@@ -391,7 +455,9 @@ __condvar_w_cleanup:
 
 2:
 	/* Wake up all waiters to make sure no signal gets lost.  */
-	mov	r8, r4
+	tst	r10, r10
+	bf/s	5f
+	 mov	r8, r4
 	add	#cond_futex, r4
 	mov	#FUTEX_WAKE, r5
 	mov	#-1, r6
@@ -402,6 +468,7 @@ __condvar_w_cleanup:
 	trapa	#0x14
 	SYSCALL_INST_PAD
 
+5:
         mov.l   .Lmlocki3, r1
         bsrf    r1
          mov     r9, r4