sem_wait.S 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. /* Copyright (C) 2002, 2003, 2005, 2007 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, write to the Free
  14. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  15. 02111-1307 USA. */
  16. #include <sysdep.h>
  17. #include <pthread-errnos.h>
  18. #include <structsem.h>
  19. #include <lowlevellock.h>
  20. #if VALUE != 0
  21. # error "code needs to be rewritten for VALUE != 0"
  22. #endif
  23. .text
  24. .globl __new_sem_wait
  25. .type __new_sem_wait,@function
  26. .align 16
  27. __new_sem_wait:
  28. .LSTARTCODE:
  29. pushl %ebx
  30. .Lpush_ebx:
  31. pushl %esi
  32. .Lpush_esi:
  33. subl $4, %esp
  34. .Lsub_esp:
  35. movl 16(%esp), %ebx
  36. movl (%ebx), %eax
  37. 2: testl %eax, %eax
  38. je 1f
  39. leal -1(%eax), %edx
  40. LOCK
  41. cmpxchgl %edx, (%ebx)
  42. jne 2b
  43. 7: xorl %eax, %eax
  44. 9: movl 4(%esp), %esi
  45. movl 8(%esp), %ebx
  46. addl $12, %esp
  47. .Ladd_esp:
  48. ret
  49. .Lafter_ret:
  50. 1: LOCK
  51. incl NWAITERS(%ebx)
  52. .LcleanupSTART:
  53. 6: call __pthread_enable_asynccancel
  54. movl %eax, (%esp)
  55. #if FUTEX_WAIT == 0
  56. movl PRIVATE(%ebx), %ecx
  57. #else
  58. movl $FUTEX_WAIT, %ecx
  59. orl PRIVATE(%ebx), %ecx
  60. #endif
  61. xorl %esi, %esi
  62. xorl %edx, %edx
  63. movl $SYS_futex, %eax
  64. ENTER_KERNEL
  65. movl %eax, %esi
  66. movl (%esp), %eax
  67. call __pthread_disable_asynccancel
  68. .LcleanupEND:
  69. testl %esi, %esi
  70. je 3f
  71. cmpl $-EWOULDBLOCK, %esi
  72. jne 4f
  73. 3:
  74. movl (%ebx), %eax
  75. 5: testl %eax, %eax
  76. je 6b
  77. leal -1(%eax), %edx
  78. LOCK
  79. cmpxchgl %edx, (%ebx)
  80. jne 5b
  81. LOCK
  82. decl NWAITERS(%ebx)
  83. jmp 7b
  84. 4: LOCK
  85. decl NWAITERS(%ebx)
  86. negl %esi
  87. #ifdef __PIC__
  88. call __x86.get_pc_thunk.bx
  89. #else
  90. movl $8f, %ebx
  91. 8:
  92. #endif
  93. addl $_GLOBAL_OFFSET_TABLE_, %ebx
  94. #if USE___THREAD
  95. # ifdef NO_TLS_DIRECT_SEG_REFS
  96. movl errno@gotntpoff(%ebx), %edx
  97. addl %gs:0, %edx
  98. movl %esi, (%edx)
  99. # else
  100. movl errno@gotntpoff(%ebx), %edx
  101. movl %esi, %gs:(%edx)
  102. # endif
  103. #else
  104. call __errno_location@plt
  105. movl %esi, (%eax)
  106. #endif
  107. orl $-1, %eax
  108. jmp 9b
  109. .size __new_sem_wait,.-__new_sem_wait
  110. weak_alias(__new_sem_wait, sem_wait)
  111. .type sem_wait_cleanup,@function
  112. sem_wait_cleanup:
  113. LOCK
  114. decl NWAITERS(%ebx)
  115. movl %eax, (%esp)
  116. .LcallUR:
  117. call _Unwind_Resume@PLT
  118. hlt
  119. .LENDCODE:
  120. .size sem_wait_cleanup,.-sem_wait_cleanup
  121. .section .gcc_except_table,"a",@progbits
  122. .LexceptSTART:
  123. .byte 0xff # @LPStart format (omit)
  124. .byte 0xff # @TType format (omit)
  125. .byte 0x01 # call-site format
  126. # DW_EH_PE_uleb128
  127. .uleb128 .Lcstend-.Lcstbegin
  128. .Lcstbegin:
  129. .uleb128 .LcleanupSTART-.LSTARTCODE
  130. .uleb128 .LcleanupEND-.LcleanupSTART
  131. .uleb128 sem_wait_cleanup-.LSTARTCODE
  132. .uleb128 0
  133. .uleb128 .LcallUR-.LSTARTCODE
  134. .uleb128 .LENDCODE-.LcallUR
  135. .uleb128 0
  136. .uleb128 0
  137. .Lcstend:
  138. .section .eh_frame,"a",@progbits
  139. .LSTARTFRAME:
  140. .long .LENDCIE-.LSTARTCIE # Length of the CIE.
  141. .LSTARTCIE:
  142. .long 0 # CIE ID.
  143. .byte 1 # Version number.
  144. #ifdef SHARED
  145. .string "zPLR" # NUL-terminated augmentation
  146. # string.
  147. #else
  148. .string "zPL" # NUL-terminated augmentation
  149. # string.
  150. #endif
  151. .uleb128 1 # Code alignment factor.
  152. .sleb128 -4 # Data alignment factor.
  153. .byte 8 # Return address register
  154. # column.
  155. #ifdef SHARED
  156. .uleb128 7 # Augmentation value length.
  157. .byte 0x9b # Personality: DW_EH_PE_pcrel
  158. # + DW_EH_PE_sdata4
  159. # + DW_EH_PE_indirect
  160. .long DW.ref.__gcc_personality_v0-.
  161. .byte 0x1b # LSDA Encoding: DW_EH_PE_pcrel
  162. # + DW_EH_PE_sdata4.
  163. .byte 0x1b # FDE Encoding: DW_EH_PE_pcrel
  164. # + DW_EH_PE_sdata4.
  165. #else
  166. .uleb128 6 # Augmentation value length.
  167. .byte 0x0 # Personality: absolute
  168. .long __gcc_personality_v0
  169. .byte 0x0 # LSDA Encoding: absolute
  170. #endif
  171. .byte 0x0c # DW_CFA_def_cfa
  172. .uleb128 4
  173. .uleb128 4
  174. .byte 0x88 # DW_CFA_offset, column 0x10
  175. .uleb128 1
  176. .align 4
  177. .LENDCIE:
  178. .long .LENDFDE-.LSTARTFDE # Length of the FDE.
  179. .LSTARTFDE:
  180. .long .LSTARTFDE-.LSTARTFRAME # CIE pointer.
  181. #ifdef SHARED
  182. .long .LSTARTCODE-. # PC-relative start address
  183. # of the code.
  184. #else
  185. .long .LSTARTCODE # Start address of the code.
  186. #endif
  187. .long .LENDCODE-.LSTARTCODE # Length of the code.
  188. .uleb128 4 # Augmentation size
  189. #ifdef SHARED
  190. .long .LexceptSTART-.
  191. #else
  192. .long .LexceptSTART
  193. #endif
  194. .byte 4 # DW_CFA_advance_loc4
  195. .long .Lpush_ebx-.LSTARTCODE
  196. .byte 14 # DW_CFA_def_cfa_offset
  197. .uleb128 8
  198. .byte 0x83 # DW_CFA_offset %ebx
  199. .uleb128 2
  200. .byte 4 # DW_CFA_advance_loc4
  201. .long .Lpush_esi-.Lpush_ebx
  202. .byte 14 # DW_CFA_def_cfa_offset
  203. .uleb128 12
  204. .byte 0x86 # DW_CFA_offset %esi
  205. .uleb128 3
  206. .byte 4 # DW_CFA_advance_loc4
  207. .long .Lsub_esp-.Lpush_esi
  208. .byte 14 # DW_CFA_def_cfa_offset
  209. .uleb128 16
  210. .byte 4 # DW_CFA_advance_loc4
  211. .long .Ladd_esp-.Lsub_esp
  212. .byte 14 # DW_CFA_def_cfa_offset
  213. .uleb128 4
  214. .byte 0xc3 # DW_CFA_restore %ebx
  215. .byte 0xc6 # DW_CFA_restore %esi
  216. .byte 4 # DW_CFA_advance_loc4
  217. .long .Lafter_ret-.Ladd_esp
  218. .byte 14 # DW_CFA_def_cfa_offset
  219. .uleb128 16
  220. .byte 0x83 # DW_CFA_offset %ebx
  221. .uleb128 2
  222. .byte 0x86 # DW_CFA_offset %esi
  223. .uleb128 3
  224. .align 4
  225. .LENDFDE:
  226. #ifdef SHARED
  227. .hidden DW.ref.__gcc_personality_v0
  228. .weak DW.ref.__gcc_personality_v0
  229. .section .gnu.linkonce.d.DW.ref.__gcc_personality_v0,"aw",@progbits
  230. .align 4
  231. .type DW.ref.__gcc_personality_v0, @object
  232. .size DW.ref.__gcc_personality_v0, 4
  233. DW.ref.__gcc_personality_v0:
  234. .long __gcc_personality_v0
  235. #endif