sem_post.S 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /* Copyright (C) 2002, 2003, 2005 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 <tls.h>
  19. #ifndef UP
  20. # define LOCK lock
  21. #else
  22. # define
  23. #endif
  24. #define FUTEX_WAKE 1
  25. .text
  26. .globl __new_sem_post
  27. .type __new_sem_post,@function
  28. .align 16
  29. __new_sem_post:
  30. pushl %ebx
  31. movl 8(%esp), %ebx
  32. movl $1, %edx
  33. LOCK
  34. xaddl %edx, (%ebx)
  35. movl $SYS_futex, %eax
  36. movl $FUTEX_WAKE, %ecx
  37. addl $1, %edx
  38. ENTER_KERNEL
  39. testl %eax, %eax
  40. js 1f
  41. xorl %eax, %eax
  42. popl %ebx
  43. ret
  44. 1:
  45. #ifdef PIC
  46. call __i686.get_pc_thunk.bx
  47. #else
  48. movl $4f, %ebx
  49. 4:
  50. #endif
  51. addl $_GLOBAL_OFFSET_TABLE_, %ebx
  52. #if USE___THREAD
  53. # ifdef NO_TLS_DIRECT_SEG_REFS
  54. movl errno@gotntpoff(%ebx), %edx
  55. addl %gs:0, %edx
  56. movl $EINVAL, (%edx)
  57. # else
  58. movl errno@gotntpoff(%ebx), %edx
  59. movl $EINVAL, %gs:(%edx)
  60. # endif
  61. #else
  62. call __errno_location@plt
  63. movl $EINVAL, (%eax)
  64. #endif
  65. orl $-1, %eax
  66. popl %ebx
  67. ret
  68. .size __new_sem_post,.-__new_sem_post
  69. weak_alias(__new_sem_post, sem_post)
  70. #ifdef PIC
  71. .section .gnu.linkonce.t.__i686.get_pc_thunk.bx,"ax",@progbits
  72. .globl __i686.get_pc_thunk.bx
  73. .hidden __i686.get_pc_thunk.bx
  74. .type __i686.get_pc_thunk.bx,@function
  75. __i686.get_pc_thunk.bx:
  76. movl (%esp), %ebx;
  77. ret
  78. .size __i686.get_pc_thunk.bx,.-__i686.get_pc_thunk.bx
  79. #endif