sem_post.S 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /* Copyright (C) 2003, 2004, 2007, 2008 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 <structsem.h>
  17. #include <lowlevellock.h>
  18. #include "lowlevel-atomic.h"
  19. .text
  20. .globl sem_post
  21. .type sem_post,@function
  22. .align 5
  23. sem_post:
  24. mov.l @(VALUE,r4), r2
  25. 0:
  26. mov.l .Lmax, r1
  27. cmp/eq r1, r2
  28. bt/s 3f
  29. mov r2, r3
  30. mov r3, r5
  31. add #1, r5
  32. CMPXCHG (r3, @(VALUE,r4), r5, r2)
  33. bf 0b
  34. mov.l @(NWAITERS,r4), r2
  35. tst r2, r2
  36. bt 2f
  37. mov #FUTEX_WAKE, r5
  38. mov.l @(PRIVATE,r4), r1
  39. or r1, r5
  40. mov #1, r6
  41. mov #0, r7
  42. mov #SYS_futex, r3
  43. extu.b r3, r3
  44. trapa #0x14
  45. SYSCALL_INST_PAD
  46. cmp/pz r0
  47. bf 1f
  48. 2:
  49. rts
  50. mov #0, r0
  51. 1:
  52. bra 4f
  53. mov #EINVAL, r2
  54. 3:
  55. mov #EOVERFLOW, r2
  56. 4:
  57. mov.l r12, @-r15
  58. mov.l r8, @-r15
  59. sts.l pr, @-r15
  60. mova .Lgot3, r0
  61. mov.l .Lgot3, r12
  62. add r0, r12
  63. #if USE___THREAD
  64. mov.l .Lerrno3, r0
  65. stc gbr, r1
  66. mov.l @(r0, r12), r0
  67. bra .Lexit
  68. add r1, r0
  69. .align 2
  70. .Lerrno3:
  71. .long errno@GOTTPOFF
  72. .Lexit:
  73. mov.l r2, @r0
  74. #else
  75. mov r2, r8
  76. mov.l .Lerrloc3, r1
  77. bsrf r1
  78. nop
  79. .Lerrloc3b:
  80. mov r8, @r0
  81. #endif
  82. lds.l @r15+, pr
  83. mov.l @r15+, r8
  84. mov.l @r15+, r12
  85. rts
  86. mov #-1, r0
  87. .align 2
  88. .Lmax:
  89. .long SEM_VALUE_MAX
  90. .Lgot3:
  91. .long _GLOBAL_OFFSET_TABLE_
  92. #if !USE___THREAD
  93. .Lerrloc3:
  94. .long __errno_location@PLT-(.Lerrloc3b-.)
  95. #endif
  96. .size sem_post,.-sem_post