1 /* Copyright (C) 2003, 2007 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_wrlock
31 .type __pthread_rwlock_wrlock,@function
33 __pthread_rwlock_wrlock:
44 CMPXCHG (r3, @r8, r4, r2)
46 CMPXCHG (r3, @(MUTEX,r8), r4, r2)
50 mov.l @(WRITER,r8), r0
53 mov.l @(NR_READERS,r8), r0
57 mov.l @(WRITERS_QUEUED,r8), r0
59 mov.l r0, @(WRITERS_QUEUED,r8)
63 mov.l @(WRITERS_WAKEUP,r8), r9
74 add #WRITERS_WAKEUP, r4
75 #ifdef __ASSUME_PRIVATE_FUTEX
78 mov #(FUTEX_PRIVATE_FLAG|FUTEX_WAIT), r0
102 /* Reget the lock. */
106 CMPXCHG (r3, @r8, r4, r2)
108 CMPXCHG (r3, @(MUTEX,r8), r4, r2)
112 mov.l @(WRITERS_QUEUED,r8), r0
115 mov.l r0, @(WRITERS_QUEUED,r8)
122 mov.l r0, @(WRITER,r8)
127 DEC (@(MUTEX,r8), r2)
177 #ifndef __ASSUME_PRIVATE_FUTEX
179 .word PRIVATE_FUTEX - TLS_PRE_TCB_SIZE
182 .word TID - TLS_PRE_TCB_SIZE
185 mov.l @(WRITERS_QUEUED,r8), r1
187 mov.l r1, @(WRITERS_QUEUED,r8)
223 .long __lll_lock_wait-.Lwait4b
225 .long __lll_unlock_wake-.Lwake4b
227 .long __lll_lock_wait-.Lwait5b
229 .long __lll_unlock_wake-.Lwake5b
230 .globl pthread_rwlock_wrlock
231 pthread_rwlock_wrlock = __pthread_rwlock_wrlock
233 .globl __pthread_rwlock_wrlock_internal
234 __pthread_rwlock_wrlock_internal = __pthread_rwlock_wrlock