1 /* Copyright (C) 2002, 2003, 2007 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
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.
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.
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
21 #include <lowlevellock.h>
22 #include <lowlevelrwlock.h>
23 #include <pthread-errnos.h>
24 #include <bits/kernel-features.h>
30 .globl pthread_rwlock_timedrdlock
31 .type pthread_rwlock_timedrdlock,@function
33 pthread_rwlock_timedrdlock:
36 cfi_adjust_cfa_offset(4)
38 cfi_adjust_cfa_offset(4)
40 cfi_adjust_cfa_offset(4)
42 cfi_adjust_cfa_offset(4)
48 cfi_adjust_cfa_offset(8)
60 cmpxchgl %edx, MUTEX(%ebp)
64 2: movl WRITER(%ebp), %eax
67 cmpl $0, WRITERS_QUEUED(%ebp)
72 /* Check the value of the timeout parameter. */
73 3: cmpl $1000000000, 4(%edi)
76 addl $1, READERS_QUEUED(%ebp)
79 movl READERS_WAKEUP(%ebp), %esi
89 /* Get current time. */
92 movl $__NR_gettimeofday, %eax
95 /* Compute relative timeout. */
98 mul %edx /* Milli seconds to nano seconds. */
104 addl $1000000000, %edx
107 js 16f /* Time is already up. */
110 movl %ecx, (%esp) /* Store relative timeout. */
114 #ifdef __ASSUME_PRIVATE_FUTEX
115 movzbl PSHARED(%ebp), %ecx
116 xorl $FUTEX_PRIVATE_FLAG|FUTEX_WAIT, %ecx
118 movzbl PSHARED(%ebp), %ecx
120 orl $FUTEX_WAIT, %ecx
122 xorl %gs:PRIVATE_FUTEX, %ecx
125 leal READERS_WAKEUP(%ebp), %ebx
126 movl $SYS_futex, %eax
131 /* Reget the lock. */
136 cmpxchgl %edx, (%ebp)
138 cmpxchgl %edx, MUTEX(%ebp)
142 13: subl $1, READERS_QUEUED(%ebp)
143 cmpl $-ETIMEDOUT, %esi
146 18: movl $ETIMEDOUT, %edx
151 addl $1, NR_READERS(%ebp)
164 cfi_adjust_cfa_offset(-8)
166 cfi_adjust_cfa_offset(-4)
169 cfi_adjust_cfa_offset(-4)
172 cfi_adjust_cfa_offset(-4)
175 cfi_adjust_cfa_offset(-4)
179 cfi_adjust_cfa_offset(24)
181 cfi_offset(%edi, -12)
182 cfi_offset(%ebx, -16)
183 cfi_offset(%ebp, -20)
188 leal MUTEX(%ebp), %edx
190 movzbl PSHARED(%ebp), %ecx
194 14: cmpl %gs:TID, %eax
203 leal MUTEX(%ebp), %eax
205 movzbl PSHARED(%ebp), %ecx
206 call __lll_unlock_wake
210 8: subl $1, NR_READERS(%ebp)
215 4: subl $1, READERS_QUEUED(%ebp)
223 leal MUTEX(%ebp), %eax
225 movzbl PSHARED(%ebp), %ecx
226 call __lll_unlock_wake
233 leal MUTEX(%ebp), %edx
235 movzbl PSHARED(%ebp), %ecx
239 16: movl $-ETIMEDOUT, %esi
242 19: movl $EINVAL, %edx
245 .size pthread_rwlock_timedrdlock,.-pthread_rwlock_timedrdlock