pthread_spin_trylock.S 402 B

1234567891011121314151617181920212223
  1. /*
  2. * Copyright (C) 2017 Hangzhou C-SKY Microsystems co.,ltd.
  3. *
  4. * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB
  5. * in this tarball.
  6. */
  7. #define _ERRNO_H 1
  8. #include <bits/errno.h>
  9. #include <sysdep.h>
  10. .text
  11. ENTRY (pthread_spin_trylock)
  12. mov a2, a0
  13. movi a0, 0
  14. movi a1, 1
  15. trap 2 // trap 2 use to cmpxchg
  16. cmpnei a0, 0
  17. bf 1f
  18. movi a0, EBUSY
  19. 1:
  20. jmp r15
  21. END (pthread_spin_trylock)