1 /* Copyright (C) 2003, 2004, 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-errnos.h>
25 #include "lowlevel-atomic.h"
29 /* int pthread_cond_signal (pthread_cond_t *cond) */
30 .globl __pthread_cond_signal
31 .type __pthread_cond_signal, @function
33 __pthread_cond_signal:
38 /* Get internal lock. */
42 CMPXCHG (r3, @(cond_lock,r8), r4, r2)
44 CMPXCHG (r3, @r8, r4, r2)
48 mov.l @(total_seq+4,r8),r0
49 mov.l @(total_seq,r8),r1
50 mov.l @(wakeup_seq+4,r8), r2
55 mov.l @(wakeup_seq,r8), r2
60 /* Bump the wakeup number. */
64 mov.l @(wakeup_seq,r8),r0
65 mov.l @(wakeup_seq+4,r8),r1
68 mov.l r0,@(wakeup_seq,r8)
69 mov.l r1,@(wakeup_seq+4,r8)
70 mov.l @(cond_futex,r8),r0
72 mov.l r0,@(cond_futex,r8)
74 /* Wake up one thread. */
77 mov.l @(dep_mutex,r8), r0
80 mov #FUTEX_WAKE_OP, r5
81 #ifdef __ASSUME_PRIVATE_FUTEX
82 mov #(FUTEX_WAKE_OP|FUTEX_PRIVATE_FLAG), r5
89 mov #FUTEX_WAKE_OP, r0
103 /* For any kind of error, we try again with WAKE.
104 The general test also covers running on old kernels. */
118 #ifndef __ASSUME_PRIVATE_FUTEX
120 .word PRIVATE_FUTEX - TLS_PRE_TCB_SIZE
124 .long FUTEX_OP_CLEAR_WAKE_IF_GT_ONE
127 /* r5 should be either FUTEX_WAKE_OP or
128 FUTEX_WAKE_OP|FUTEX_PRIVATE_FLAG from the previous syscall. */
129 mov #(FUTEX_WAKE ^ FUTEX_WAKE_OP), r0
137 DEC (@(cond_lock,r8), r2)
145 /* Unlock in loop requires wakeup. */
150 mov.l @(dep_mutex,r8), r0
164 /* Initial locking failed. */
169 mov.l @(dep_mutex,r8), r0
185 .long __lll_lock_wait-.Lwait4b
187 .long __lll_unlock_wake-.Lwake4b
188 .size __pthread_cond_signal, .-__pthread_cond_signal
189 versioned_symbol (libpthread, __pthread_cond_signal, pthread_cond_signal,