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