(file) Return to sunsparc8_atomic.s CVS log (file) (dir) Up to [OMI] / omi / base

 1 krisbash 1.3 !*==============================================================================
 2              !*
 3              !* Open Management Infrastructure (OMI)
 4              !*
 5              !* Copyright (c) Microsoft Corporation
 6              !* 
 7              !* Licensed under the Apache License, Version 2.0 (the "License"); you may not 
 8              !* use this file except in compliance with the License. You may obtain a copy 
 9              !* of the License at 
10              !*
11              !*     http://www.apache.org/licenses/LICENSE-2.0 
12              !*
13              !* THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14              !* KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 
15              !* WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 
16              !* MERCHANTABLITY OR NON-INFRINGEMENT. 
17              !*
18              !* See the Apache 2 License for the specific language governing permissions 
19              !* and limitations under the License.
20              !*
21              !*==============================================================================
22 krisbash 1.3 
23 mike     1.1 ! Provides assembler funcions needed for SUN sparc atomic functions.    
24              ! Date        05-sep-08
25              
26              .section   ".text"
27              .global   AtomicIncrement
28              .align   4
29              
30              AtomicIncrement:             
31              
32              1:      ld      [%o0], %o1          ! load the current value
33                      add     %o1, 1, %o2         ! perform required operation
34                      cas     [%o0], %o1, %o2     ! try CAS
35                      cmp     %o1, %o2            ! check if result is expected one
36                      bne     1b                  ! try again if not
37                      nop
38                      retl
39                      add     %o2, 1, %o0         ! return new value         
40              
41              
42              .type  AtomicIncrement,#function
43              .size  AtomicIncrement,.-AtomicIncrement
44 mike     1.1 
45              
46              .section   ".text"
47              .global   AtomicDecrement
48              .align   4
49              
50              AtomicDecrement:             
51              
52              1:      ld      [%o0], %o1          ! load the current value
53                      sub     %o1, 1, %o2         ! perform required operation
54                      cas     [%o0], %o1, %o2     ! try CAS
55                      cmp     %o1, %o2            ! check if result is expected one
56                      bne     1b                  ! try again if not
57                      nop
58                      retl
59                      sub     %o2, 1, %o0         ! return new value
60              
61              .type  AtomicDecrement,#function
62              .size  AtomicDecrement,.-AtomicDecrement
63              
64                      

ViewCVS 0.9.2