sem_post.S 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /* Copyright (C) 2002, 2003, 2005, 2007, 2008 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. .text
  21. .globl __new_sem_post
  22. .type __new_sem_post,@function
  23. .align 16
  24. __new_sem_post:
  25. cfi_startproc
  26. pushl %ebx
  27. cfi_adjust_cfa_offset(4)
  28. cfi_offset(%ebx, -8)
  29. movl 8(%esp), %ebx
  30. #if VALUE == 0
  31. movl (%ebx), %eax
  32. #else
  33. movl VALUE(%ebx), %eax
  34. #endif
  35. 0: cmpl $SEM_VALUE_MAX, %eax
  36. je 3f
  37. leal 1(%eax), %edx
  38. LOCK
  39. #if VALUE == 0
  40. cmpxchgl %edx, (%ebx)
  41. #else
  42. cmpxchgl %edx, VALUE(%ebx)
  43. #endif
  44. jnz 0b
  45. cmpl $0, NWAITERS(%ebx)
  46. je 2f
  47. movl $FUTEX_WAKE, %ecx
  48. orl PRIVATE(%ebx), %ecx
  49. movl $1, %edx
  50. movl $SYS_futex, %eax
  51. ENTER_KERNEL
  52. testl %eax, %eax
  53. js 1f
  54. 2: xorl %eax, %eax
  55. popl %ebx
  56. cfi_adjust_cfa_offset(-4)
  57. cfi_restore(%ebx)
  58. ret
  59. cfi_adjust_cfa_offset(4)
  60. cfi_offset(%ebx, -8)
  61. 1:
  62. #ifdef __PIC__
  63. call __x86.get_pc_thunk.bx
  64. #else
  65. movl $4f, %ebx
  66. 4:
  67. #endif
  68. addl $_GLOBAL_OFFSET_TABLE_, %ebx
  69. #if USE___THREAD
  70. # ifdef NO_TLS_DIRECT_SEG_REFS
  71. movl errno@gotntpoff(%ebx), %edx
  72. addl %gs:0, %edx
  73. movl $EINVAL, (%edx)
  74. # else
  75. movl errno@gotntpoff(%ebx), %edx
  76. movl $EINVAL, %gs:(%edx)
  77. # endif
  78. #else
  79. call __errno_location@plt
  80. movl $EINVAL, (%eax)
  81. #endif
  82. orl $-1, %eax
  83. popl %ebx
  84. ret
  85. 3:
  86. #ifdef __PIC__
  87. call __x86.get_pc_thunk.bx
  88. #else
  89. movl $5f, %ebx
  90. 5:
  91. #endif
  92. addl $_GLOBAL_OFFSET_TABLE_, %ebx
  93. #if USE___THREAD
  94. # ifdef NO_TLS_DIRECT_SEG_REFS
  95. movl errno@gotntpoff(%ebx), %edx
  96. addl %gs:0, %edx
  97. movl $EOVERFLOW, (%edx)
  98. # else
  99. movl errno@gotntpoff(%ebx), %edx
  100. movl $EOVERFLOW, %gs:(%edx)
  101. # endif
  102. #else
  103. call __errno_location@plt
  104. movl $EOVERFLOW, (%eax)
  105. #endif
  106. orl $-1, %eax
  107. popl %ebx
  108. cfi_adjust_cfa_offset(-4)
  109. cfi_restore(%ebx)
  110. ret
  111. cfi_endproc
  112. .size __new_sem_post,.-__new_sem_post
  113. weak_alias(__new_sem_post, sem_post)
  114. #ifdef __PIC__
  115. .section .gnu.linkonce.t.__x86.get_pc_thunk.bx,"ax",@progbits
  116. .globl __x86.get_pc_thunk.bx
  117. .hidden __x86.get_pc_thunk.bx
  118. .type __x86.get_pc_thunk.bx,@function
  119. __x86.get_pc_thunk.bx:
  120. movl (%esp), %ebx;
  121. ret
  122. .size __x86.get_pc_thunk.bx,.-__x86.get_pc_thunk.bx
  123. #endif