summaryrefslogtreecommitdiff
path: root/lib/libpthread
diff options
context:
space:
mode:
authornathanw <nathanw@NetBSD.org>2003-06-12 21:46:03 +0000
committernathanw <nathanw@NetBSD.org>2003-06-12 21:46:03 +0000
commitf866ba061d53ebf951e55db8a583afd0d4bf2424 (patch)
tree724acb3a7e8977f004ab45d3f31ea2d3e85d84f1 /lib/libpthread
parent72aa9a9ed13915ca7ac927750b41f8f359ecde03 (diff)
Two fixes:
* In switch-away cases, write PT_SWITCHTO last (after PT_SWITCHTOUC), so that pthread__resolve_locks() doesn't see an empty SWITCHTOUC value. This also permits pthread__resolve_locks() to use the presence of PT_SWITCHTO as a sign that the thread has done all of its necessary chain work. * Make the return-point of pthread__switch global and visible, so that its address can be compared to the PC of a thread, again as a sign that its chain-work is done. (other architectures in progress, after they get the *previous* asm fix...)
Diffstat (limited to 'lib/libpthread')
-rw-r--r--lib/libpthread/arch/alpha/pthread_switch.S18
-rw-r--r--lib/libpthread/arch/arm/pthread_switch.S18
-rw-r--r--lib/libpthread/arch/i386/pthread_switch.S18
-rw-r--r--lib/libpthread/arch/powerpc/pthread_switch.S20
4 files changed, 37 insertions, 37 deletions
diff --git a/lib/libpthread/arch/alpha/pthread_switch.S b/lib/libpthread/arch/alpha/pthread_switch.S
index 2616e2e3351..9a29d68959e 100644
--- a/lib/libpthread/arch/alpha/pthread_switch.S
+++ b/lib/libpthread/arch/alpha/pthread_switch.S
@@ -1,4 +1,4 @@
-/* $NetBSD: pthread_switch.S,v 1.2 2003/01/18 10:34:17 thorpej Exp $ */
+/* $NetBSD: pthread_switch.S,v 1.3 2003/06/12 21:46:03 nathanw Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -80,7 +80,7 @@ NESTED(pthread__switch, 2, CONTEXTSIZE + 24, ra, 0, 0)
/* Edit the context to make it continue below, rather than here */
lda t3, 24(sp)
- lda t1, switch_return_point
+ lda t1, pthread__switch_return_point
stq t1, (UC_GREGS + _REG_PC * 8)(t3)
lda t0, 24(sp)
@@ -90,7 +90,7 @@ NESTED(pthread__switch, 2, CONTEXTSIZE + 24, ra, 0, 0)
stq t0, PT_UC(a0)
mov t2, a0
CALL(_setcontext_u)
-switch_return_point:
+XNESTED(pthread__switch_return_point, 2)
ldq ra, 0(sp)
lda sp, (CONTEXTSIZE + 24)(sp)
RET
@@ -163,9 +163,9 @@ NESTED(pthread__locked_switch, 3, CONTEXTSIZE + 32, ra, 0x00030000, 0)
* PT_SWITCHTO will be stomped by another switch_lock and
* preemption.
*/
- stq a1, PT_SWITCHTO(a0)
- stq t2, PT_SWITCHTOUC(a0)
stq a2, PT_HELDLOCK(a0)
+ stq t2, PT_SWITCHTOUC(a0)
+ stq a1, PT_SWITCHTO(a0)
ldl t4, PT_SPINLOCKS(a0)
subl t4, 1, t4
stl t4, PT_SPINLOCKS(a0)
@@ -203,8 +203,8 @@ NESTED(pthread__locked_switch, 3, CONTEXTSIZE + 32, ra, 0x00030000, 0)
beq t0, 2f
/* Yes, we were. Go to the next element in the chain. */
- stq a1, PT_SWITCHTO(a1)
stq t2, PT_SWITCHTOUC(a1)
+ stq a1, PT_SWITCHTO(a1)
mov a1, a0
mov t0, a1
mov zero, a2
@@ -250,10 +250,10 @@ NESTED(pthread__upcall_switch,2,0,ra,0,0)
/* Yes, it was. Stash the thread we were going to switch to,
* and switch to the next thread in the continuation chain.
*/
- stq a1, PT_SWITCHTO(a0)
- stq s2, PT_SWITCHTOUC(a0)
mov PT_STATE_RECYCLABLE, t1
stl t1, PT_STATE(a0)
+ stq s2, PT_SWITCHTOUC(a0)
+ stq a1, PT_SWITCHTO(a0)
mov a1, a0
mov t0, a1
mov 1, a2
@@ -279,8 +279,8 @@ NESTED(pthread__upcall_switch,2,0,ra,0,0)
/* Yes, we were. Stash the to-be-switched-to context in our thread
* structure and go to the next link in the chain.
*/
- stq a1, PT_SWITCHTO(a1)
stq s2, PT_SWITCHTOUC(a1)
+ stq a1, PT_SWITCHTO(a1)
mov a1, a0
mov t0, a1
mov 0, a2
diff --git a/lib/libpthread/arch/arm/pthread_switch.S b/lib/libpthread/arch/arm/pthread_switch.S
index 3e070916332..5b2d30730c1 100644
--- a/lib/libpthread/arch/arm/pthread_switch.S
+++ b/lib/libpthread/arch/arm/pthread_switch.S
@@ -1,4 +1,4 @@
-/* $NetBSD: pthread_switch.S,v 1.3 2003/04/05 23:15:11 bjh21 Exp $ */
+/* $NetBSD: pthread_switch.S,v 1.4 2003/06/12 21:46:04 nathanw Exp $ */
/*
* Copyright (c) 2001 Wasabi Systems, Inc.
@@ -101,7 +101,7 @@ ENTRY(pthread__switch)
bl PIC_SYM(_C_LABEL(_getcontext_u), PLT)
/* Edit the context to make it continue below, rather than here */
- add r0, pc, #switch_return_point - . - 8
+ add r0, pc, #pthread__switch_return_point - . - 8
str r0, [r5, #(_REG_PC)]
/* Get back r0-r2 */
@@ -118,7 +118,7 @@ ENTRY(pthread__switch)
b PIC_SYM(_C_LABEL(_setcontext_u), PLT)
NOTREACHED
-switch_return_point:
+ENTRY_NP(pthread__switch_return_point)
/*
* Stack is:
* context (RND_CTXSIZE bytes)
@@ -189,10 +189,10 @@ ENTRY(pthread__upcall_switch)
* Yes, it was. Stash the tread we were going to switch to,
* and switch to the next thread in the continuation chain.
*/
- str r1, [r0, #(PT_SWITCHTO)]
- str r7, [r0, #(PT_SWITCHTOUC)]
mov r4, #(PT_STATE_RECYCLABLE)
str r4, [r0, #(PT_STATE)]
+ str r7, [r0, #(PT_SWITCHTOUC)]
+ str r1, [r0, #(PT_SWITCHTO)]
mov r0, r1 /* from = next */
mov r1, r3 /* to = self->pt_next */
mov r2, #0x00000001 /* decr-spinlocks = TRUE */
@@ -221,8 +221,8 @@ ENTRY(pthread__upcall_switch)
* in itself, and switch to the next thread in the continuation
* chain.
*/
- str r1, [r1, #(PT_SWITCHTO)]
str r7, [r1, #(PT_SWITCHTOUC)]
+ str r1, [r1, #(PT_SWITCHTO)]
mov r0, r1 /* from = next */
mov r1, r3 /* to = next->pt_next */
mov r2, #0x00000000 /* decr-spinlocks = FALSE */
@@ -317,9 +317,9 @@ ENTRY(pthread__locked_switch)
* PT_SWITCHTO will be stomped on by another switch_lock and
* preemption.
*/
- str r1, [r0, #(PT_SWITCHTO)]
- str r4, [r0, #(PT_SWITCHTOUC)]
str r2, [r0, #(PT_HELDLOCK)]
+ str r4, [r0, #(PT_SWITCHTOUC)]
+ str r1, [r0, #(PT_SWITCHTO)]
ldr r4, [r0, #(PT_SPINLOCKS)]
sub r4, r4, #1
@@ -370,8 +370,8 @@ ENTRY(pthread__locked_switch)
beq 2f
/* Yes, we were. Go to the next thread in the chain. */
- str r1, [r1, #(PT_SWITCHTO)]
str r5, [r1, #(PT_SWITCHTOUC)]
+ str r1, [r1, #(PT_SWITCHTO)]
mov r0, r1 /* from = next */
mov r1, r3 /* to = next->pt_next */
mov r2, #0x00000000 /* decr-spinlocks = FALSE */
diff --git a/lib/libpthread/arch/i386/pthread_switch.S b/lib/libpthread/arch/i386/pthread_switch.S
index 731377ac874..633e5c06851 100644
--- a/lib/libpthread/arch/i386/pthread_switch.S
+++ b/lib/libpthread/arch/i386/pthread_switch.S
@@ -1,4 +1,4 @@
-/* $NetBSD: pthread_switch.S,v 1.3 2003/02/10 11:09:33 fvdl Exp $ */
+/* $NetBSD: pthread_switch.S,v 1.4 2003/06/12 21:46:04 nathanw Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -139,9 +139,9 @@ ENTRY(pthread__switch)
* the _setcontext_u below.
*/
#ifdef PIC
- movl PIC_GOT(switch_return_point), %esi
+ movl PIC_GOT(pthread__switch_return_point), %esi
#else
- leal switch_return_point, %esi
+ leal pthread__switch_return_point, %esi
#endif
movl %esi, UC_EIP(%edi)
@@ -151,7 +151,7 @@ ENTRY(pthread__switch)
pushl %esi /* ucontext_t *ucp */
call *PIC_GOTOFF(_C_LABEL(_md_setcontext_u))
-switch_return_point:
+NENTRY(pthread__switch_return_point)
/* We're back on the original stack. */
addl $CONTEXTSIZE+24, %esp
PIC_EPILOGUE
@@ -249,8 +249,8 @@ ENTRY(pthread__locked_switch)
* PT_SWITCHTO will be stomped by another switch_lock and
* preemption.
*/
- movl %ecx, PT_SWITCHTO(%eax)
movl %esi, PT_SWITCHTOUC(%eax)
+ movl %ecx, PT_SWITCHTO(%eax)
movl %edx, PT_HELDLOCK(%eax)
decl PT_SPINLOCKS(%eax)
@@ -282,8 +282,8 @@ locked_no_old_preempt:
cmpl $0, PT_NEXT(%ecx)
je locked_no_new_preempt
/* Yes, we were. Bummer. Go to the next element in the chain. */
- movl %ecx, PT_SWITCHTO(%ecx)
movl %esi, PT_SWITCHTOUC(%ecx)
+ movl %ecx, PT_SWITCHTO(%ecx)
movl %ecx, %eax
movl PT_NEXT(%ecx), %ecx
movl $-2, %edx
@@ -329,9 +329,9 @@ ENTRY(pthread__upcall_switch)
* Yes, it was. Stash the thread we were going to
* switch to, and go to the next thread in the chain.
*/
- movl %ecx, PT_SWITCHTO(%eax)
- movl %esi, PT_SWITCHTOUC(%eax)
movl $PT_STATE_RECYCLABLE, PT_STATE(%eax)
+ movl %esi, PT_SWITCHTOUC(%eax)
+ movl %ecx, PT_SWITCHTO(%eax)
movl PT_NEXT(%eax), %edx
movl %ecx, %eax
movl %edx, %ecx
@@ -353,8 +353,8 @@ upcall_no_old_preempt:
cmpl $0, PT_NEXT(%ecx)
je upcall_no_new_preempt
/* Yes, we were. Bummer. Go to the next element in the chain. */
- movl %ecx, PT_SWITCHTO(%ecx)
movl %esi, PT_SWITCHTOUC(%ecx)
+ movl %ecx, PT_SWITCHTO(%ecx)
movl %ecx, %eax
movl PT_NEXT(%ecx), %ecx
movl $-1, %edx
diff --git a/lib/libpthread/arch/powerpc/pthread_switch.S b/lib/libpthread/arch/powerpc/pthread_switch.S
index 7349bcf580f..a38a88b3830 100644
--- a/lib/libpthread/arch/powerpc/pthread_switch.S
+++ b/lib/libpthread/arch/powerpc/pthread_switch.S
@@ -1,4 +1,4 @@
-/* $NetBSD: pthread_switch.S,v 1.3 2003/06/06 19:35:03 nathanw Exp $ */
+/* $NetBSD: pthread_switch.S,v 1.4 2003/06/12 21:46:04 nathanw Exp $ */
/*
* Copyright (c) 2001 Wasabi Systems, Inc.
@@ -109,9 +109,9 @@ ENTRY(pthread__switch)
* here.
*/
#ifdef PIC
- lwz %r6, switch_return@got(%r9)
+ lwz %r6, pthread__switch_return_point@got(%r9)
#else
- lis %r6, switch_return@ha
+ lis %r6, pthread__switch_return_point@ha
addi %r6, %r6, switch_return@l
#endif
stw %r6, (_REG_PC + 16)(%r1)
@@ -124,7 +124,7 @@ ENTRY(pthread__switch)
b PIC_PLT(_C_LABEL(_setcontext_u))
NOTREACHED
-switch_return:
+ENTRY_NOPROFILE(pthread__switch_return_point)
lwz %r31, (RND_CTXSIZE + 44)(%r1)
addi %r1, %r1, (RND_CTXSIZE + 48)
lwz %r0, 4(%r1)
@@ -161,10 +161,10 @@ ENTRY(pthread__upcall_switch)
or. %r7, %r7, %r7
beq 1f
- stw %r4, PT_SWITCHTO(%r3)
- stw %r5, PT_SWITCHTOUC(%r3)
li %r5, PT_STATE_RECYCLABLE
stw %r5, PT_STATE(%r3)
+ stw %r5, PT_SWITCHTOUC(%r3)
+ stw %r4, PT_SWITCHTO(%r3)
mr %r3, %r4
mr %r4, %r7
li %r5, 1
@@ -187,8 +187,8 @@ ENTRY(pthread__upcall_switch)
or. %r7, %r7, %r7
beq 2f
- stw %r4, PT_SWITCHTO(%r4)
stw %r5, PT_SWITCHTOUC(%r4)
+ stw %r4, PT_SWITCHTO(%r4)
mr %r3, %r4
mr %r4, %r7
li %r5, 0
@@ -289,9 +289,9 @@ ENTRY(pthread__locked_switch)
* Don't release the lock. It's possible that if we do so,
* PT_SWITCHTO will be stomped by another switch_lock and preemption.
*/
- stw %r4, PT_SWITCHTO(%r3)
- stw %r7, PT_SWITCHTOUC(%r3)
stw %r5, PT_HELDLOCK(%r3)
+ stw %r7, PT_SWITCHTOUC(%r3)
+ stw %r4, PT_SWITCHTO(%r3)
lwz %r6, PT_SPINLOCKS(%r3)
addi %r6, %r6, -1
stw %r6, PT_SPINLOCKS(%r3)
@@ -333,8 +333,8 @@ ENTRY(pthread__locked_switch)
beq 2f
/* Yes, we were. Go to the next element in the chain. */
- stw %r4, PT_SWITCHTO(%r4)
stw %r7, PT_SWITCHTOUC(%r4)
+ stw %r4, PT_SWITCHTO(%r4)
mr %r3, %r4
mr %r4, %r8
li %r5, 0