OSDN Git Service

Replace FSF snail mail address with URLs
[uclinux-h8/uClibc.git] / libpthread / nptl / sysdeps / unix / sysv / linux / sh / sem_trywait.S
1 /* Copyright (C) 2003, 2004, 2007 Free Software Foundation, Inc.
2    This file is part of the GNU C Library.
3
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
9    The GNU C Library is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12    Lesser General Public License for more details.
13
14    You should have received a copy of the GNU Lesser General Public
15    License along with the GNU C Library; if not, see
16    <http://www.gnu.org/licenses/>.  */
17
18 #include <sysdep.h>
19 #include <pthread-errnos.h>
20 #include <lowlevellock.h>
21 #include "lowlevel-atomic.h"
22
23
24         .text
25
26         .globl  sem_trywait
27         .type   sem_trywait,@function
28         .align  5
29 sem_trywait:
30         mov.l   r12, @-r15
31         mov.l   r8, @-r15
32         sts.l   pr, @-r15
33         mov     r4, r8
34         mov.l   @r8, r0
35 2:
36         tst     r0, r0
37         bt      1f
38
39         mov     r0, r3
40         mov     r0, r4
41         add     #-1, r3
42         CMPXCHG (r4, @r8, r3, r2)
43         bf/s    2b
44          mov    r2, r0
45
46         lds.l   @r15+, pr
47         mov.l   @r15+, r8
48         mov.l   @r15+, r12
49         rts
50          mov    #0, r0
51
52 1:
53         mov     #EAGAIN, r8
54         mova    .Lgot1, r0
55         mov.l   .Lgot1, r12
56         add     r0, r12
57
58 #if USE___THREAD
59         mov.l   .Lerrno1, r0
60         stc     gbr, r1
61         mov.l   @(r0, r12), r0
62         bra     .Lexit
63          add    r1, r0
64         .align  2
65 .Lerrno1:
66         .long   errno@GOTTPOFF
67 .Lexit:
68 #else
69         mov.l   .Lerrloc1, r1
70         bsrf    r1
71          nop
72 .Lerrloc1b:
73 #endif
74         mov.l   r8, @r0
75         lds.l   @r15+, pr
76         mov.l   @r15+, r8
77         mov.l   @r15+, r12
78         rts
79          mov    #-1, r0
80
81         .align  2
82 .Lgot1:
83         .long   _GLOBAL_OFFSET_TABLE_
84 #if !USE___THREAD
85 .Lerrloc1:
86         .long   __errno_location@PLT-(.Lerrloc1b-.)
87 #endif
88         .size   sem_trywait,.-sem_trywait