pthread_spin_trylock.S 579 B

12345678910111213141516171819202122232425262728293031
  1. /*
  2. * Copyright (C) 2013 Synopsys, Inc. (www.synopsys.com)
  3. *
  4. * Licensed under LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
  5. */
  6. #include <sysdep.h>
  7. #define _ERRNO_H 1
  8. #include <bits/errno.h>
  9. ; int pthread_spin_trylock(pthread_spinlock_t *lock)
  10. ; Return EBUSY is already locked, 0 if not
  11. ENTRY(pthread_spin_trylock)
  12. mov_s r1, 1
  13. ex r1, [r0]
  14. tst r1, r1
  15. mov.z r0, 0
  16. j.d [blink]
  17. mov.nz r0, EBUSY
  18. ; slightly faster, but difficult to follow
  19. ; mov_s r1, r0
  20. ; mov_s r0, 1
  21. ; ex r0, [r1]
  22. ; tst r0, r0
  23. ; j.d [blink]
  24. ; mov.nz r0, EBUSY
  25. END(pthread_spin_trylock)