sem_trywait.S 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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, see
  14. <http://www.gnu.org/licenses/>. */
  15. #include <sysdep.h>
  16. #include <pthread-errnos.h>
  17. #include <lowlevellock.h>
  18. .text
  19. .globl sem_trywait
  20. .type sem_trywait,@function
  21. .align 16
  22. sem_trywait:
  23. movl 4(%esp), %ecx
  24. movl (%ecx), %eax
  25. 2: testl %eax, %eax
  26. jz 1f
  27. leal -1(%eax), %edx
  28. LOCK
  29. cmpxchgl %edx, (%ecx)
  30. jne 2b
  31. xorl %eax, %eax
  32. ret
  33. 1:
  34. #ifdef __PIC__
  35. call __x86.get_pc_thunk.cx
  36. #else
  37. movl $3f, %ecx
  38. 3:
  39. #endif
  40. addl $_GLOBAL_OFFSET_TABLE_, %ecx
  41. #if USE___THREAD
  42. # ifdef NO_TLS_DIRECT_SEG_REFS
  43. movl errno@gotntpoff(%ecx), %edx
  44. addl %gs:0, %edx
  45. movl $EAGAIN, (%edx)
  46. # else
  47. movl errno@gotntpoff(%ecx), %edx
  48. movl $EAGAIN, %gs:(%edx)
  49. # endif
  50. #else
  51. call __errno_location@plt
  52. movl $EAGAIN, (%eax)
  53. #endif
  54. orl $-1, %eax
  55. ret
  56. .size sem_trywait,.-sem_trywait
  57. #ifdef __PIC__
  58. .section .gnu.linkonce.t.__x86.get_pc_thunk.cx,"ax",@progbits
  59. .globl __x86.get_pc_thunk.cx
  60. .hidden __x86.get_pc_thunk.cx
  61. .type __x86.get_pc_thunk.cx,@function
  62. __x86.get_pc_thunk.cx:
  63. movl (%esp), %ecx;
  64. ret
  65. .size __x86.get_pc_thunk.cx,.-__x86.get_pc_thunk.cx
  66. #endif