This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] SH: nptl fixups


Hi,

The appended patch updates the SH specific part of NPTL.

BTW, in translating recent i386 change into sh one, I've found
that __broadcast_seq field is stored into 20(%esp):

	movl	broadcast_seq(%ebx), %eax
	movl	%edi, 12(%esp)
	movl	%edx, 16(%esp)
	movl	%eax, 20(%esp)

in pthread_cond_timedwait.S:__pthread_cond_timedwait, while
it's compared with 12(%esp) in __condvar_tw_cleanup:

1:	movl	broadcast_seq(%ebx), %eax
	cmpl	12(%esp), %eax
	jne	3f

It should be "cmpl 20(%esp), %eax", shouldn't it?  

Regards,
	kaz
--
2004-06-01  Kaz Kojima  <kkojima@rr.iij4u.or.jp>

	* sysdeps/unix/sysv/linux/sh/bits/pthreadtypes.h (pthread_cond_t):
	Add __broadcast_seq field.
	* sysdeps/unix/sysv/linux/sh/pthread_cond_broadcast.S: Mark
	all waiters as woken with woken_seq and bump broadcast counter.
	* sysdeps/unix/sysv/linux/sh/pthread_cond_wait.S: Use new
	__broadcast_seq.  Increment __woken_seq correctly when cleanuped.
	* sysdeps/unix/sysv/linux/sh/pthread_cond_timedwait.S: Likewise.
	Comment typo fixes.  Avoid returning -ETIMEDOUT.

diff -u3prN ORIG/libc/nptl/sysdeps/unix/sysv/linux/sh/bits/pthreadtypes.h LOCAL/libc/nptl/sysdeps/unix/sysv/linux/sh/bits/pthreadtypes.h
--- ORIG/libc/nptl/sysdeps/unix/sysv/linux/sh/bits/pthreadtypes.h	Tue Mar 30 10:41:09 2004
+++ LOCAL/libc/nptl/sysdeps/unix/sysv/linux/sh/bits/pthreadtypes.h	Mon May 31 09:42:26 2004
@@ -82,6 +82,7 @@ typedef union
     unsigned long long int __wakeup_seq;
     unsigned long long int __woken_seq;
     void *__mutex;
+    unsigned int __broadcast_seq;
   } __data;
   char __size[__SIZEOF_PTHREAD_COND_T];
   long long int __align;
diff -u3prN ORIG/libc/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_broadcast.S LOCAL/libc/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_broadcast.S
--- ORIG/libc/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_broadcast.S	Sat Mar 20 15:24:28 2004
+++ LOCAL/libc/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_broadcast.S	Mon May 31 12:24:57 2004
@@ -67,6 +67,11 @@ __pthread_cond_broadcast:
 	   woken up.  */
 	mov.l	r1, @(wakeup_seq,r8)
 	mov.l	r0, @(wakeup_seq+4,r8)
+	mov.l	r1, @(woken_seq,r8)
+	mov.l	r0, @(woken_seq+4,r8)
+	mov.l	@(broadcast_seq,r8), r2
+	add	#1, r2
+	mov.l	r2, @(broadcast_seq,r8)
 
 	/* Get the address of the mutex used.  */
 	mov.l	@(dep_mutex,r8), r9
diff -u3prN ORIG/libc/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_timedwait.S LOCAL/libc/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_timedwait.S
--- ORIG/libc/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_timedwait.S	Mon Apr 19 09:16:40 2004
+++ LOCAL/libc/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_timedwait.S	Tue Jun  1 13:40:34 2004
@@ -114,6 +114,8 @@ __pthread_cond_timedwait:
 	/* Get and store current wakeup_seq value.  */
 	mov.l	@(wakeup_seq,r8), r10
 	mov.l	@(wakeup_seq+4,r8), r11
+	mov.l	@(broadcast_seq,r8), r0
+	mov.l	r0, @(4,r15)
 
 8:	
 	/* Get current time.  */
@@ -140,8 +142,10 @@ __pthread_cond_timedwait:
 	add	r1, r3
 	add	#-1, r2
 12:
+	mov	#-ETIMEDOUT, r1
+	mov.l	r1, @(12,r15)
 	cmp/pz	r2
-	bf	13f		/* Time is already up.  */
+	bf	6f		/* Time is already up.  */
 
 	/* Store relative timeout.  */
 	mov.l	r2, @(16,r15)
@@ -193,6 +197,11 @@ __pthread_cond_timedwait:
 #endif
 	bf	5f
 6:
+	mov.l	@(broadcast_seq,r8), r0
+	mov.l	@(4,r15), r1
+	cmp/eq	r0, r1
+	bf	23f
+
 	mov.l	@(woken_seq,r8), r0
 	mov.l	@(woken_seq+4,r8), r1
 
