1 /* Copyright (C) 2003 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 <lowlevelrwlock.h>
21 #include <tcb-offsets.h>
22 #include "lowlevel-atomic.h"
24 #define SYS_gettimeofday __NR_gettimeofday
36 .globl pthread_rwlock_timedrdlock
37 .type pthread_rwlock_timedrdlock,@function
39 pthread_rwlock_timedrdlock:
53 XADD (r3, @(MUTEX,r4), r2)
58 mov.l @(WRITER,r8), r0
61 mov.l @(WRITERS_QUEUED,r8), r0
68 mov.l @(READERS_QUEUED,r8), r0
70 mov.l r0, @(READERS_QUEUED,r8)
83 /* Get current time. */
86 mov #SYS_gettimeofday, r3
92 dmulu.l r0, r1 /* Milli seconds to nano seconds. */
106 bf 16f /* Time is already up. */
108 /* Store relative timeout. */
117 add #READERS_WAKEUP, r4
125 /* Reget the lock. */
131 XADD (r5, @(MUTEX,r4), r2)
140 mov.l @(READERS_QUEUED,r8), r0
142 mov.l r0, @(READERS_QUEUED,r8)
146 mov.l r0, @(READERS_WAKEUP,r8)
150 mov.l @(NR_READERS,r8), r0
152 mov.l r0, @(NR_READERS,r8)
160 DEC (@(MUTEX,r8), r2)
198 /* Deadlock detected. */
216 mov.l @(NR_READERS,r8), r1
218 mov.l r1, @(NR_READERS,r8)
224 mov.l @(READERS_QUEUED,r8), r1
226 mov.l r1, @(READERS_QUEUED,r8)
264 .word TLS_PRE_TCB_SIZE
267 .long __lll_mutex_lock_wait-.Lwait2b
269 .long __lll_mutex_unlock_wake-.Lwake2b
271 .long __lll_mutex_lock_wait-.Lwait3b
273 .long __lll_mutex_unlock_wake-.Lwake3b
274 .size pthread_rwlock_timedrdlock,.-pthread_rwlock_timedrdlock