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-errnos.h>
24 #include "lowlevel-atomic.h"
28 /* int pthread_cond_signal (pthread_cond_t *cond) */
29 .globl __pthread_cond_signal
30 .type __pthread_cond_signal, @function
33 __pthread_cond_signal:
35 cfi_adjust_cfa_offset (4)
36 cfi_rel_offset (r8, 0)
38 cfi_adjust_cfa_offset (4)
39 cfi_rel_offset (pr, 0)
42 /* Get internal lock. */
46 CMPXCHG (r3, @(cond_lock,r8), r4, r2)
48 CMPXCHG (r3, @r8, r4, r2)
52 mov.l @(total_seq+4,r8),r0
53 mov.l @(total_seq,r8),r1
54 mov.l @(wakeup_seq+4,r8), r2
59 mov.l @(wakeup_seq,r8), r2
64 /* Bump the wakeup number. */
68 mov.l @(wakeup_seq,r8),r0
69 mov.l @(wakeup_seq+4,r8),r1
72 mov.l r0,@(wakeup_seq,r8)
73 mov.l r1,@(wakeup_seq+4,r8)
74 mov.l @(cond_futex,r8),r0
76 mov.l r0,@(cond_futex,r8)
78 /* Wake up one thread. */
81 mov.l @(dep_mutex,r8), r0
84 mov #FUTEX_WAKE_OP, r5
85 #ifdef __ASSUME_PRIVATE_FUTEX
86 mov #(FUTEX_WAKE_OP|FUTEX_PRIVATE_FLAG), r5
93 mov #FUTEX_WAKE_OP, r0
107 /* For any kind of error, we try again with WAKE.
108 The general test also covers running on old kernels. */
119 cfi_adjust_cfa_offset (-4)
122 cfi_adjust_cfa_offset (-4)
128 #ifndef __ASSUME_PRIVATE_FUTEX
130 .word PRIVATE_FUTEX - TLS_PRE_TCB_SIZE
134 .long FUTEX_OP_CLEAR_WAKE_IF_GT_ONE
137 /* r5 should be either FUTEX_WAKE_OP or
138 FUTEX_WAKE_OP|FUTEX_PRIVATE_FLAG from the previous syscall. */
139 mov #(FUTEX_WAKE ^ FUTEX_WAKE_OP), r0
147 DEC (@(cond_lock,r8), r2)
155 /* Unlock in loop requires wakeup. */
160 mov.l @(dep_mutex,r8), r0
174 /* Initial locking failed. */
179 mov.l @(dep_mutex,r8), r0
196 .long __lll_lock_wait-.Lwait4b
198 .long __lll_unlock_wake-.Lwake4b
199 .size __pthread_cond_signal, .-__pthread_cond_signal
200 versioned_symbol (libpthread, __pthread_cond_signal, pthread_cond_signal,