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