@@ -212,7 +221,7 @@ __pthread_cond_timedwait:
 	mov.l	@(12,r15),r0
 	cmp/eq	#-ETIMEDOUT, r0
 	bf	8b
-13:
+
 	mov	#1, r2
 	mov	#0, r3
 
@@ -227,6 +236,11 @@ __pthread_cond_timedwait:
 	bra	14f
 	 mov.l	r0, @(24,r15)
 
+23:
+	mov	#0, r0
+	bra	24f
+	 mov.l	r0, @(24,r15)
+
 9:
 	mov	#0, r0
 	mov.l	r0, @(24,r15)
@@ -242,6 +256,7 @@ __pthread_cond_timedwait:
 	mov.l	r0,@(woken_seq,r8)
 	mov.l	r1,@(woken_seq+4,r8)
 
+24:	
 #if cond_lock != 0
 	DEC (@(cond_lock,r8), r2)
 #else
@@ -301,7 +316,7 @@ __pthread_cond_timedwait:
 	 nop
 
 3:
-	/* Unlock in loop requires waekup.  */
+	/* Unlock in loop requires wakeup.  */
 	mov	r8, r4
 #if cond_lock != 0
 	add	#cond_lock, r4
@@ -327,7 +342,7 @@ __pthread_cond_timedwait:
 	 nop
 
 10:
-	/* Unlock after loop requires waekup.  */
+	/* Unlock after loop requires wakeup.  */
 	mov	r8, r4
 #if cond_lock != 0
 	add	#cond_lock, r4
@@ -403,6 +418,11 @@ __condvar_tw_cleanup:
 .Lmwait5b:
 
 1:
+	mov.l	@(broadcast_seq,r8), r0
+	mov.l	@(4,r15), r1
+	cmp/eq	r0, r1
+	bf	3f
+
 	mov	#1, r2
 	mov	#0, r3
 
@@ -414,6 +434,15 @@ __condvar_tw_cleanup:
 	mov.l	r0,@(wakeup_seq,r8)
 	mov.l	r1,@(wakeup_seq+4,r8)
 
+	clrt
+	mov.l	@(woken_seq,r8),r0
+	mov.l	@(woken_seq+4,r8),r1
+	addc	r2, r0
+	addc	r3, r1
+	mov.l	r0,@(woken_seq,r8)
+	mov.l	r1,@(woken_seq+4,r8)
+
+3:
 #if cond_lock != 0
 	DEC (@(cond_lock,r8), r2)
 #else
diff -u3prN ORIG/libc/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_wait.S LOCAL/libc/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_wait.S
--- ORIG/libc/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_wait.S	Mon Apr 19 09:16:40 2004
+++ LOCAL/libc/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_wait.S	Tue Jun  1 13:40:38 2004
@@ -108,6 +108,8 @@ __pthread_cond_wait:
 	/* Get and store current wakeup_seq value.  */
 	mov.l	@(wakeup_seq,r8), r10
 	mov.l	@(wakeup_seq+4,r8), r11
+	mov.l	@(broadcast_seq,r8), r0
+	mov.l	r0, @(4,r15)
 
 8:
 	/* Unlock.  */
@@ -152,6 +154,11 @@ __pthread_cond_wait:
 #endif
 	bf	5f
 6:
+	mov.l	@(broadcast_seq,r8), r0
+	mov.l	@(4,r15), r1
+	cmp/eq	r0, r1
+	bf	16f
+
 	mov.l	@(woken_seq,r8), r0
 	mov.l	@(woken_seq+4,r8), r1
 
@@ -179,6 +186,7 @@ __pthread_cond_wait:
 	mov.l	r0,@(woken_seq,r8)
 	mov.l	r1,@(woken_seq+4,r8)
 
+16:	
 #if cond_lock != 0
 	DEC (@(cond_lock,r8), r2)
 #else
@@ -330,6 +338,11 @@ __condvar_w_cleanup:
 .Lmwait3b:
 
 1:
+	mov.l	@(broadcast_seq,r8), r0
+	mov.l	@(4,r15), r1
+	cmp/eq	r0, r1
+	bf	3f
+
 	mov	#1, r2
 	mov	#0, r3
 
@@ -341,6 +354,15 @@ __condvar_w_cleanup:
 	mov.l	r0,@(wakeup_seq,r8)
 	mov.l	r1,@(wakeup_seq+4,r8)
 
+	clrt
+	mov.l	@(woken_seq,r8),r0
+	mov.l	@(woken_seq+4,r8),r1
+	addc	r2, r0
+	addc	r3, r1
+	mov.l	r0,@(woken_seq,r8)
+	mov.l	r1,@(woken_seq+4,r8)
+
+3:	
 #if cond_lock != 0
 	DEC (@(cond_lock,r8), r2)
 #else


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]