sem_trywait.S 2.0 KB

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