1 /* Copyright (C) 2003, 2007, 2008 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
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.
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.
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/>. */
19 #include <lowlevellock.h>
20 #include <lowlevelrwlock.h>
21 #include <pthread-errnos.h>
22 #include <tcb-offsets.h>
23 #include <bits/kernel-features.h>
24 #include "lowlevel-atomic.h"
29 .globl pthread_rwlock_timedwrlock
30 .type pthread_rwlock_timedwrlock,@function
32 pthread_rwlock_timedwrlock:
46 CMPXCHG (r3, @r8, r4, r2)
48 CMPXCHG (r3, @(MUTEX,r8), r4, r2)
52 mov.l @(WRITER,r8), r0
55 mov.l @(NR_READERS,r8), r0
59 /* Check the value of the timeout parameter. */
65 mov.l @(WRITERS_QUEUED,r8), r0
67 mov.l r0, @(WRITERS_QUEUED,r8)
71 mov.l @(WRITERS_WAKEUP,r8), r10
82 /* Get current time. */
85 mov #__NR_gettimeofday, r3
91 dmulu.l r0, r1 /* Milli seconds to nano seconds. */
105 bf 16f /* Time is already up. */
107 /* Store relative timeout. */
113 #ifdef __ASSUME_PRIVATE_FUTEX
116 mov #(FUTEX_PRIVATE_FLAG|FUTEX_WAIT), r0
135 add #WRITERS_WAKEUP, r4
143 /* Reget the lock. */
147 CMPXCHG (r5, @r8, r4, r2)
149 CMPXCHG (r5, @(MUTEX,r8), r4, r2)
154 mov.l @(WRITERS_QUEUED,r8), r0
156 mov.l r0, @(WRITERS_QUEUED,r8)
174 mov.l r0, @(WRITER,r8)
179 DEC (@(MUTEX,r8), r2)
193 #ifndef __ASSUME_PRIVATE_FUTEX
195 .word PRIVATE_FUTEX - TLS_PRE_TCB_SIZE
243 .word TID - TLS_PRE_TCB_SIZE
247 mov.l @(WRITERS_QUEUED,r8), r1
249 mov.l r1, @(WRITERS_QUEUED,r8)
290 .long __lll_lock_wait-.Lwait6b
292 .long __lll_unlock_wake-.Lwake6b
294 .long __lll_lock_wait-.Lwait7b
296 .long __lll_unlock_wake-.Lwake7b
297 .size pthread_rwlock_timedwrlock,.-pthread_rwlock_timedwrlock