sem_trywait.S 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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, write to the Free
  13. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  14. 02111-1307 USA. */
  15. #include <sysdep.h>
  16. #include <pthread-errnos.h>
  17. #include <lowlevellock.h>
  18. #include "lowlevel-atomic.h"
  19. .text
  20. .globl sem_trywait
  21. .type sem_trywait,@function
  22. .align 5
  23. sem_trywait:
  24. mov.l r12, @-r15
  25. mov.l r8, @-r15
  26. sts.l pr, @-r15
  27. mov r4, r8
  28. mov.l @r8, r0
  29. 2:
  30. tst r0, r0
  31. bt 1f
  32. mov r0, r3
  33. mov r0, r4
  34. add #-1, r3
  35. CMPXCHG (r4, @r8, r3, r2)
  36. bf/s 2b
  37. mov r2, r0
  38. lds.l @r15+, pr
  39. mov.l @r15+, r8
  40. mov.l @r15+, r12
  41. rts
  42. mov #0, r0
  43. 1:
  44. mov #EAGAIN, r8
  45. mova .Lgot1, r0
  46. mov.l .Lgot1, r12
  47. add r0, r12
  48. #if USE___THREAD
  49. mov.l .Lerrno1, r0
  50. stc gbr, r1
  51. mov.l @(r0, r12), r0
  52. bra .Lexit
  53. add r1, r0
  54. .align 2
  55. .Lerrno1:
  56. .long errno@GOTTPOFF
  57. .Lexit:
  58. #else
  59. mov.l .Lerrloc1, r1
  60. bsrf r1
  61. nop
  62. .Lerrloc1b:
  63. #endif
  64. mov.l r8, @r0
  65. lds.l @r15+, pr
  66. mov.l @r15+, r8
  67. mov.l @r15+, r12
  68. rts
  69. mov #-1, r0
  70. .align 2
  71. .Lgot1:
  72. .long _GLOBAL_OFFSET_TABLE_
  73. #if !USE___THREAD
  74. .Lerrloc1:
  75. .long __errno_location@PLT-(.Lerrloc1b-.)
  76. #endif
  77. .size sem_trywait,.-sem_trywait