sparc_atomic64.s 2.4 KB

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