Update copyright notices with scripts/update-copyrights
[jlayton/glibc.git] / nptl / sysdeps / unix / sysv / linux / sh / sem_trywait.S
1 /* Copyright (C) 2003-2014 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 <shlib-compat.h>
20 #include <pthread-errnos.h>
21 #include <lowlevellock.h>
22 #include "lowlevel-atomic.h"
23
24
25         .text
26
27         .globl  __new_sem_trywait
28         .type   __new_sem_trywait,@function
29         .align  5
30         cfi_startproc
31 __new_sem_trywait:
32         mov.l   r12, @-r15
33         cfi_adjust_cfa_offset (4)
34         cfi_rel_offset (r12, 0)
35         mov.l   r8, @-r15
36         cfi_adjust_cfa_offset (4)
37         cfi_rel_offset (r8, 0)
38         sts.l   pr, @-r15
39         cfi_adjust_cfa_offset (4)
40         cfi_rel_offset (pr, 0)
41         mov     r4, r8
42         mov.l   @r8, r0
43 2:
44         tst     r0, r0
45         bt      1f
46
47         mov     r0, r3
48         mov     r0, r4
49         add     #-1, r3
50         CMPXCHG (r4, @r8, r3, r2)
51         bf/s    2b
52          mov    r2, r0
53
54         cfi_remember_state
55         lds.l   @r15+, pr
56         cfi_adjust_cfa_offset (-4)
57         cfi_restore (pr)
58         mov.l   @r15+, r8
59         cfi_adjust_cfa_offset (-4)
60         cfi_restore (r8)
61         mov.l   @r15+, r12
62         cfi_adjust_cfa_offset (-4)
63         cfi_restore (r12)
64         rts
65          mov    #0, r0
66         cfi_restore_state
67
68 1:
69         mov     #EAGAIN, r8
70         mova    .Lgot1, r0
71         mov.l   .Lgot1, r12
72         add     r0, r12
73
74         mov.l   .Lerrno1, r0
75         stc     gbr, r1
76         mov.l   @(r0, r12), r0
77         bra     .Lexit
78          add    r1, r0
79         .align  2
80 .Lerrno1:
81         .long   errno@GOTTPOFF
82 .Lexit:
83         mov.l   r8, @r0
84         lds.l   @r15+, pr
85         cfi_adjust_cfa_offset (-4)
86         cfi_restore (pr)
87         mov.l   @r15+, r8
88         cfi_adjust_cfa_offset (-4)
89         cfi_restore (r8)
90         mov.l   @r15+, r12
91         cfi_adjust_cfa_offset (-4)
92         cfi_restore (r12)
93         rts
94          mov    #-1, r0
95
96         cfi_endproc
97
98         .align  2
99 .Lgot1:
100         .long   _GLOBAL_OFFSET_TABLE_
101         .size   __new_sem_trywait,.-__new_sem_trywait
102         versioned_symbol(libpthread, __new_sem_trywait, sem_trywait, GLIBC_2_1)