sem_post.S 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. #ifndef UP
  19. # define LOCK lock
  20. #else
  21. # define
  22. #endif
  23. #define FUTEX_WAKE 1
  24. .text
  25. .globl sem_post
  26. .type sem_post,@function
  27. .align 16
  28. sem_post:
  29. movl $1, %edx
  30. LOCK
  31. xaddl %edx, (%rdi)
  32. movl $SYS_futex, %eax
  33. movl $FUTEX_WAKE, %esi
  34. incl %edx
  35. syscall
  36. testq %rax, %rax
  37. js 1f
  38. xorl %eax, %eax
  39. retq
  40. 1:
  41. #if USE___THREAD
  42. movq errno@gottpoff(%rip), %rdx
  43. movl $EINVAL, %fs:(%rdx)
  44. #else
  45. callq __errno_location@plt
  46. movl $EINVAL, (%rax)
  47. #endif
  48. orl $-1, %eax
  49. retq
  50. .size sem_post,.-sem_post