sl@0
|
1 |
.section ".text",#alloc,#execinstr
|
sl@0
|
2 |
.align 8
|
sl@0
|
3 |
.skip 16
|
sl@0
|
4 |
|
sl@0
|
5 |
! int _STLP_atomic_exchange (void *pvalue, int value)
|
sl@0
|
6 |
!
|
sl@0
|
7 |
|
sl@0
|
8 |
.type _STLP_atomic_exchange,#function
|
sl@0
|
9 |
.global _STLP_atomic_exchange
|
sl@0
|
10 |
.align 8
|
sl@0
|
11 |
|
sl@0
|
12 |
_STLP_atomic_exchange:
|
sl@0
|
13 |
1:
|
sl@0
|
14 |
ldx [%o0], %o2 ! Set the current value
|
sl@0
|
15 |
mov %o1, %o3 ! Set the new value
|
sl@0
|
16 |
casx [%o0], %o2, %o3 ! Do the compare and swap
|
sl@0
|
17 |
cmp %o2, %o3 ! Check whether successful
|
sl@0
|
18 |
bne 1b ! Retry upon failure
|
sl@0
|
19 |
membar #LoadLoad | #LoadStore ! Ensure the cas finishes before
|
sl@0
|
20 |
! returning
|
sl@0
|
21 |
retl ! return
|
sl@0
|
22 |
mov %o2, %o0 ! Set the new value
|
sl@0
|
23 |
.size _STLP_atomic_exchange,(.-_STLP_atomic_exchange)
|
sl@0
|
24 |
|
sl@0
|
25 |
|
sl@0
|
26 |
! int _STLP_atomic_increment (void *pvalue)
|
sl@0
|
27 |
|
sl@0
|
28 |
.type _STLP_atomic_increment,#function
|
sl@0
|
29 |
.global _STLP_atomic_increment
|
sl@0
|
30 |
.align 8
|
sl@0
|
31 |
_STLP_atomic_increment:
|
sl@0
|
32 |
0:
|
sl@0
|
33 |
ldx [%o0], %o2 ! set the current
|
sl@0
|
34 |
addx %o2, 0x1, %o3 ! Increment and store current
|
sl@0
|
35 |
casx [%o0], %o2, %o3 ! Do the compare and swap
|
sl@0
|
36 |
cmp %o3, %o2 ! Check whether successful
|
sl@0
|
37 |
bne 0b
|
sl@0
|
38 |
membar #LoadLoad | #LoadStore ! Ensure the cas finishes before
|
sl@0
|
39 |
! returning
|
sl@0
|
40 |
retl ! return
|
sl@0
|
41 |
mov %o1, %o0 ! Set the return value
|
sl@0
|
42 |
|
sl@0
|
43 |
.size _STLP_atomic_increment,(.-_STLP_atomic_increment)
|
sl@0
|
44 |
|
sl@0
|
45 |
|
sl@0
|
46 |
! /* int _STLP_atomic_decrement (void *pvalue) */
|
sl@0
|
47 |
.type _STLP_atomic_decrement,#function
|
sl@0
|
48 |
.global _STLP_atomic_decrement
|
sl@0
|
49 |
.align 8
|
sl@0
|
50 |
|
sl@0
|
51 |
_STLP_atomic_decrement:
|
sl@0
|
52 |
0:
|
sl@0
|
53 |
ldx [%o0], %o2 ! set the current
|
sl@0
|
54 |
subx %o2, 0x1, %o3 ! decrement and store current
|
sl@0
|
55 |
casx [%o0], %o2, %o3 ! Do the compare and swap
|
sl@0
|
56 |
cmp %o3, %o2 ! Check whether successful
|
sl@0
|
57 |
bne 0b
|
sl@0
|
58 |
membar #LoadLoad | #LoadStore ! Ensure the cas finishes before
|
sl@0
|
59 |
! returning
|
sl@0
|
60 |
retl ! return
|
sl@0
|
61 |
nop
|
sl@0
|
62 |
.size _STLP_atomic_decrement,(.-_STLP_atomic_decrement)
|
sl@0
|
63 |
|
sl@0
|
64 |
|
sl@0
|
65 |
|