* [PATCH] SH: nptl fixups
@ 2008-01-21 14:27 Kaz Kojima
0 siblings, 0 replies; 7+ messages in thread
From: Kaz Kojima @ 2008-01-21 14:27 UTC (permalink / raw)
To: libc-hacker
Hi,
The appended patch fixes several tinko&typo on SH port.
The currnet implementation of XADD clobbers the register
value in the critical section and doesn't match the correct
xadd behavior when this section restarts. The patch
introduces a tempolary register to avoid it.
The other hunks of the patch are to fix the rather obvious
typo and oversight when I interpreted x86 pthread_rwlock_timed*
sources.
Uli, could you please approve this patch?
Regards,
kaz
--
2008-01-21 Kaz Kojima <kkojima@rr.iij4u.or.jp>
* sysdeps/unix/sysv/linux/sh/lowlevel-atomic.h (XADD): Use
a scratch register.
* sysdeps/unix/sysv/linux/sh/lowlevellock.S
(__lll_lock_wait_private): Fix typo.
* sysdeps/unix/sysv/linux/sh/pthread_barrier_wait.S
(pthread_barrier_wait): Likewise. Adjust XADD use.
* sysdeps/unix/sysv/linux/sh/sem_post.S (__new_sem_post):
Adjust XADD use.
* sysdeps/unix/sysv/linux/sh/pthread_rwlock_timedrdlock.S
(pthread_rwlock_timedrdlock): Return correct return value.
* sysdeps/unix/sysv/linux/sh/pthread_rwlock_timedwrlock.S
(pthread_rwlock_timedwrlock): Likewise.
diff -uprN ORIG/libc/nptl/sysdeps/unix/sysv/linux/sh/lowlevel-atomic.h LOCAL/libc/nptl/sysdeps/unix/sysv/linux/sh/lowlevel-atomic.h
--- ORIG/libc/nptl/sysdeps/unix/sysv/linux/sh/lowlevel-atomic.h 2004-03-20 15:13:03.000000000 +0900
+++ LOCAL/libc/nptl/sysdeps/unix/sysv/linux/sh/lowlevel-atomic.h 2008-01-18 16:31:16.000000000 +0900
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 2003, 2004, 2008 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -44,14 +44,16 @@
mov.l reg, mem; \
99: mov r1, r15
-#define XADD(reg, mem, old) \
+#define XADD(reg, mem, old, tmp) \
.align 2; \
mova 99f, r0; \
+ nop; \
mov r15, r1; \
- mov _IMM6, r15; \
+ mov _IMM8, r15; \
98: mov.l mem, old; \
- add old, reg; \
- mov.l reg, mem; \
+ mov reg, tmp; \
+ add old, tmp; \
+ mov.l tmp, mem; \
99: mov r1, r15
#define XCHG(reg, mem, old) \
diff -uprN ORIG/libc/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.S LOCAL/libc/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.S
--- ORIG/libc/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.S 2007-12-06 09:37:23.000000000 +0900
+++ LOCAL/libc/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.S 2008-01-18 16:32:03.000000000 +0900
@@ -1,4 +1,5 @@
-/* Copyright (C) 2003, 2004, 2005, 2007 Free Software Foundation, Inc.
+/* Copyright (C) 2003, 2004, 2005, 2007, 2008
+ Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -143,7 +144,7 @@ __lll_lock_wait_private:
bf 1b
mov.l @r15+, r8
- ret
+ rts
mov r2, r0
cfi_endproc
.size __lll_lock_wait_private,.-__lll_lock_wait_private
diff -uprN ORIG/libc/nptl/sysdeps/unix/sysv/linux/sh/pthread_barrier_wait.S LOCAL/libc/nptl/sysdeps/unix/sysv/linux/sh/pthread_barrier_wait.S
--- ORIG/libc/nptl/sysdeps/unix/sysv/linux/sh/pthread_barrier_wait.S 2007-08-04 09:57:13.000000000 +0900
+++ LOCAL/libc/nptl/sysdeps/unix/sysv/linux/sh/pthread_barrier_wait.S 2008-01-18 16:31:25.000000000 +0900
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2004, 2007 Free Software Foundation, Inc.
+/* Copyright (C) 2003, 2004, 2007, 2008 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -86,7 +86,7 @@ pthread_barrier_wait:
initial count unlock the object. */
mov #1, r3
mov.l @(INIT_COUNT,r8), r4
- XADD (r3, @(LEFT,r8), r2)
+ XADD (r3, @(LEFT,r8), r2, r5)
add #-1, r4
cmp/eq r2, r4
bf 10f
@@ -131,7 +131,7 @@ pthread_barrier_wait:
initial count unlock the object. */
mov #1, r3
mov.l @(INIT_COUNT,r8), r4
- XADD (r3, @(LEFT,r8), r2)
+ XADD (r3, @(LEFT,r8), r2, r5)
add #-1, r4
cmp/eq r2, r4
bf 5f
@@ -144,7 +144,7 @@ pthread_barrier_wait:
mov #-1, r0 /* == PTHREAD_BARRIER_SERIAL_THREAD */
lds.l @r15+, pr
mov.l @r15+, r8
- ret
+ rts
mov.l @r15+, r9
1:
diff -uprN ORIG/libc/nptl/sysdeps/unix/sysv/linux/sh/pthread_rwlock_timedrdlock.S LOCAL/libc/nptl/sysdeps/unix/sysv/linux/sh/pthread_rwlock_timedrdlock.S
--- ORIG/libc/nptl/sysdeps/unix/sysv/linux/sh/pthread_rwlock_timedrdlock.S 2007-08-16 08:16:43.000000000 +0900
+++ LOCAL/libc/nptl/sysdeps/unix/sysv/linux/sh/pthread_rwlock_timedrdlock.S 2008-01-18 16:33:16.000000000 +0900
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+/* Copyright (C) 2003, 2007, 2008 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -232,6 +232,7 @@ pthread_rwlock_timedrdlock:
.word TID - TLS_PRE_TCB_SIZE
6:
+ mov r3, r10
mov r8, r4
#if MUTEX != 0
add #MUTEX, r4
@@ -244,7 +245,7 @@ pthread_rwlock_timedrdlock:
nop
.Lwake2b:
bra 7b
- mov #0, r3
+ mov r10, r3
8:
/* Overflow. */
@@ -278,6 +279,7 @@ pthread_rwlock_timedrdlock:
nop
12:
+ mov r3, r10
mov r8, r5
#if MUTEX != 0
add #MUTEX, r5
@@ -290,7 +292,7 @@ pthread_rwlock_timedrdlock:
mov r2, r4
.Lwait3b:
bra 13b
- nop
+ mov r10, r3
16:
bra 17b
diff -uprN ORIG/libc/nptl/sysdeps/unix/sysv/linux/sh/pthread_rwlock_timedwrlock.S LOCAL/libc/nptl/sysdeps/unix/sysv/linux/sh/pthread_rwlock_timedwrlock.S
--- ORIG/libc/nptl/sysdeps/unix/sysv/linux/sh/pthread_rwlock_timedwrlock.S 2007-08-16 08:16:43.000000000 +0900
+++ LOCAL/libc/nptl/sysdeps/unix/sysv/linux/sh/pthread_rwlock_timedwrlock.S 2008-01-18 16:33:30.000000000 +0900
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2007 Free Software Foundation, Inc.
+/* Copyright (C) 2003, 2007, 2008 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -225,6 +225,7 @@ pthread_rwlock_timedwrlock:
bra 9b
mov #EDEADLK, r3
6:
+ mov r3, r10
mov r8, r4
#if MUTEX != 0
add #MUTEX, r4
@@ -237,7 +238,7 @@ pthread_rwlock_timedwrlock:
nop
.Lwake6b:
bra 7b
- mov #0, r3
+ mov r10, r3
.Ltidoff:
.word TID - TLS_PRE_TCB_SIZE
@@ -266,6 +267,7 @@ pthread_rwlock_timedwrlock:
nop
12:
+ mov r3, r10
mov r8, r5
#if MUTEX != 0
add #MUTEX, r5
@@ -278,7 +280,7 @@ pthread_rwlock_timedwrlock:
mov r2, r4
.Lwait7b:
bra 13b
- nop
+ mov r10, r3
16:
bra 17b
diff -uprN ORIG/libc/nptl/sysdeps/unix/sysv/linux/sh/sem_post.S LOCAL/libc/nptl/sysdeps/unix/sysv/linux/sh/sem_post.S
--- ORIG/libc/nptl/sysdeps/unix/sysv/linux/sh/sem_post.S 2007-08-04 09:57:14.000000000 +0900
+++ LOCAL/libc/nptl/sysdeps/unix/sysv/linux/sh/sem_post.S 2008-01-18 16:31:16.000000000 +0900
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2004, 2007 Free Software Foundation, Inc.
+/* Copyright (C) 2003, 2004, 2007, 2008 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -31,7 +31,7 @@
.align 5
__new_sem_post:
mov #1, r3
- XADD (r3, @(VALUE,r4), r2)
+ XADD (r3, @(VALUE,r4), r2, r5)
mov.l @(NWAITERS,r4), r2
tst r2, r2
bt 2f
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] SH: nptl fixups
2006-09-12 22:28 Kaz Kojima
@ 2006-09-17 6:02 ` Ulrich Drepper
0 siblings, 0 replies; 7+ messages in thread
From: Ulrich Drepper @ 2006-09-17 6:02 UTC (permalink / raw)
To: Kaz Kojima; +Cc: libc-hacker
[-- Attachment #1: Type: text/plain, Size: 101 bytes --]
Applied.
--
➧ Ulrich Drepper ➧ Red Hat, Inc. ➧ 444 Castro St ➧ Mountain View, CA ❖
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 251 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] SH: nptl fixups
@ 2006-09-12 22:28 Kaz Kojima
2006-09-17 6:02 ` Ulrich Drepper
0 siblings, 1 reply; 7+ messages in thread
From: Kaz Kojima @ 2006-09-12 22:28 UTC (permalink / raw)
To: libc-hacker
Hi,
The attached patch updates SH port of nptl according to the recent
updates for x86.
Regards,
kaz
--
2006-09-12 Kaz Kojima <kkojima@rr.iij4u.or.jp>
* sysdeps/unix/sysv/linux/sh/pthread_cond_broadcast.S: For PI
mutexes wake all mutexes.
* sysdeps/unix/sysv/linux/sh/pthread_cond_wait.S: Don't increment
WAKEUP_SEQ if this would increase the value beyond TOTAL_SEQ.
* sysdeps/unix/sysv/linux/sh/pthread_cond_timedwait.S: Likewise.
diff -uprN 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 2004-06-18 08:55:20.000000000 +0900
+++ LOCAL/libc/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_broadcast.S 2006-09-09 09:58:52.000000000 +0900
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -20,6 +20,7 @@
#include <shlib-compat.h>
#include <lowlevelcond.h>
#include <kernel-features.h>
+#include <pthread-pi-defines.h>
#include "lowlevel-atomic.h"
#define SYS_futex 240
@@ -98,6 +99,11 @@ __pthread_cond_broadcast:
bt/s 9f
add #cond_futex, r4
+ /* XXX: The kernel so far doesn't support requeue to PI futex. */
+ mov.l @(MUTEX_KIND,r9), r0
+ tst #PI_BIT, r0
+ bf 9f
+
/* Wake up all threads. */
mov #FUTEX_CMP_REQUEUE, r5
mov #1, r6
diff -uprN 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 2004-10-26 04:06:13.000000000 +0900
+++ LOCAL/libc/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_timedwait.S 2006-09-09 10:58:42.000000000 +0900
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -521,6 +521,21 @@ __condvar_tw_cleanup:
mov #1, r2
mov #0, r3
+ /* We increment the wakeup_seq counter only if it is lower than
+ total_seq. If this is not the case the thread was woken and
+ then canceled. In this case we ignore the signal. */
+ mov.l @(total_seq+4,r8), r0
+ mov.l @(wakeup_seq+4,r8), r1
+ cmp/hi r1, r0
+ bt/s 6f
+ cmp/hi r0, r1
+ bt 7f
+ mov.l @(total_seq,r8), r0
+ mov.l @(wakeup_seq,r8), r1
+ cmp/hs r0, r1
+ bt 7f
+
+6:
clrt
mov.l @(wakeup_seq,r8),r0
mov.l @(wakeup_seq+4,r8),r1
@@ -532,6 +547,7 @@ __condvar_tw_cleanup:
add r2, r0
mov.l r0,@(cond_futex,r8)
+7:
clrt
mov.l @(woken_seq,r8),r0
mov.l @(woken_seq+4,r8),r1
diff -uprN 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 2004-09-11 06:18:06.000000000 +0900
+++ LOCAL/libc/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_wait.S 2006-09-09 10:58:12.000000000 +0900
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+/* Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -385,6 +385,21 @@ __condvar_w_cleanup:
mov #1, r2
mov #0, r3
+ /* We increment the wakeup_seq counter only if it is lower than
+ total_seq. If this is not the case the thread was woken and
+ then canceled. In this case we ignore the signal. */
+ mov.l @(total_seq+4,r8), r0
+ mov.l @(wakeup_seq+4,r8), r1
+ cmp/hi r1, r0
+ bt/s 6f
+ cmp/hi r0, r1
+ bt 7f
+ mov.l @(total_seq,r8), r0
+ mov.l @(wakeup_seq,r8), r1
+ cmp/hs r0, r1
+ bt 7f
+
+6:
clrt
mov.l @(wakeup_seq,r8),r0
mov.l @(wakeup_seq+4,r8),r1
@@ -396,6 +411,7 @@ __condvar_w_cleanup:
add r2, r0
mov.l r0,@(cond_futex,r8)
+7:
clrt
mov.l @(woken_seq,r8),r0
mov.l @(woken_seq+4,r8),r1
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] SH: nptl fixups
2004-06-13 6:16 Kaz Kojima
@ 2004-06-17 23:58 ` Ulrich Drepper
0 siblings, 0 replies; 7+ messages in thread
From: Ulrich Drepper @ 2004-06-17 23:58 UTC (permalink / raw)
To: Kaz Kojima; +Cc: libc-hacker
Applied.
--
â§ Ulrich Drepper â§ Red Hat, Inc. â§ 444 Castro St â§ Mountain View, CA â
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] SH: nptl fixups
@ 2004-06-13 6:16 Kaz Kojima
2004-06-17 23:58 ` Ulrich Drepper
0 siblings, 1 reply; 7+ messages in thread
From: Kaz Kojima @ 2004-06-13 6:16 UTC (permalink / raw)
To: libc-hacker
Hi,
The appended patch updates SH port of nptl according to the recent
change by Jakub.
Regards,
kaz
--
2004-06-13 Kaz Kojima <kkojima@rr.iij4u.or.jp>
* sysdeps/unix/sysv/linux/sh/bits/pthreadtypes.h (pthread_cond_t):
Add __data.__futex field, reshuffle __data.__clock.
* sysdeps/unix/sysv/linux/sh/pthread_cond_signal.S
(__pthread_cond_signal): Increment __futex at the same time as
__wakeup_seq or __total_seq. Pass address of __futex instead of
address of low 32-bits of __wakeup_seq to futex syscall.
* sysdeps/unix/sysv/linux/sh/pthread_cond_wait.S
(__pthread_cond_wait): Likewise. Pass __futex value from before
releasing internal lock to FUTEX_WAIT.
* sysdeps/unix/sysv/linux/sh/pthread_cond_timedwait.S
(__pthread_cond_timedwait): Likewise.
* sysdeps/unix/sysv/linux/sh/pthread_cond_broadcast.S
(FUTEX_CMP_REQUEUE): Define.
(__pthread_cond_broadcast): Set __futex to 2 * __total_seq.
Use FUTEX_CMP_REQUEUE operation instead of FUTEX_REQUEUE.
Pass __futex value from before the unlock and __futex address instead
of address of low 32-bits of __wakeup_seq to futex syscall.
Fallback to FUTEX_WAKE all on any errors.
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 Fri Jun 4 07:29:33 2004
+++ LOCAL/libc/nptl/sysdeps/unix/sysv/linux/sh/bits/pthreadtypes.h Sat Jun 12 13:24:40 2004
@@ -77,11 +77,12 @@ typedef union
struct
{
int __lock;
- int __clock;
+ unsigned int __futex;
unsigned long long int __total_seq;
unsigned long long int __wakeup_seq;
unsigned long long int __woken_seq;
void *__mutex;
+ int __clock;
unsigned int __broadcast_seq;
} __data;
char __size[__SIZEOF_PTHREAD_COND_T];
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 Fri Jun 4 07:29:33 2004
+++ LOCAL/libc/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_broadcast.S Sat Jun 12 18:44:42 2004
@@ -26,6 +26,7 @@
#define FUTEX_WAIT 0
#define FUTEX_WAKE 1
#define FUTEX_REQUEUE 3
+#define FUTEX_CMP_REQUEUE 4
#define EINVAL 22
@@ -36,6 +37,7 @@
.type __pthread_cond_broadcast, @function
.align 5
__pthread_cond_broadcast:
+ mov.l r10, @-r15
mov.l r9, @-r15
mov.l r8, @-r15
sts.l pr, @-r15
@@ -72,6 +74,9 @@ __pthread_cond_broadcast:
mov.l @(broadcast_seq,r8), r2
add #1, r2
mov.l r2, @(broadcast_seq,r8)
+ add r1, r1
+ mov r1, r10
+ mov.l r10, @(cond_futex,r8)
/* Get the address of the mutex used. */
mov.l @(dep_mutex,r8), r9
@@ -91,10 +96,10 @@ __pthread_cond_broadcast:
cmp/eq r0, r9
mov r8, r4
bt/s 9f
- add #wakeup_seq, r4
+ add #cond_futex, r4
/* Wake up all threads. */
- mov #FUTEX_REQUEUE, r5
+ mov #FUTEX_CMP_REQUEUE, r5
mov #1, r6
mov #-1, r7
shlr r7 /* r7 = 0x7fffffff */
@@ -102,17 +107,31 @@ __pthread_cond_broadcast:
# if MUTEX_FUTEX != 0
add #MUTEX_FUTEX, r0
# endif
+ mov r10, r1
mov #SYS_futex, r3
extu.b r3, r3
- trapa #0x15
+ trapa #0x16
SYSCALL_INST_PAD
+ /* For any kind of error, which mainly is EAGAIN, we try again
+ with WAKE. The general test also covers running on old
+ kernels. */
+ mov r0, r1
+ mov #-12, r2
+ shad r2, r1
+ not r1, r1
+ tst r1, r1
+ mov r8, r4
+ bt/s 9f
+ add #cond_futex, r4
+
10:
mov #0, r0
lds.l @r15+, pr
mov.l @r15+, r8
+ mov.l @r15+, r9
rts
- mov.l @r15+, r9
+ mov.l @r15+, r10
4:
/* Unlock. */
@@ -127,8 +146,9 @@ __pthread_cond_broadcast:
mov #0, r0
lds.l @r15+, pr
mov.l @r15+, r8
+ mov.l @r15+, r9
rts
- mov.l @r15+, r9
+ mov.l @r15+, r10
1:
/* Initial locking failed. */
diff -u3prN ORIG/libc/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_signal.S LOCAL/libc/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_signal.S
--- ORIG/libc/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_signal.S Sat Mar 20 15:24:28 2004
+++ LOCAL/libc/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_signal.S Sat Jun 12 19:29:28 2004
@@ -72,10 +72,13 @@ __pthread_cond_signal:
addc r3, r1
mov.l r0,@(wakeup_seq,r8)
mov.l r1,@(wakeup_seq+4,r8)
+ mov.l @(cond_futex,r8),r0
+ add r2, r0
+ mov.l r0,@(cond_futex,r8)
/* Wake up one thread. */
mov r8, r4
- add #wakeup_seq, r4
+ add #cond_futex, r4
mov #FUTEX_WAKE, r5
mov #1, r6
mov #0, r7
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 Fri Jun 4 07:29:33 2004
+++ LOCAL/libc/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_timedwait.S Sat Jun 12 14:21:19 2004
@@ -110,6 +110,10 @@ __pthread_cond_timedwait:
addc r3, r1
mov.l r0,@(total_seq,r8)
mov.l r1,@(total_seq+4,r8)
+ mov.l @(cond_futex,r8), r0
+ add r2, r0
+ mov.l r0, @(cond_futex,r8)
+
/* Get and store current wakeup_seq value. */
mov.l @(wakeup_seq,r8), r10
@@ -150,6 +154,8 @@ __pthread_cond_timedwait:
/* Store relative timeout. */
mov.l r2, @(16,r15)
mov.l r3, @(20,r15)
+ mov.l @(cond_futex,r8), r1
+ mov.l r1, @(8,r15)
/* Unlock. */
#if cond_lock != 0
@@ -172,9 +178,9 @@ __pthread_cond_timedwait:
mov r15, r7
add #16, r7
mov #FUTEX_WAIT, r5
- mov r10, r6
+ mov.l @(8,r15), r6
mov r8, r4
- add #wakeup_seq, r4
+ add #cond_futex, r4
mov #SYS_futex, r3
extu.b r3, r3
trapa #0x14
@@ -232,6 +238,9 @@ __pthread_cond_timedwait:
addc r3, r1
mov.l r0,@(wakeup_seq,r8)
mov.l r1,@(wakeup_seq+4,r8)
+ mov.l @(cond_futex,r8),r0
+ add r2, r0
+ mov.l r0,@(cond_futex,r8)
mov #ETIMEDOUT, r0
bra 14f
mov.l r0, @(24,r15)
@@ -433,6 +442,9 @@ __condvar_tw_cleanup:
addc r3, r1
mov.l r0,@(wakeup_seq,r8)
mov.l r1,@(wakeup_seq+4,r8)
+ mov.l @(cond_futex,r8),r0
+ add r2, r0
+ mov.l r0,@(cond_futex,r8)
clrt
mov.l @(woken_seq,r8),r0
@@ -463,7 +475,7 @@ __condvar_tw_cleanup:
2:
/* Wake up all waiters to make sure no signal gets lost. */
mov r8, r4
- add #wakeup_seq, r4
+ add #cond_futex, r4
mov #FUTEX_WAKE, r5
mov #-1, r6
shlr r6 /* r6 = 0x7fffffff */
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 Fri Jun 4 07:29:33 2004
+++ LOCAL/libc/nptl/sysdeps/unix/sysv/linux/sh/pthread_cond_wait.S Sat Jun 12 14:26:14 2004
@@ -104,6 +104,9 @@ __pthread_cond_wait:
addc r3, r1
mov.l r0,@(total_seq,r8)
mov.l r1,@(total_seq+4,r8)
+ mov.l @(cond_futex,r8),r0
+ add r2, r0
+ mov.l r0,@(cond_futex,r8)
/* Get and store current wakeup_seq value. */
mov.l @(wakeup_seq,r8), r10
@@ -112,6 +115,9 @@ __pthread_cond_wait:
mov.l r0, @(4,r15)
8:
+ mov.l @(cond_futex,r8),r0
+ mov.l r0, @(8,r15)
+
/* Unlock. */
#if cond_lock != 0
DEC (@(cond_lock,r8), r2)
@@ -130,9 +136,9 @@ __pthread_cond_wait:
mov #0, r7
mov #FUTEX_WAIT, r5
- mov r10, r6
+ mov.l @(8,r15), r6
mov r8, r4
- add #wakeup_seq, r4
+ add #cond_futex, r4
mov #SYS_futex, r3
extu.b r3, r3
trapa #0x14
@@ -353,6 +359,9 @@ __condvar_w_cleanup:
addc r3, r1
mov.l r0,@(wakeup_seq,r8)
mov.l r1,@(wakeup_seq+4,r8)
+ mov.l @(cond_futex,r8),r0
+ add r2, r0
+ mov.l r0,@(cond_futex,r8)
clrt
mov.l @(woken_seq,r8),r0
@@ -383,7 +392,7 @@ __condvar_w_cleanup:
2:
/* Wake up all waiters to make sure no signal gets lost. */
mov r8, r4
- add #wakeup_seq, r4
+ add #cond_futex, r4
mov #FUTEX_WAKE, r5
mov #-1, r6
shlr r6 /* r6 = 0x7fffffff */
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] SH: nptl fixups
2004-06-01 5:33 Kaz Kojima
@ 2004-06-01 18:17 ` Ulrich Drepper
0 siblings, 0 replies; 7+ messages in thread
From: Ulrich Drepper @ 2004-06-01 18:17 UTC (permalink / raw)
To: Kaz Kojima; +Cc: libc-hacker
Kaz Kojima wrote:
> It should be "cmpl 20(%esp), %eax", shouldn't it?
Right, I fixed that.
And I applied the patch.
--
â§ Ulrich Drepper â§ Red Hat, Inc. â§ 444 Castro St â§ Mountain View, CA â
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] SH: nptl fixups
@ 2004-06-01 5:33 Kaz Kojima
2004-06-01 18:17 ` Ulrich Drepper
0 siblings, 1 reply; 7+ messages in thread
From: Kaz Kojima @ 2004-06-01 5:33 UTC (permalink / raw)
To: libc-hacker
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
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2008-01-21 14:27 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-21 14:27 [PATCH] SH: nptl fixups Kaz Kojima
-- strict thread matches above, loose matches on Subject: below --
2006-09-12 22:28 Kaz Kojima
2006-09-17 6:02 ` Ulrich Drepper
2004-06-13 6:16 Kaz Kojima
2004-06-17 23:58 ` Ulrich Drepper
2004-06-01 5:33 Kaz Kojima
2004-06-01 18:17 ` Ulrich Drepper
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).