sem_trywait.S 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /* Copyright (C) 2003, 2004, 2007 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library; if not, see
  13. <http://www.gnu.org/licenses/>. */
  14. #include <sysdep.h>
  15. #include <pthread-errnos.h>
  16. #include <lowlevellock.h>
  17. #include "lowlevel-atomic.h"
  18. .text
  19. .globl sem_trywait
  20. .type sem_trywait,@function
  21. .align 5
  22. sem_trywait:
  23. mov.l r12, @-r15
  24. mov.l r8, @-r15
  25. sts.l pr, @-r15
  26. mov r4, r8
  27. mov.l @r8, r0
  28. 2:
  29. tst r0, r0
  30. bt 1f
  31. mov r0, r3
  32. mov r0, r4
  33. add #-1, r3
  34. CMPXCHG (r4, @r8, r3, r2)
  35. bf/s 2b
  36. mov r2, r0
  37. lds.l @r15+, pr
  38. mov.l @r15+, r8
  39. mov.l @r15+, r12
  40. rts
  41. mov #0, r0
  42. 1:
  43. mov #EAGAIN, r8
  44. mova .Lgot1, r0
  45. mov.l .Lgot1, r12
  46. add r0, r12
  47. #if USE___THREAD
  48. mov.l .Lerrno1, r0
  49. stc gbr, r1
  50. mov.l @(r0, r12), r0
  51. bra .Lexit
  52. add r1, r0
  53. .align 2
  54. .Lerrno1:
  55. .long errno@GOTTPOFF
  56. .Lexit:
  57. #else
  58. mov.l .Lerrloc1, r1
  59. bsrf r1
  60. nop
  61. .Lerrloc1b:
  62. #endif
  63. mov.l r8, @r0
  64. lds.l @r15+, pr
  65. mov.l @r15+, r8
  66. mov.l @r15+, r12
  67. rts
  68. mov #-1, r0
  69. .align 2
  70. .Lgot1:
  71. .long _GLOBAL_OFFSET_TABLE_
  72. #if !USE___THREAD
  73. .Lerrloc1:
  74. .long __errno_location@PLT-(.Lerrloc1b-.)
  75. #endif
  76. .size sem_trywait,.-sem_trywait