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 <kernel-features.h>
29 .globl pthread_rwlock_timedwrlock
30 .type pthread_rwlock_timedwrlock,@function
32 pthread_rwlock_timedwrlock:
49 cmpxchgl %edx, MUTEX(%ebp)
53 2: movl WRITER(%ebp), %eax
56 cmpl $0, NR_READERS(%ebp)
59 /* Check the value of the timeout parameter. */
60 3: cmpl $1000000000, 4(%edi)
63 addl $1, WRITERS_QUEUED(%ebp)
66 movl WRITERS_WAKEUP(%ebp), %esi
76 /* Get current time. */
79 movl $__NR_gettimeofday, %eax
82 /* Compute relative timeout. */
85 mul %edx /* Milli seconds to nano seconds. */
91 addl $1000000000, %edx
94 js 16f /* Time is already up. */
97 movl %ecx, (%esp) /* Store relative timeout. */
101 #ifdef __ASSUME_PRIVATE_FUTEX
102 movzbl PSHARED(%ebp), %ecx
103 xorl $FUTEX_PRIVATE_FLAG|FUTEX_WAIT, %ecx
105 movzbl PSHARED(%ebp), %ecx
107 orl $FUTEX_WAIT, %ecx
109 xorl %gs:PRIVATE_FUTEX, %ecx
112 leal WRITERS_WAKEUP(%ebp), %ebx
113 movl $SYS_futex, %eax
118 /* Reget the lock. */
123 cmpxchgl %edx, (%ebp)
125 cmpxchgl %edx, MUTEX(%ebp)
129 13: subl $1, WRITERS_QUEUED(%ebp)
130 cmpl $-ETIMEDOUT, %esi
133 18: movl $ETIMEDOUT, %edx
139 movl %eax, WRITER(%ebp)
161 leal MUTEX(%ebp), %edx
163 movzbl PSHARED(%ebp), %ecx
167 14: cmpl %gs:TID, %eax
169 20: movl $EDEADLK, %edx
176 leal MUTEX(%ebp), %eax
178 movzbl PSHARED(%ebp), %ecx
179 call __lll_unlock_wake
183 4: subl $1, WRITERS_QUEUED(%ebp)
191 leal MUTEX(%ebp), %eax
193 movzbl PSHARED(%ebp), %ecx
194 call __lll_unlock_wake
201 leal MUTEX(%ebp), %edx
203 movzbl PSHARED(%ebp), %ecx
207 16: movl $-ETIMEDOUT, %esi
210 19: movl $EINVAL, %edx
212 .size pthread_rwlock_timedwrlock,.-pthread_rwlock_timedwrlock