Commit eb868815 authored by Rob Pike's avatar Rob Pike

arm runtime: attempt to fix build by adding casp (same as cas)

untested.

Fixes #1523.

R=rsc
CC=golang-dev
https://golang.org/cl/4171057
parent 6ccc96ee
...@@ -20,7 +20,6 @@ TEXT runtime·cas(SB),7,$0 ...@@ -20,7 +20,6 @@ TEXT runtime·cas(SB),7,$0
MOVW 8(FP), R2 // new MOVW 8(FP), R2 // new
MOVW $1, R3 MOVW $1, R3
MOVW $runtime·cas_mutex(SB), R4 MOVW $runtime·cas_mutex(SB), R4
l:
SWPW (R4), R3 // acquire mutex SWPW (R4), R3 // acquire mutex
CMP $0, R3 CMP $0, R3
BNE fail0 BNE fail0
...@@ -38,6 +37,38 @@ fail1: ...@@ -38,6 +37,38 @@ fail1:
fail0: fail0:
MOVW $0, R0 MOVW $0, R0
RET RET
// bool casp(void **p, void *old, void *new)
// Atomically:
// if(*p == old){
// *p = new;
// return 1;
// }else
// return 0;
TEXT runtime·casp(SB),7,$0
MOVW 0(FP), R0 // *p
MOVW 4(FP), R1 // old
MOVW 8(FP), R2 // new
MOVW $1, R3
MOVW $runtime·cas_mutex(SB), R4
SWPW (R4), R3 // acquire mutex
CMP $0, R3
BNE failp0
MOVW (R0), R5
CMP R1, R5
BNE failp1
MOVW R2, (R0)
MOVW R3, (R4) // release mutex
MOVW $1, R0
RET
failp1:
MOVW R3, (R4) // release mutex
failp0:
MOVW $0, R0
RET
DATA runtime·cas_mutex(SB)/4, $0 DATA runtime·cas_mutex(SB)/4, $0
GLOBL runtime·cas_mutex(SB), $4 GLOBL runtime·cas_mutex(SB), $4
...@@ -27,3 +27,26 @@ fail: ...@@ -27,3 +27,26 @@ fail:
MOVW $0, R0 MOVW $0, R0
RET RET
// bool casp(void **p, void *old, void *new)
// Atomically:
// if(*p == old){
// *p = new;
// return 1;
// }else
// return 0;
TEXT runtime·casp(SB), 7, $0
MOVW 0(FP), R1 // *p
MOVW 4(FP), R2 // old
MOVW 8(FP), R3 // new
lp:
LDREX (R1), R0
CMP R0, R2
BNE failp
STREX R3, (R1), R0
CMP $0, R0
BNE lp
MOVW $1, R0
RET
failp:
MOVW $0, R0
RET
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment