spinlock.S 420 B

123456789101112131415161718192021222324252627282930313233
  1. ;; Core of the spinlock implementation
  2. ;;
  3. ;; Copyright (C) 2004 Axis Communications AB.
  4. ;;
  5. ;; Author: Mikael Starvik
  6. .global cris_spin_lock
  7. .global cris_spin_trylock
  8. .text
  9. cris_spin_lock:
  10. clearf p
  11. 1: test.d [$r10]
  12. beq 1b
  13. clearf p
  14. ax
  15. clear.d [$r10]
  16. bcs 1b
  17. clearf p
  18. ret
  19. nop
  20. cris_spin_trylock:
  21. clearf p
  22. 1: move.d [$r10], $r11
  23. ax
  24. clear.d [$r10]
  25. bcs 1b
  26. clearf p
  27. ret
  28. move.d $r11,$r10