OSDN Git Service

2013.10.24
[uclinux-h8/uClinux-dist.git] / uClibc / libpthread / nptl / sysdeps / unix / sysv / linux / i386 / i486 / sem_trywait.S
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
5    The GNU C Library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public
7    License as published by the Free Software Foundation; either
8    version 2.1 of the License, or (at your option) any later version.
9
10    The GNU C Library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Lesser General Public License for more details.
14
15    You should have received a copy of the GNU Lesser General Public
16    License along with the GNU C Library; if not, write to the Free
17    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18    02111-1307 USA.  */
19
20 #include <sysdep.h>
21 #include <pthread-errnos.h>
22 #include <lowlevellock.h>
23
24         .text
25
26         .globl  __new_sem_trywait
27         .type   __new_sem_trywait,@function
28         .align  16
29 __new_sem_trywait:
30         movl    4(%esp), %ecx
31
32         movl    (%ecx), %eax
33 2:      testl   %eax, %eax
34         jz      1f
35
36         leal    -1(%eax), %edx
37         LOCK
38         cmpxchgl %edx, (%ecx)
39         jne     2b
40         xorl    %eax, %eax
41         ret
42
43 1:
44 #ifdef __PIC__
45         call    __x86.get_pc_thunk.cx
46 #else
47         movl    $3f, %ecx
48 3:
49 #endif
50         addl    $_GLOBAL_OFFSET_TABLE_, %ecx
51 #if USE___THREAD
52 # ifdef NO_TLS_DIRECT_SEG_REFS
53         movl    errno@gotntpoff(%ecx), %edx
54         addl    %gs:0, %edx
55         movl    $EAGAIN, (%edx)
56 # else
57         movl    errno@gotntpoff(%ecx), %edx
58         movl    $EAGAIN, %gs:(%edx)
59 # endif
60 #else
61         call    __errno_location@plt
62         movl    $EAGAIN, (%eax)
63 #endif
64         orl     $-1, %eax
65         ret
66         .size   __new_sem_trywait,.-__new_sem_trywait
67 weak_alias(__new_sem_trywait, sem_trywait)
68
69
70 #ifdef __PIC__
71         .section .gnu.linkonce.t.__x86.get_pc_thunk.cx,"ax",@progbits
72         .globl  __x86.get_pc_thunk.cx
73         .hidden __x86.get_pc_thunk.cx
74         .type   __x86.get_pc_thunk.cx,@function
75 __x86.get_pc_thunk.cx:
76         movl (%esp), %ecx;
77         ret
78         .size   __x86.get_pc_thunk.cx,.-__x86.get_pc_thunk.cx
79 #endif