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