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 <lowlevelrwlock.h>
21 #include <kernel-features.h>
22 #include "lowlevel-atomic.h"
27 #define FUTEX_PRIVATE_FLAG 128
32 .globl __pthread_rwlock_unlock
33 .type __pthread_rwlock_unlock,@function
35 __pthread_rwlock_unlock:
45 CMPXCHG (r3, @r8, r4, r2)
47 CMPXCHG (r3, @(MUTEX,r8), r4, r2)
51 mov.l @(WRITER,r8), r0
54 mov.l @(NR_READERS,r8), r0
56 mov.l r0, @(NR_READERS,r8)
61 mov.l r0, @(WRITER,r8)
64 add #WRITERS_WAKEUP, r4
65 mov.l @(WRITERS_QUEUED,r8), r0
69 /* If also no readers waiting nothing to do. */
70 mov.l @(READERS_QUEUED,r8), r0
75 shlr r6 /* r6 = 0x7fffffff */
77 add #READERS_WAKEUP, r4
92 #if __ASSUME_PRIVATE_FUTEX
95 mov #(FUTEX_PRIVATE_FLAG|FUTEX_WAKE), r0
125 DEC (@(MUTEX,r8), r2)
176 #if !__ASSUME_PRIVATE_FUTEX
178 .word PRIVATE_FUTEX - TLS_PRE_TCB_SIZE
182 .long __lll_mutex_lock_wait-.Lwait8b
184 .long __lll_mutex_unlock_wake-.Lwake8b
186 .long __lll_mutex_unlock_wake-.Lwake9b
187 .size __pthread_rwlock_unlock,.-__pthread_rwlock_unlock
189 .globl pthread_rwlock_unlock
190 pthread_rwlock_unlock = __pthread_rwlock_unlock
192 .globl __pthread_rwlock_unlock_internal
193 __pthread_rwlock_unlock_internal = __pthread_rwlock_unlock