]> sourceware.org Git - glibc.git/blob - nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_rdlock.S
Remove use of INTDEF/INTUSE in nptl
[glibc.git] / nptl / sysdeps / unix / sysv / linux / x86_64 / pthread_rwlock_rdlock.S
1 /* Copyright (C) 2002-2012 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, see
17 <http://www.gnu.org/licenses/>. */
18
19 #include <sysdep.h>
20 #include <lowlevellock.h>
21 #include <lowlevelrwlock.h>
22 #include <pthread-errnos.h>
23 #include <kernel-features.h>
24 #include <stap-probe.h>
25
26 .text
27
28 .globl __pthread_rwlock_rdlock
29 .type __pthread_rwlock_rdlock,@function
30 .align 16
31 __pthread_rwlock_rdlock:
32 cfi_startproc
33
34 LIBC_PROBE (rdlock_entry, 1, %rdi)
35
36 xorq %r10, %r10
37
38 /* Get the lock. */
39 movl $1, %esi
40 xorl %eax, %eax
41 LOCK
42 #if MUTEX == 0
43 cmpxchgl %esi, (%rdi)
44 #else
45 cmpxchgl %esi, MUTEX(%rdi)
46 #endif
47 jnz 1f
48
49 2: movl WRITER(%rdi), %eax
50 testl %eax, %eax
51 jne 14f
52 cmpl $0, WRITERS_QUEUED(%rdi)
53 je 5f
54 cmpl $0, FLAGS(%rdi)
55 je 5f
56
57 3: incl READERS_QUEUED(%rdi)
58 je 4f
59
60 movl READERS_WAKEUP(%rdi), %edx
61
62 LOCK
63 #if MUTEX == 0
64 decl (%rdi)
65 #else
66 decl MUTEX(%rdi)
67 #endif
68 jne 10f
69
70 11:
71 #ifdef __ASSUME_PRIVATE_FUTEX
72 movl $FUTEX_PRIVATE_FLAG|FUTEX_WAIT, %esi
73 xorl PSHARED(%rdi), %esi
74 #else
75 # if FUTEX_WAIT == 0
76 movl PSHARED(%rdi), %esi
77 # else
78 movl $FUTEX_WAIT, %esi
79 orl PSHARED(%rdi), %esi
80 # endif
81 xorl %fs:PRIVATE_FUTEX, %esi
82 #endif
83 addq $READERS_WAKEUP, %rdi
84 movl $SYS_futex, %eax
85 syscall
86
87 subq $READERS_WAKEUP, %rdi
88
89 /* Reget the lock. */
90 movl $1, %esi
91 xorl %eax, %eax
92 LOCK
93 #if MUTEX == 0
94 cmpxchgl %esi, (%rdi)
95 #else
96 cmpxchgl %esi, MUTEX(%rdi)
97 #endif
98 jnz 12f
99
100 13: decl READERS_QUEUED(%rdi)
101 jmp 2b
102
103 5: xorl %edx, %edx
104 incl NR_READERS(%rdi)
105 je 8f
106 9: LOCK
107 #if MUTEX == 0
108 decl (%rdi)
109 #else
110 decl MUTEX(%rdi)
111 #endif
112 jne 6f
113 7:
114
115 movq %rdx, %rax
116 retq
117
118 1: movl PSHARED(%rdi), %esi
119 #if MUTEX != 0
120 addq $MUTEX, %rdi
121 #endif
122 callq __lll_lock_wait
123 #if MUTEX != 0
124 subq $MUTEX, %rdi
125 #endif
126 jmp 2b
127
128 14: cmpl %fs:TID, %eax
129 jne 3b
130 /* Deadlock detected. */
131 movl $EDEADLK, %edx
132 jmp 9b
133
134 6: movl PSHARED(%rdi), %esi
135 #if MUTEX != 0
136 addq $MUTEX, %rdi
137 #endif
138 callq __lll_unlock_wake
139 #if MUTEX != 0
140 subq $MUTEX, %rdi
141 #endif
142 jmp 7b
143
144 /* Overflow. */
145 8: decl NR_READERS(%rdi)
146 movl $EAGAIN, %edx
147 jmp 9b
148
149 /* Overflow. */
150 4: decl READERS_QUEUED(%rdi)
151 movl $EAGAIN, %edx
152 jmp 9b
153
154 10: movl PSHARED(%rdi), %esi
155 #if MUTEX != 0
156 addq $MUTEX, %rdi
157 #endif
158 callq __lll_unlock_wake
159 #if MUTEX != 0
160 subq $MUTEX, %rdi
161 #endif
162 jmp 11b
163
164 12: movl PSHARED(%rdi), %esi
165 #if MUTEX == 0
166 addq $MUTEX, %rdi
167 #endif
168 callq __lll_lock_wait
169 #if MUTEX != 0
170 subq $MUTEX, %rdi
171 #endif
172 jmp 13b
173 cfi_endproc
174 .size __pthread_rwlock_rdlock,.-__pthread_rwlock_rdlock
175
176 strong_alias (__pthread_rwlock_rdlock, pthread_rwlock_rdlock)
177 hidden_def (__pthread_rwlock_rdlock)
This page took 0.045682 seconds and 5 git commands to generate.