sem_trywait.S 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /* Copyright (C) 2003, 2004 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 "lowlevel-atomic.h"
  18. .text
  19. .globl __new_sem_trywait
  20. .type __new_sem_trywait,@function
  21. .align 5
  22. __new_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 __new_sem_trywait,.-__new_sem_trywait
  77. weak_alias(__new_sem_trywait, sem_trywait)