sem_trywait.S 1.9 KB

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