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, write to the Free
16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
20 #include <lowlevellock.h>
21 #include <lowlevelrwlock.h>
22 #include <pthread-errnos.h>
23 #include <tcb-offsets.h>
24 #include <kernel-features.h>
25 #include "lowlevel-atomic.h"
30 .globl pthread_rwlock_timedrdlock
31 .type pthread_rwlock_timedrdlock,@function
33 pthread_rwlock_timedrdlock:
47 CMPXCHG (r3, @r8, r4, r2)
49 CMPXCHG (r3, @(MUTEX,r8), r4, r2)
53 mov.l @(WRITER,r8), r0
56 mov.l @(WRITERS_QUEUED,r8), r0
64 /* Check the value of the timeout parameter. */
70 mov.l @(READERS_QUEUED,r8), r0
72 mov.l r0, @(READERS_QUEUED,r8)
76 mov.l @(READERS_WAKEUP,r8), r10
87 /* Get current time. */
90 mov #__NR_gettimeofday, r3
96 dmulu.l r0, r1 /* Milli seconds to nano seconds. */
110 bf 16f /* Time is already up. */
112 /* Store relative timeout. */
118 #ifdef __ASSUME_PRIVATE_FUTEX
121 mov #(FUTEX_PRIVATE_FLAG|FUTEX_WAIT), r0
140 add #READERS_WAKEUP, r4
148 /* Reget the lock. */
152 CMPXCHG (r5, @r8, r4, r2)
154 CMPXCHG (r5, @(MUTEX,r8), r4, r2)
159 mov.l @(READERS_QUEUED,r8), r0
161 mov.l r0, @(READERS_QUEUED,r8)
172 mov.l @(NR_READERS,r8), r0
174 mov.l r0, @(NR_READERS,r8)
182 DEC (@(MUTEX,r8), r2)
196 #ifndef __ASSUME_PRIVATE_FUTEX
198 .word PRIVATE_FUTEX - TLS_PRE_TCB_SIZE
227 /* Deadlock detected. */
232 .word TID - TLS_PRE_TCB_SIZE
252 mov.l @(NR_READERS,r8), r1
254 mov.l r1, @(NR_READERS,r8)
260 mov.l @(READERS_QUEUED,r8), r1
262 mov.l r1, @(READERS_QUEUED,r8)
307 .long __lll_lock_wait-.Lwait2b
309 .long __lll_unlock_wake-.Lwake2b
311 .long __lll_lock_wait-.Lwait3b
313 .long __lll_unlock_wake-.Lwake3b
314 .size pthread_rwlock_timedrdlock,.-pthread_rwlock_timedrdlock