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