1 /* Copyright (C) 2003, 2004, 2006, 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 <shlib-compat.h>
21 #include <lowlevellock.h>
22 #include <lowlevelcond.h>
23 #include <kernel-features.h>
24 #include <pthread-pi-defines.h>
25 #include <pthread-errnos.h>
26 #include "lowlevel-atomic.h"
30 /* int pthread_cond_broadcast (pthread_cond_t *cond) */
31 .globl __pthread_cond_broadcast
32 .type __pthread_cond_broadcast, @function
34 __pthread_cond_broadcast:
41 /* Get internal lock. */
45 CMPXCHG (r3, @(cond_lock,r8), r4, r2)
47 CMPXCHG (r3, @r8, r4, r2)
51 mov.l @(total_seq+4,r8),r0
52 mov.l @(total_seq,r8),r1
53 mov.l @(wakeup_seq+4,r8), r2
58 mov.l @(wakeup_seq,r8), r2
63 /* Cause all currently waiting threads to recognize they are
65 mov.l r1, @(wakeup_seq,r8)
66 mov.l r0, @(wakeup_seq+4,r8)
67 mov.l r1, @(woken_seq,r8)
68 mov.l r0, @(woken_seq+4,r8)
69 mov.l @(broadcast_seq,r8), r2
71 mov.l r2, @(broadcast_seq,r8)
74 mov.l r10, @(cond_futex,r8)
76 /* Get the address of the mutex used. */
77 mov.l @(dep_mutex,r8), r9
81 DEC (@(cond_lock,r8), r2)
89 /* Don't use requeue for pshared condvars. */
96 /* XXX: The kernel only supports FUTEX_CMP_REQUEUE to the same
97 type of futex (private resp. shared). */
98 mov.l @(MUTEX_KIND,r9), r0
99 tst #(PI_BIT|PS_BIT), r0
102 /* Wake up all threads. */
103 #ifdef __ASSUME_PRIVATE_FUTEX
104 mov #(FUTEX_CMP_REQUEUE|FUTEX_PRIVATE_FLAG), r5
111 mov #FUTEX_CMP_REQUEUE, r0
116 shlr r7 /* r7 = 0x7fffffff */
118 # if MUTEX_FUTEX != 0
127 /* For any kind of error, which mainly is EAGAIN, we try again
128 with WAKE. The general test also covers running on old
150 DEC (@(cond_lock,r8), r2)
165 /* Initial locking failed. */
170 mov.l @(dep_mutex,r8), r0
185 /* Unlock in loop requires wakeup. */
190 mov.l @(dep_mutex,r8), r0
204 /* Unlock in loop requires wakeup. */
227 #ifdef __ASSUME_PRIVATE_FUTEX
228 mov #(FUTEX_WAKE|FUTEX_PRIVATE_FLAG), r5
240 shlr r6 /* r6 = 0x7fffffff */
249 #ifndef __ASSUME_PRIVATE_FUTEX
251 .word PRIVATE_FUTEX - TLS_PRE_TCB_SIZE
256 .long __lll_lock_wait-.Lwait5b
258 .long __lll_unlock_wake-.Lwake5b
260 .long __lll_unlock_wake-.Lwake6b
261 .size __pthread_cond_broadcast, .-__pthread_cond_broadcast
262 versioned_symbol (libpthread, __pthread_cond_broadcast, pthread_cond_broadcast,