sem_post.S 1.5 KB

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