sem_wait.S 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  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 <tcb-offsets.h>
  18. #include <structsem.h>
  19. #include <lowlevellock.h>
  20. #include "lowlevel-atomic.h"
  21. #if VALUE != 0
  22. # error "code needs to be rewritten for VALUE != 0"
  23. #endif
  24. .text
  25. .globl __new_sem_wait
  26. .type __new_sem_wait,@function
  27. .align 5
  28. __new_sem_wait:
  29. .LSTARTCODE:
  30. mov.l r8, @-r15
  31. .Lpush_r8:
  32. mov.l r10, @-r15
  33. .Lpush_r10:
  34. mov.l r12, @-r15
  35. .Lpush_r12:
  36. sts.l pr, @-r15
  37. .Lpush_pr:
  38. mov r4, r8
  39. mov.l @r8, r0
  40. 2:
  41. tst r0, r0
  42. bt 1f
  43. mov r0, r3
  44. mov r0, r4
  45. add #-1, r3
  46. CMPXCHG (r4, @r8, r3, r2)
  47. bf/s 2b
  48. mov r2, r0
  49. 7:
  50. mov #0, r0
  51. 9:
  52. lds.l @r15+, pr
  53. mov.l @r15+, r12
  54. mov.l @r15+, r10
  55. rts
  56. mov.l @r15+, r8
  57. .Lafter_ret:
  58. 1:
  59. INC (@(NWAITERS,r8),r2)
  60. .LcleanupSTART:
  61. 6:
  62. mov.l .Lenable0, r1
  63. bsrf r1
  64. nop
  65. .Lenable0b:
  66. mov r0, r10
  67. mov r8, r4
  68. #if FUTEX_WAIT == 0
  69. mov.l @(PRIVATE,r8), r5
  70. #else
  71. mov.l @(PRIVATE,r8), r5
  72. mov #FUTEX_WAIT, r0
  73. or r0, r5
  74. #endif
  75. mov #0, r6
  76. mov #0, r7
  77. mov #SYS_futex, r3
  78. extu.b r3, r3
  79. trapa #0x14
  80. SYSCALL_INST_PAD
  81. mov.l .Ldisable0, r1
  82. mov r10, r4
  83. bsrf r1
  84. mov r0, r10
  85. .Ldisable0b:
  86. mov r10, r0
  87. .LcleanupEND:
  88. tst r0, r0
  89. bt 3f
  90. cmp/eq #-EWOULDBLOCK, r0
  91. bf 4f
  92. 3:
  93. mov.l @r8, r0
  94. 5:
  95. tst r0, r0
  96. bt 6b
  97. mov r0, r3
  98. mov r0, r4
  99. add #-1, r3
  100. CMPXCHG (r4, @r8, r3, r2)
  101. bf/s 5b
  102. mov r2, r0
  103. DEC (@(NWAITERS,r8), r2)
  104. bra 7b
  105. nop
  106. 4:
  107. neg r0, r0
  108. mov r0, r4
  109. DEC (@(NWAITERS,r8), r2)
  110. mov r4, r8
  111. mova .Lgot0, r0
  112. mov.l .Lgot0, r12
  113. add r0, r12
  114. #if USE___THREAD
  115. mov.l .Lerrno0, r0
  116. stc gbr, r1
  117. mov.l @(r0, r12), r0
  118. bra .Lexit
  119. add r1, r0
  120. .align 2
  121. .Lerrno0:
  122. .long errno@GOTTPOFF
  123. .Lexit:
  124. #else
  125. mov.l .Lerrloc0, r1
  126. bsrf r1
  127. nop
  128. .Lerrloc0b:
  129. #endif
  130. mov.l r8, @r0
  131. bra 9b
  132. mov #-1, r0
  133. .align 2
  134. .Lgot0:
  135. .long _GLOBAL_OFFSET_TABLE_
  136. #if !USE___THREAD
  137. .Lerrloc0:
  138. .long __errno_location@PLT-(.Lerrloc0b-.)
  139. #endif
  140. .Lenable0:
  141. .long __pthread_enable_asynccancel-.Lenable0b
  142. .Ldisable0:
  143. .long __pthread_disable_asynccancel-.Ldisable0b
  144. .size __new_sem_wait,.-__new_sem_wait
  145. weak_alias(__new_sem_wait, sem_wait)
  146. .type sem_wait_cleanup,@function
  147. sem_wait_cleanup:
  148. DEC (@(NWAITERS,r8), r2)
  149. .LcallUR:
  150. mov.l .Lresume, r1
  151. #ifdef __PIC__
  152. add r12, r1
  153. #endif
  154. jsr @r1
  155. nop
  156. sleep
  157. .align 2
  158. .Lresume:
  159. #ifdef __PIC__
  160. .long _Unwind_Resume@GOTOFF
  161. #else
  162. .long _Unwind_Resume
  163. #endif
  164. .LENDCODE:
  165. .size sem_wait_cleanup,.-sem_wait_cleanup
  166. .section .gcc_except_table,"a",@progbits
  167. .LexceptSTART:
  168. .byte 0xff ! @LPStart format (omit)
  169. .byte 0xff ! @TType format (omit)
  170. .byte 0x01 ! call-site format
  171. ! DW_EH_PE_uleb128
  172. .uleb128 .Lcstend-.Lcstbegin
  173. .Lcstbegin:
  174. .uleb128 .LcleanupSTART-.LSTARTCODE
  175. .uleb128 .LcleanupEND-.LcleanupSTART
  176. .uleb128 sem_wait_cleanup-.LSTARTCODE
  177. .uleb128 0
  178. .uleb128 .LcallUR-.LSTARTCODE
  179. .uleb128 .LENDCODE-.LcallUR
  180. .uleb128 0
  181. .uleb128 0
  182. .Lcstend:
  183. .section .eh_frame,"a",@progbits
  184. .LSTARTFRAME:
  185. .ualong .LENDCIE-.LSTARTCIE ! Length of the CIE.
  186. .LSTARTCIE:
  187. .ualong 0 ! CIE ID.
  188. .byte 1 ! Version number.
  189. #ifdef SHARED
  190. .string "zPLR" ! NUL-terminated augmentation
  191. ! string.
  192. #else
  193. .string "zPL" ! NUL-terminated augmentation
  194. ! string.
  195. #endif
  196. .uleb128 1 ! Code alignment factor.
  197. .sleb128 -4 ! Data alignment factor.
  198. .byte 0x11 ! Return address register
  199. ! column.
  200. #ifdef SHARED
  201. .uleb128 7 ! Augmentation value length.
  202. .byte 0x9b ! Personality: DW_EH_PE_pcrel
  203. ! + DW_EH_PE_sdata4
  204. ! + DW_EH_PE_indirect
  205. .ualong DW.ref.__gcc_personality_v0-.
  206. .byte 0x1b ! LSDA Encoding: DW_EH_PE_pcrel
  207. ! + DW_EH_PE_sdata4.
  208. .byte 0x1b ! FDE Encoding: DW_EH_PE_pcrel
  209. ! + DW_EH_PE_sdata4.
  210. #else
  211. .uleb128 6 ! Augmentation value length.
  212. .byte 0x0 ! Personality: absolute
  213. .ualong __gcc_personality_v0
  214. .byte 0x0 ! LSDA Encoding: absolute
  215. #endif
  216. .byte 0x0c ! DW_CFA_def_cfa
  217. .uleb128 0xf
  218. .uleb128 0
  219. .align 4
  220. .LENDCIE:
  221. .ualong .LENDFDE-.LSTARTFDE ! Length of the FDE.
  222. .LSTARTFDE:
  223. .ualong .LSTARTFDE-.LSTARTFRAME ! CIE pointer.
  224. #ifdef SHARED
  225. .ualong .LSTARTCODE-. ! PC-relative start address
  226. ! of the code.
  227. #else
  228. .ualong .LSTARTCODE ! Start address of the code.
  229. #endif
  230. .ualong .LENDCODE-.LSTARTCODE ! Length of the code.
  231. .uleb128 4 ! Augmentation size
  232. #ifdef SHARED
  233. .ualong .LexceptSTART-.
  234. #else
  235. .ualong .LexceptSTART
  236. #endif
  237. .byte 4 ! DW_CFA_advance_loc4
  238. .ualong .Lpush_r8-.LSTARTCODE
  239. .byte 14 ! DW_CFA_def_cfa_offset
  240. .uleb128 4
  241. .byte 0x88 ! DW_CFA_offset r8
  242. .uleb128 1
  243. .byte 4 ! DW_CFA_advance_loc4
  244. .ualong .Lpush_r10-.Lpush_r8
  245. .byte 14 ! DW_CFA_def_cfa_offset
  246. .uleb128 8
  247. .byte 0x8a ! DW_CFA_offset r10
  248. .uleb128 2
  249. .byte 4 ! DW_CFA_advance_loc4
  250. .ualong .Lpush_r12-.Lpush_r10
  251. .byte 14 ! DW_CFA_def_cfa_offset
  252. .uleb128 12
  253. .byte 0x8c ! DW_CFA_offset r12
  254. .uleb128 3
  255. .byte 4 ! DW_CFA_advance_loc4
  256. .ualong .Lpush_pr-.Lpush_r12
  257. .byte 14 ! DW_CFA_def_cfa_offset
  258. .uleb128 16
  259. .byte 0x91 ! DW_CFA_offset pr
  260. .uleb128 4
  261. .align 4
  262. .LENDFDE:
  263. #ifdef SHARED
  264. .hidden DW.ref.__gcc_personality_v0
  265. .weak DW.ref.__gcc_personality_v0
  266. .section .gnu.linkonce.d.DW.ref.__gcc_personality_v0,"aw",@progbits
  267. .align 4
  268. .type DW.ref.__gcc_personality_v0, @object
  269. .size DW.ref.__gcc_personality_v0, 4
  270. DW.ref.__gcc_personality_v0:
  271. .long __gcc_personality_v0
  272. #endif