]> git.ipfire.org Git - thirdparty/glibc.git/blame - nptl/sysdeps/unix/sysv/linux/sh/pthread_rwlock_unlock.S
Update copyright notices with scripts/update-copyrights
[thirdparty/glibc.git] / nptl / sysdeps / unix / sysv / linux / sh / pthread_rwlock_unlock.S
CommitLineData
d4697bc9 1/* Copyright (C) 2003-2014 Free Software Foundation, Inc.
a54e8d33
UD
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
59ba27a6
PE
15 License along with the GNU C Library; if not, see
16 <http://www.gnu.org/licenses/>. */
a54e8d33
UD
17
18#include <sysdep.h>
ce31a3b1 19#include <lowlevellock.h>
a54e8d33 20#include <lowlevelrwlock.h>
339dbf0e 21#include <kernel-features.h>
a54e8d33
UD
22#include "lowlevel-atomic.h"
23
a54e8d33
UD
24
25 .text
26
27 .globl __pthread_rwlock_unlock
28 .type __pthread_rwlock_unlock,@function
29 .align 5
65a4de4e 30 cfi_startproc
a54e8d33
UD
31__pthread_rwlock_unlock:
32 mov.l r12, @-r15
65a4de4e
CLT
33 cfi_adjust_cfa_offset (4)
34 cfi_rel_offset (r12, 0)
a54e8d33 35 mov.l r8, @-r15
65a4de4e
CLT
36 cfi_adjust_cfa_offset (4)
37 cfi_rel_offset (r8, 0)
a54e8d33 38 sts.l pr, @-r15
65a4de4e
CLT
39 cfi_adjust_cfa_offset (4)
40 cfi_rel_offset (pr, 0)
a54e8d33
UD
41 mov r4, r8
42
43 /* Get the lock. */
fa3cbe3d
UD
44 mov #0, r3
45 mov #1, r4
a54e8d33 46#if MUTEX == 0
fa3cbe3d 47 CMPXCHG (r3, @r8, r4, r2)
a54e8d33 48#else
fa3cbe3d 49 CMPXCHG (r3, @(MUTEX,r8), r4, r2)
a54e8d33 50#endif
a54e8d33
UD
51 bf 1f
522:
53 mov.l @(WRITER,r8), r0
54 tst r0, r0
55 bf 5f
56 mov.l @(NR_READERS,r8), r0
57 add #-1, r0
58 mov.l r0, @(NR_READERS,r8)
59 tst r0, r0
60 bf 6f
615:
62 mov #0, r0
63 mov.l r0, @(WRITER,r8)
dd731d53 64 mov #1, r6
a54e8d33 65 mov r8, r4
dd731d53 66 add #WRITERS_WAKEUP, r4
a54e8d33
UD
67 mov.l @(WRITERS_QUEUED,r8), r0
68 tst r0, r0
dd731d53
UD
69 bf 0f
70
71 /* If also no readers waiting nothing to do. */
72 mov.l @(READERS_QUEUED,r8), r0
73 tst r0, r0
74 bt 6f
75
a54e8d33
UD
76 mov #-1, r6
77 shlr r6 /* r6 = 0x7fffffff */
dd731d53
UD
78 mov r8, r4
79 add #READERS_WAKEUP, r4
80
a54e8d33 810:
dd731d53
UD
82 mov.l @r4, r0
83 add #1, r0
84 mov.l r0, @r4
85#if MUTEX == 0
86 DEC (@r8, r2)
87#else
88 DEC (@(MUTEX,r8), r2)
89#endif
90 tst r2, r2
91 bf 7f
92
938:
d13f4a43 94#ifdef __ASSUME_PRIVATE_FUTEX
339dbf0e
UD
95 mov #PSHARED, r0
96 mov.b @(r0,r8), r5
97 mov #(FUTEX_PRIVATE_FLAG|FUTEX_WAKE), r0
98 xor r0, r5
99 extu.b r5, r5
100#else
101 mov #PSHARED, r0
102 mov.b @(r0,r8), r5
103 extu.b r5, r5
104 mov #FUTEX_WAKE, r0
105 or r0, r5
106 stc gbr, r1
107 mov.w .Lpfoff, r2
108 add r2, r1
109 mov.l @r1, r0
110 xor r0, r5
111#endif
a54e8d33 112 mov #SYS_futex, r3
dd731d53 113 mov #0, r7
a54e8d33
UD
114 extu.b r3, r3
115 trapa #0x14
116 SYSCALL_INST_PAD
117
65a4de4e 118 cfi_remember_state
dd731d53 119 lds.l @r15+, pr
65a4de4e
CLT
120 cfi_adjust_cfa_offset (-4)
121 cfi_restore (pr)
dd731d53 122 mov.l @r15+, r8
65a4de4e
CLT
123 cfi_adjust_cfa_offset (-4)
124 cfi_restore (r8)
dd731d53 125 mov.l @r15+, r12
65a4de4e
CLT
126 cfi_adjust_cfa_offset (-4)
127 cfi_restore (r12)
dd731d53
UD
128 rts
129 mov #0, r0
65a4de4e 130 cfi_restore_state
a54e8d33
UD
1316:
132#if MUTEX == 0
133 DEC (@r8, r2)
134#else
135 DEC (@(MUTEX,r8), r2)
136#endif
137 tst r2, r2
138 bf 3f
1394:
65a4de4e 140 cfi_remember_state
a54e8d33 141 lds.l @r15+, pr
65a4de4e
CLT
142 cfi_adjust_cfa_offset (-4)
143 cfi_restore (pr)
a54e8d33 144 mov.l @r15+, r8
65a4de4e
CLT
145 cfi_adjust_cfa_offset (-4)
146 cfi_restore (r8)
a54e8d33 147 mov.l @r15+, r12
65a4de4e
CLT
148 cfi_adjust_cfa_offset (-4)
149 cfi_restore (r12)
a54e8d33
UD
150 rts
151 mov #0, r0
65a4de4e 152 cfi_restore_state
a54e8d33
UD
153
1541:
155 mov r8, r5
156#if MUTEX != 0
157 add #MUTEX, r5
158#endif
ce31a3b1
UD
159 mov #PSHARED, r0
160 mov.b @(r0,r8), r6
161 extu.b r6, r6
a54e8d33
UD
162 mov.l .Lwait8, r1
163 bsrf r1
ce31a3b1 164 mov r2, r4
a54e8d33
UD
165.Lwait8b:
166 bra 2b
167 nop
1683:
169 mov r8, r4
170#if MUTEX != 0
171 add #MUTEX, r4
172#endif
ce31a3b1
UD
173 mov #PSHARED, r0
174 mov.b @(r0,r8), r5
175 extu.b r5, r5
a54e8d33
UD
176 mov.l .Lwake8, r1
177 bsrf r1
178 nop
179.Lwake8b:
180 bra 4b
181 nop
182
dd731d53
UD
1837:
184 mov.l r4, @-r15
65a4de4e 185 cfi_adjust_cfa_offset (4)
dd731d53 186 mov.l r6, @-r15
65a4de4e 187 cfi_adjust_cfa_offset (4)
dd731d53
UD
188 mov r8, r4
189#if MUTEX != 0
190 add #MUTEX, r4
191#endif
ce31a3b1
UD
192 mov #PSHARED, r0
193 mov.b @(r0,r8), r5
194 extu.b r5, r5
dd731d53
UD
195 mov.l .Lwake9, r1
196 bsrf r1
197 nop
198.Lwake9b:
199
200 mov.l @r15+, r6
65a4de4e 201 cfi_adjust_cfa_offset (-4)
dd731d53
UD
202 bra 8b
203 mov.l @r15+, r4
204
65a4de4e
CLT
205 cfi_endproc
206
d13f4a43 207#ifndef __ASSUME_PRIVATE_FUTEX
339dbf0e
UD
208.Lpfoff:
209 .word PRIVATE_FUTEX - TLS_PRE_TCB_SIZE
210#endif
a54e8d33 211 .align 2
c7afae94 212.Lwait8:
ce31a3b1 213 .long __lll_lock_wait-.Lwait8b
a54e8d33 214.Lwake8:
ce31a3b1 215 .long __lll_unlock_wake-.Lwake8b
dd731d53 216.Lwake9:
ce31a3b1 217 .long __lll_unlock_wake-.Lwake9b
a54e8d33
UD
218 .size __pthread_rwlock_unlock,.-__pthread_rwlock_unlock
219
4d17e683
AS
220strong_alias (__pthread_rwlock_unlock, pthread_rwlock_unlock)
221hidden_def (__pthread_rwlock_unlock)