michael@0: .section ".text",#alloc,#execinstr michael@0: .align 8 michael@0: .skip 16 michael@0: michael@0: michael@0: /* michael@0: ** int _STLP_atomic_exchange (void *pvalue, int value) michael@0: */ michael@0: michael@0: .type _STLP_atomic_exchange,#function michael@0: .global _STLP_atomic_exchange michael@0: .align 8 michael@0: michael@0: _STLP_atomic_exchange: michael@0: 0: michael@0: ld [%o0], %o2 ! Set the current value michael@0: mov %o1, %o3 ! Set the new value michael@0: ! swap [%o0], %o3 ! Do the compare and swap michael@0: cas [%o0], %o2, %o3 michael@0: cmp %o2, %o3 ! Check whether successful michael@0: bne 0b ! Retry upon failure michael@0: stbar michael@0: mov %o2, %o0 ! Set the new value michael@0: retl ! return michael@0: nop michael@0: .size _STLP_atomic_exchange,(.-_STLP_atomic_exchange) michael@0: michael@0: /* int _STLP_atomic_increment (void *pvalue) */ michael@0: michael@0: .type _STLP_atomic_increment,#function michael@0: .global _STLP_atomic_increment michael@0: .align 8 michael@0: _STLP_atomic_increment: michael@0: 1: michael@0: ld [%o0], %o2 ! set the current michael@0: add %o2, 0x1, %o3 ! Increment and store current michael@0: ! swap [%o0], %o3 ! Do the compare and swap michael@0: cas [%o0], %o2, %o3 michael@0: cmp %o3, %o2 ! Check whether successful michael@0: bne 1b ! Retry if we failed. michael@0: membar #LoadLoad | #LoadStore ! Ensure the cas finishes before michael@0: ! returning michael@0: nop michael@0: retl ! return michael@0: nop michael@0: michael@0: .size _STLP_atomic_increment,(.-_STLP_atomic_increment) michael@0: michael@0: michael@0: /* int _STLP_atomic_decrement (void *pvalue) */ michael@0: .type _STLP_atomic_decrement,#function michael@0: .global _STLP_atomic_decrement michael@0: .align 8 michael@0: michael@0: _STLP_atomic_decrement: michael@0: 2: michael@0: ld [%o0], %o2 ! set the current michael@0: sub %o2, 0x1, %o3 ! decrement and store current michael@0: ! swap [%o0], %o3 ! Do the compare and swap michael@0: cas [%o0], %o2, %o3 michael@0: cmp %o3, %o2 ! Check whether successful michael@0: bne 2b ! Retry if we failed. michael@0: membar #LoadLoad | #LoadStore ! Ensure the cas finishes before michael@0: nop michael@0: ! returning michael@0: retl ! return michael@0: nop michael@0: .size _STLP_atomic_decrement,(.-_STLP_atomic_decrement)