[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[commits] r4150 - in /fsf/trunk/libc/nptl: ./ sysdeps/unix/sysv/linux/ sysdeps/unix/sysv/linux/i386/i486/ sysdeps/unix/sysv/linux/x86_64/
- To: commits@xxxxxxxxxx
- Subject: [commits] r4150 - in /fsf/trunk/libc/nptl: ./ sysdeps/unix/sysv/linux/ sysdeps/unix/sysv/linux/i386/i486/ sysdeps/unix/sysv/linux/x86_64/
- From: eglibc@xxxxxxxxxx
- Date: Sat, 10 Nov 2007 08:03:21 -0000
Author: eglibc
Date: Sat Nov 10 00:03:20 2007
New Revision: 4150
Log:
Import glibc-mainline for 2007-11-10
Modified:
fsf/trunk/libc/nptl/ChangeLog
fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S
fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/lowlevellock.c
fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
Modified: fsf/trunk/libc/nptl/ChangeLog
==============================================================================
--- fsf/trunk/libc/nptl/ChangeLog (original)
+++ fsf/trunk/libc/nptl/ChangeLog Sat Nov 10 00:03:20 2007
@@ -1,4 +1,11 @@
2007-11-08 Ulrich Drepper <drepper@xxxxxxxxxx>
+
+ [BZ #5240]
+ * sysdeps/unix/sysv/linux/lowlevellock.c (__lll_timedlock_wait):
+ If we time out, try one last time to lock the futex to avoid
+ losing a wakeup signal.
+ * sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S: Likewise.
+ * sysdeps/unix/sysv/linux/x86_64/lowlevellock.S: Likewise.
[BZ #5245]
* sysdeps/pthread/createthread.c (do_clone): Translate clone error
Modified: fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S
==============================================================================
--- fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S (original)
+++ fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S Sat Nov 10 00:03:20 2007
@@ -203,7 +203,7 @@
addl $1000000000, %edx
subl $1, %ecx
4: testl %ecx, %ecx
- js 5f /* Time is already up. */
+ js 9f /* Time is already up. */
/* Store relative timeout. */
movl %ecx, (%esp)
@@ -271,6 +271,10 @@
5: movl $ETIMEDOUT, %eax
jmp 6b
+
+9: movl $-ETIMEDOUT, %ecx
+ movl $2, %edx
+ jmp 8b
cfi_endproc
.size __lll_timedlock_wait,.-__lll_timedlock_wait
#endif
Modified: fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/lowlevellock.c
==============================================================================
--- fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/lowlevellock.c (original)
+++ fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/lowlevellock.c Sat Nov 10 00:03:20 2007
@@ -59,10 +59,10 @@
if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000)
return EINVAL;
+ struct timespec rt;
do
{
struct timeval tv;
- struct timespec rt;
/* Get the current time. */
(void) __gettimeofday (&tv, NULL);
@@ -76,18 +76,21 @@
--rt.tv_sec;
}
- /* Already timed out? */
- if (rt.tv_sec < 0)
- return ETIMEDOUT;
+ /* If timed out do not go to sleep. */
+ if (__builtin_expect (rt.tv_sec >= 0, 1))
+ {
+ /* Wait. */
+ int oldval = atomic_compare_and_exchange_val_acq (futex, 2, 1);
+ if (oldval != 0)
+ lll_futex_timed_wait (futex, 2, &rt, private);
+ }
- /* Wait. */
- int oldval = atomic_compare_and_exchange_val_acq (futex, 2, 1);
- if (oldval != 0)
- lll_futex_timed_wait (futex, 2, &rt, private);
+ if (atomic_compare_and_exchange_bool_acq (futex, 2, 0) == 0)
+ return 0;
}
- while (atomic_compare_and_exchange_bool_acq (futex, 2, 0) != 0);
+ while (rt.tv_sec >= 0);
- return 0;
+ return ETIMEDOUT;
}
Modified: fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
==============================================================================
--- fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S (original)
+++ fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S Sat Nov 10 00:03:20 2007
@@ -199,14 +199,16 @@
addq $1000000000, %rsi
decq %rdi
4: testq %rdi, %rdi
- js 5f /* Time is already up. */
+ movq $-ETIMEDOUT, %rcx
+ movl $2, %edx
+ js 8f /* Time is already up. */
/* Futex call. */
movq %rdi, (%rsp) /* Store relative timeout. */
movq %rsi, 8(%rsp)
movl $1, %eax
- movl $2, %edx
+ /* NB: $edx has been loaded early. */
LOCK
cmpxchgl %edx, (%r12)