1 /* Copyright (C) 2002, 2003, 2004, 2005, 2007 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21 #include <shlib-compat.h>
22 #include <lowlevellock.h>
23 #include <lowlevelcond.h>
24 #include <kernel-features.h>
25 #include <pthread-errnos.h>
30 /* int pthread_cond_signal (pthread_cond_t *cond) */
31 .globl __pthread_cond_signal
32 .type __pthread_cond_signal, @function
34 __pthread_cond_signal:
41 /* Get internal lock. */
48 cmpxchgl %edx, cond_lock(%edi)
52 2: leal cond_futex(%edi), %ebx
53 movl total_seq+4(%edi), %eax
54 movl total_seq(%edi), %ecx
55 cmpl wakeup_seq+4(%edi), %eax
57 /* Must use leal to preserve the flags. */
58 leal cond_lock(%edi), %edi
62 cmpl wakeup_seq-cond_futex(%ebx), %ecx
65 /* Bump the wakeup number. */
66 3: addl $1, wakeup_seq-cond_futex(%ebx)
67 adcl $0, wakeup_seq-cond_futex+4(%ebx)
70 /* Wake up one thread. */
73 #if FUTEX_PRIVATE_FLAG > 255
76 cmpl $-1, dep_mutex-cond_futex(%ebx)
79 #ifdef __ASSUME_PRIVATE_FUTEX
80 andl $FUTEX_PRIVATE_FLAG, %ecx
82 andl %gs:PRIVATE_FUTEX, %ecx
84 addl $FUTEX_WAKE_OP, %ecx
88 movl $FUTEX_OP_CLEAR_WAKE_IF_GT_ONE, %ebp
89 /* FIXME: Until Ingo fixes 4G/4G vDSO, 6 arg syscalls are broken for
96 /* For any kind of error, we try again with WAKE.
97 The general test also covers running on old kernels. */
106 7: /* %ecx should be either FUTEX_WAKE_OP or
107 FUTEX_WAKE_OP|FUTEX_PRIVATE_FLAG from the previous syscall. */
108 xorl $(FUTEX_WAKE ^ FUTEX_WAKE_OP), %ecx
109 movl $SYS_futex, %eax
110 /* %edx should be 1 already from $FUTEX_WAKE_OP syscall.
114 /* Unlock. Note that at this point %edi always points to
120 /* Unlock in loop requires wakeup. */
122 #if (LLL_SHARED-LLL_PRIVATE) > 255
125 cmpl $-1, dep_mutex-cond_futex(%ebx)
128 andl $(LLL_SHARED-LLL_PRIVATE), %ecx
130 addl $LLL_PRIVATE, %ecx
132 call __lll_unlock_wake
135 /* Initial locking failed. */
140 leal cond_lock(%edi), %edx
142 #if (LLL_SHARED-LLL_PRIVATE) > 255
145 cmpl $-1, dep_mutex(%edi)
148 andl $(LLL_SHARED-LLL_PRIVATE), %ecx
150 addl $LLL_PRIVATE, %ecx
155 .size __pthread_cond_signal, .-__pthread_cond_signal
156 versioned_symbol (libpthread, __pthread_cond_signal, pthread_cond_signal,