sem_post.S 2.1 KB

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