sem_trywait.S 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 __new_sem_trywait
  21. .type __new_sem_trywait,@function
  22. .align 16
  23. __new_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 __new_sem_trywait,.-__new_sem_trywait
  58. weak_alias(__new_sem_trywait, sem_trywait)
  59. #ifdef __PIC__
  60. .section .gnu.linkonce.t.__x86.get_pc_thunk.cx,"ax",@progbits
  61. .globl __x86.get_pc_thunk.cx
  62. .hidden __x86.get_pc_thunk.cx
  63. .type __x86.get_pc_thunk.cx,@function
  64. __x86.get_pc_thunk.cx:
  65. movl (%esp), %ecx;
  66. ret
  67. .size __x86.get_pc_thunk.cx,.-__x86.get_pc_thunk.cx
  68. #endif