1 /* Copyright (C) 2003-2014 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, see
16 <http://www.gnu.org/licenses/>. */
19 #include <shlib-compat.h>
20 #include <lowlevellock.h>
21 #include <lowlevelcond.h>
22 #include <kernel-features.h>
23 #include <pthread-pi-defines.h>
24 #include <pthread-errnos.h>
25 #include "lowlevel-atomic.h"
29 /* int pthread_cond_broadcast (pthread_cond_t *cond) */
30 .globl __pthread_cond_broadcast
31 .type __pthread_cond_broadcast, @function
34 __pthread_cond_broadcast:
36 cfi_adjust_cfa_offset (4)
37 cfi_rel_offset (r10, 0)
39 cfi_adjust_cfa_offset (4)
40 cfi_rel_offset (r9, 0)
42 cfi_adjust_cfa_offset (4)
43 cfi_rel_offset (r8, 0)
45 cfi_adjust_cfa_offset (4)
46 cfi_rel_offset (pr, 0)
49 /* Get internal lock. */
53 CMPXCHG (r3, @(cond_lock,r8), r4, r2)
55 CMPXCHG (r3, @r8, r4, r2)
59 mov.l @(total_seq+4,r8),r0
60 mov.l @(total_seq,r8),r1
61 mov.l @(wakeup_seq+4,r8), r2
66 mov.l @(wakeup_seq,r8), r2
71 /* Cause all currently waiting threads to recognize they are
73 mov.l r1, @(wakeup_seq,r8)
74 mov.l r0, @(wakeup_seq+4,r8)
75 mov.l r1, @(woken_seq,r8)
76 mov.l r0, @(woken_seq+4,r8)
77 mov.l @(broadcast_seq,r8), r2
79 mov.l r2, @(broadcast_seq,r8)
82 mov.l r10, @(cond_futex,r8)
84 /* Get the address of the mutex used. */
85 mov.l @(dep_mutex,r8), r9
89 DEC (@(cond_lock,r8), r2)
97 /* Don't use requeue for pshared condvars. */
104 /* XXX: The kernel only supports FUTEX_CMP_REQUEUE to the same
105 type of futex (private resp. shared). */
106 mov.l @(MUTEX_KIND,r9), r0
107 tst #(PI_BIT|PS_BIT), r0
110 /* Wake up all threads. */
111 #ifdef __ASSUME_PRIVATE_FUTEX
112 mov #(FUTEX_CMP_REQUEUE|FUTEX_PRIVATE_FLAG), r5
119 mov #FUTEX_CMP_REQUEUE, r0
124 shlr r7 /* r7 = 0x7fffffff */
126 # if MUTEX_FUTEX != 0
135 /* For any kind of error, which mainly is EAGAIN, we try again
136 with WAKE. The general test also covers running on old
150 cfi_adjust_cfa_offset (-4)
153 cfi_adjust_cfa_offset (-4)
156 cfi_adjust_cfa_offset (-4)
159 cfi_adjust_cfa_offset (-4)
168 DEC (@(cond_lock,r8), r2)
177 cfi_adjust_cfa_offset (-4)
180 cfi_adjust_cfa_offset (-4)
183 cfi_adjust_cfa_offset (-4)
186 cfi_adjust_cfa_offset (-4)
193 /* Initial locking failed. */
198 mov.l @(dep_mutex,r8), r0
213 /* Unlock in loop requires wakeup. */
218 mov.l @(dep_mutex,r8), r0
232 /* Unlock in loop requires wakeup. */
255 #ifdef __ASSUME_PRIVATE_FUTEX
256 mov #(FUTEX_WAKE|FUTEX_PRIVATE_FLAG), r5
268 shlr r6 /* r6 = 0x7fffffff */
278 #ifndef __ASSUME_PRIVATE_FUTEX
280 .word PRIVATE_FUTEX - TLS_PRE_TCB_SIZE
285 .long __lll_lock_wait-.Lwait5b
287 .long __lll_unlock_wake-.Lwake5b
289 .long __lll_unlock_wake-.Lwake6b
290 .size __pthread_cond_broadcast, .-__pthread_cond_broadcast
291 versioned_symbol (libpthread, __pthread_cond_broadcast, pthread_cond_broadcast,