Skip to content

Commit

Permalink
Work around kernel rejecting valid absolute timestamps
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Schwab authored and Ulrich Drepper committed Jul 2, 2010
1 parent 72b6e8c commit 2983d85
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 8 deletions.
20 changes: 20 additions & 0 deletions nptl/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
2010-07-01 Andreas Schwab <schwab@redhat.com>
Ulrich Drepper <drepper@redhat.com>

* Makefile (tests): Add tst-abstime.
* tst-abstime.c: New file.
* sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S
(__lll_timedlock_wait): Check for timestamp before the Epoch.
* sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
(__lll_timedlock_wait): Likewise.
* sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S
(__lll_robust_timedlock_wait): Likewise.
* sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S
(__pthread_cond_timedwait): Likewise.
* sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S
(pthread_rwlock_timedrdlock): Likewise.
* sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S
(pthread_rwlock_timedwrlock): Likewise.
* sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S (sem_timedwait):
Likewise.

2010-07-01 Ulrich Drepper <drepper@redhat.com>

* Makefile (tst-_res1): Add tst-_res1mod1 to dependency list.
Expand Down
1 change: 1 addition & 0 deletions nptl/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ tests = tst-typesizes \
tst-sched1 \
tst-backtrace1 \
tst-oddstacklimit \
tst-abstime \
tst-vfork1 tst-vfork2 tst-vfork1x tst-vfork2x \
tst-getpid1 tst-getpid2 tst-getpid3 \
tst-initializers1 $(patsubst %,tst-initializers1-%,c89 gnu89 c99 gnu99)
Expand Down
8 changes: 7 additions & 1 deletion nptl/sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2002-2004, 2006, 2007, 2009 Free Software Foundation, Inc.
/* Copyright (C) 2002-2004,2006,2007,2009,2010 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
Expand Down Expand Up @@ -188,6 +188,9 @@ __lll_timedlock_wait:
je .Lreltmo
# endif

cmpl $0, (%edx)
js 8f

movl %ecx, %ebx
movl %esi, %ecx
movl %edx, %esi
Expand Down Expand Up @@ -223,6 +226,9 @@ __lll_timedlock_wait:
cfi_restore(%ebp)
ret

8: movl $ETIMEDOUT, %eax
jmp 7b

# ifndef __ASSUME_FUTEX_CLOCK_REALTIME
.Lreltmo:
/* Check for a valid timeout value. */
Expand Down
9 changes: 8 additions & 1 deletion nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2002-2006, 2007, 2009 Free Software Foundation, Inc.
/* Copyright (C) 2002-2006, 2007, 2009, 2010 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
Expand Down Expand Up @@ -169,9 +169,13 @@ __lll_timedlock_wait:
je .Lreltmo
# endif

cmpq $0, (%rdx)
js 5f

pushq %r9
cfi_adjust_cfa_offset(8)
cfi_rel_offset(%r9, 0)

movq %rdx, %r10
movl $0xffffffff, %r9d
LOAD_FUTEX_WAIT_ABS (%esi)
Expand Down Expand Up @@ -202,6 +206,9 @@ __lll_timedlock_wait:
cfi_restore(%r9)
retq

5: movl $ETIMEDOUT, %eax
retq

# ifndef __ASSUME_FUTEX_CLOCK_REALTIME
.Lreltmo:
/* Check for a valid timeout value. */
Expand Down
9 changes: 7 additions & 2 deletions nptl/sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2009
Free Software Foundation, Inc.
/* Copyright (C) 2002=2007, 2009, 2010 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
Expand Down Expand Up @@ -125,6 +124,9 @@ __lll_robust_timedlock_wait:
je .Lreltmo
# endif

cmpq $0, (%rdx)
js 7f

pushq %r9
cfi_adjust_cfa_offset(8)
cfi_rel_offset(%r9, 0)
Expand Down Expand Up @@ -180,6 +182,9 @@ __lll_robust_timedlock_wait:
cfi_adjust_cfa_offset(-8)
cfi_restore(%r9)

7: movl $ETIMEDOUT, %eax
retq


# ifndef __ASSUME_FUTEX_CLOCK_REALTIME
.Lreltmo:
Expand Down
6 changes: 5 additions & 1 deletion nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2002-2005, 2007, 2009 Free Software Foundation, Inc.
/* Copyright (C) 2002-2005, 2007, 2009, 2010 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
Expand Down Expand Up @@ -144,6 +144,10 @@ __pthread_cond_timedwait:
movq %r9, 24(%rsp)
movl %edx, 4(%rsp)

cmpq $0, (%r13)
movq $-ETIMEDOUT, %r14
js 36f

38: movl cond_futex(%rdi), %r12d

/* Unlock. */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2002-2005, 2007, 2009 Free Software Foundation, Inc.
/* Copyright (C) 2002-2005, 2007, 2009, 2010 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
Expand Down Expand Up @@ -102,6 +102,9 @@ pthread_rwlock_timedrdlock:
je .Lreltmo
#endif

cmpq $0, (%r13)
js 16f /* Time is already up. */

movl $FUTEX_PRIVATE_FLAG|FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME, %esi
xorl PSHARED(%r12), %esi
movq %r13, %r10
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2002, 2003, 2005, 2007, 2009 Free Software Foundation, Inc.
/* Copyright (C) 2002, 2003, 2005, 2007, 2009, 2010 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
Expand Down Expand Up @@ -99,6 +99,9 @@ pthread_rwlock_timedwrlock:
je .Lreltmo
#endif

cmpq $0, (%r13)
js 16f /* Time is already up. */

movl $FUTEX_PRIVATE_FLAG|FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME, %esi
xorl PSHARED(%r12), %esi
movq %r13, %r10
Expand Down
18 changes: 17 additions & 1 deletion nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2002, 2003, 2005, 2007, 2009 Free Software Foundation, Inc.
/* Copyright (C) 2002,2003,2005,2007,2009,2010 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
Expand Down Expand Up @@ -77,6 +77,9 @@ sem_timedwait:
je .Lreltmo
#endif

cmpq $0, (%rsi)
js 16f

/* This push is only needed to store the sem_t pointer for the
exception handler. */
pushq %rdi
Expand Down Expand Up @@ -169,6 +172,19 @@ sem_timedwait:

retq

16:
#if USE___THREAD
movq errno@gottpoff(%rip), %rdx
movl $ETIMEDOUT, %fs:(%rdx)
#else
callq __errno_location@plt
movl $ETIMEDOUT, (%rax)
#endif

orl $-1, %eax

retq

#ifndef __ASSUME_FUTEX_CLOCK_REALTIME
.Lreltmo:
pushq %r12
Expand Down

0 comments on commit 2983d85

Please sign in to comment.