1 mike 1.1 !------------------------------------------------------------------------------
2 ! Copyright (c) Microsoft Corporation. All rights reserved.
3 !
4 ! Provides assembler funcions needed for SUN sparc atomic functions.
5 ! Date 05-sep-08
6
7 .section ".text"
8 .global AtomicIncrement
9 .align 4
10
11 AtomicIncrement:
12
13 1: ld [%o0], %o1 ! load the current value
14 add %o1, 1, %o2 ! perform required operation
15 cas [%o0], %o1, %o2 ! try CAS
16 cmp %o1, %o2 ! check if result is expected one
17 bne 1b ! try again if not
18 nop
19 retl
20 add %o2, 1, %o0 ! return new value
21
22 mike 1.1
23 .type AtomicIncrement,#function
24 .size AtomicIncrement,.-AtomicIncrement
25
26
27 .section ".text"
28 .global AtomicDecrement
29 .align 4
30
31 AtomicDecrement:
32
33 1: ld [%o0], %o1 ! load the current value
34 sub %o1, 1, %o2 ! perform required operation
35 cas [%o0], %o1, %o2 ! try CAS
36 cmp %o1, %o2 ! check if result is expected one
37 bne 1b ! try again if not
38 nop
39 retl
40 sub %o2, 1, %o0 ! return new value
41
42 .type AtomicDecrement,#function
43 mike 1.1 .size AtomicDecrement,.-AtomicDecrement
44
45
|