1 2010-07-03 Ulrich Drepper <drepper@redhat.com>
3 * tst-abstime.c (do_test): Some more cleanups
5 2010-07-02 Ulrich Drepper <drepper@redhat.com>
7 * tst-abstime.c: Correct testing and add test for sem_timedwait.
9 2010-07-01 Andreas Schwab <schwab@redhat.com>
10 Ulrich Drepper <drepper@redhat.com>
12 * Makefile (tests): Add tst-abstime.
13 * tst-abstime.c: New file.
14 * sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S
15 (__lll_timedlock_wait): Check for timestamp before the Epoch.
16 * sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
17 (__lll_timedlock_wait): Likewise.
18 * sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S
19 (__lll_robust_timedlock_wait): Likewise.
20 * sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S
21 (__pthread_cond_timedwait): Likewise.
22 * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S
23 (pthread_rwlock_timedrdlock): Likewise.
24 * sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S
25 (pthread_rwlock_timedwrlock): Likewise.
26 * sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S (sem_timedwait):
29 Index: glibc-2.12-2-gc4ccff1/nptl/Makefile
30 ===================================================================
31 --- glibc-2.12-2-gc4ccff1.orig/nptl/Makefile
32 +++ glibc-2.12-2-gc4ccff1/nptl/Makefile
33 @@ -256,6 +256,7 @@ tests = tst-typesizes \
38 tst-vfork1 tst-vfork2 tst-vfork1x tst-vfork2x \
39 tst-getpid1 tst-getpid2 tst-getpid3 \
40 tst-initializers1 $(patsubst %,tst-initializers1-%,c89 gnu89 c99 gnu99)
41 Index: glibc-2.12-2-gc4ccff1/nptl/sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S
42 ===================================================================
43 --- glibc-2.12-2-gc4ccff1.orig/nptl/sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S
44 +++ glibc-2.12-2-gc4ccff1/nptl/sysdeps/unix/sysv/linux/i386/i486/lowlevellock.S
45 @@ -188,6 +188,9 @@ __lll_timedlock_wait:
55 @@ -223,6 +226,9 @@ __lll_timedlock_wait:
59 +8: movl $ETIMEDOUT, %eax
62 # ifndef __ASSUME_FUTEX_CLOCK_REALTIME
64 /* Check for a valid timeout value. */
65 Index: glibc-2.12-2-gc4ccff1/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
66 ===================================================================
67 --- glibc-2.12-2-gc4ccff1.orig/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
68 +++ glibc-2.12-2-gc4ccff1/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S
69 @@ -169,9 +169,13 @@ __lll_timedlock_wait:
77 cfi_adjust_cfa_offset(8)
78 cfi_rel_offset(%r9, 0)
81 movl $0xffffffff, %r9d
82 LOAD_FUTEX_WAIT_ABS (%esi)
83 @@ -202,6 +206,9 @@ __lll_timedlock_wait:
87 +5: movl $ETIMEDOUT, %eax
90 # ifndef __ASSUME_FUTEX_CLOCK_REALTIME
92 /* Check for a valid timeout value. */
93 Index: glibc-2.12-2-gc4ccff1/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S
94 ===================================================================
95 --- glibc-2.12-2-gc4ccff1.orig/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S
96 +++ glibc-2.12-2-gc4ccff1/nptl/sysdeps/unix/sysv/linux/x86_64/lowlevelrobustlock.S
97 @@ -125,6 +125,9 @@ __lll_robust_timedlock_wait:
105 cfi_adjust_cfa_offset(8)
106 cfi_rel_offset(%r9, 0)
107 @@ -180,6 +183,9 @@ __lll_robust_timedlock_wait:
108 cfi_adjust_cfa_offset(-8)
111 +7: movl $ETIMEDOUT, %eax
115 # ifndef __ASSUME_FUTEX_CLOCK_REALTIME
117 Index: glibc-2.12-2-gc4ccff1/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S
118 ===================================================================
119 --- glibc-2.12-2-gc4ccff1.orig/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S
120 +++ glibc-2.12-2-gc4ccff1/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S
121 @@ -144,6 +144,10 @@ __pthread_cond_timedwait:
126 + movq $-ETIMEDOUT, %r14
129 38: movl cond_futex(%rdi), %r12d
132 Index: glibc-2.12-2-gc4ccff1/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S
133 ===================================================================
134 --- glibc-2.12-2-gc4ccff1.orig/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S
135 +++ glibc-2.12-2-gc4ccff1/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedrdlock.S
136 @@ -102,6 +102,9 @@ pthread_rwlock_timedrdlock:
141 + js 16f /* Time is already up. */
143 movl $FUTEX_PRIVATE_FLAG|FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME, %esi
144 xorl PSHARED(%r12), %esi
146 Index: glibc-2.12-2-gc4ccff1/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S
147 ===================================================================
148 --- glibc-2.12-2-gc4ccff1.orig/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S
149 +++ glibc-2.12-2-gc4ccff1/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_rwlock_timedwrlock.S
150 @@ -99,6 +99,9 @@ pthread_rwlock_timedwrlock:
155 + js 16f /* Time is already up. */
157 movl $FUTEX_PRIVATE_FLAG|FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME, %esi
158 xorl PSHARED(%r12), %esi
160 Index: glibc-2.12-2-gc4ccff1/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S
161 ===================================================================
162 --- glibc-2.12-2-gc4ccff1.orig/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S
163 +++ glibc-2.12-2-gc4ccff1/nptl/sysdeps/unix/sysv/linux/x86_64/sem_timedwait.S
164 @@ -77,6 +77,9 @@ sem_timedwait:
171 /* This push is only needed to store the sem_t pointer for the
172 exception handler. */
174 @@ -169,6 +172,19 @@ sem_timedwait:
180 + movq errno@gottpoff(%rip), %rdx
181 + movl $ETIMEDOUT, %fs:(%rdx)
183 + callq __errno_location@plt
184 + movl $ETIMEDOUT, (%rax)
191 #ifndef __ASSUME_FUTEX_CLOCK_REALTIME
194 Index: glibc-2.12-2-gc4ccff1/nptl/tst-abstime.c
195 ===================================================================
197 +++ glibc-2.12-2-gc4ccff1/nptl/tst-abstime.c
199 +/* Copyright (C) 2010 Free Software Foundation, Inc.
200 + This file is part of the GNU C Library.
201 + Contributed by Andreas Schwab <schwab@redhat.com>, 2010.
203 + The GNU C Library is free software; you can redistribute it and/or
204 + modify it under the terms of the GNU Lesser General Public
205 + License as published by the Free Software Foundation; either
206 + version 2.1 of the License, or (at your option) any later version.
208 + The GNU C Library is distributed in the hope that it will be useful,
209 + but WITHOUT ANY WARRANTY; without even the implied warranty of
210 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
211 + Lesser General Public License for more details.
213 + You should have received a copy of the GNU Lesser General Public
214 + License along with the GNU C Library; if not, write to the Free
215 + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
219 +#include <pthread.h>
220 +#include <semaphore.h>
223 +static pthread_cond_t c = PTHREAD_COND_INITIALIZER;
224 +static pthread_mutex_t m1 = PTHREAD_MUTEX_INITIALIZER;
225 +static pthread_mutex_t m2 = PTHREAD_MUTEX_INITIALIZER;
226 +static pthread_rwlock_t rw1 = PTHREAD_RWLOCK_INITIALIZER;
227 +static pthread_rwlock_t rw2 = PTHREAD_RWLOCK_INITIALIZER;
235 + struct timespec t = { -2, 0 };
237 + r = pthread_mutex_timedlock (&m1, &t);
238 + if (r != ETIMEDOUT)
240 + puts ("pthread_mutex_timedlock did not return ETIMEDOUT");
243 + r = pthread_rwlock_timedrdlock (&rw1, &t);
244 + if (r != ETIMEDOUT)
246 + puts ("pthread_rwlock_timedrdlock did not return ETIMEDOUT");
249 + r = pthread_rwlock_timedwrlock (&rw2, &t);
250 + if (r != ETIMEDOUT)
252 + puts ("pthread_rwlock_timedwrlock did not return ETIMEDOUT");
255 + return (void *) res;
263 + struct timespec t = { -2, 0 };
266 + sem_init (&sem, 0, 0);
267 + r = sem_timedwait (&sem, &t);
268 + if (r != -1 || errno != ETIMEDOUT)
270 + puts ("sem_timedwait did not fail with ETIMEDOUT");
274 + pthread_mutex_lock (&m1);
275 + pthread_rwlock_wrlock (&rw1);
276 + pthread_rwlock_rdlock (&rw2);
277 + pthread_mutex_lock (&m2);
278 + if (pthread_create (&pth, 0, th, 0) != 0)
280 + puts ("cannot create thread");
283 + r = pthread_cond_timedwait (&c, &m2, &t);
284 + if (r != ETIMEDOUT)
286 + puts ("pthread_cond_timedwait did not return ETIMEDOUT");
290 + pthread_join (pth, &thres);
291 + return res | (thres != NULL);
295 +#define TEST_FUNCTION do_test ()
296 +#include "../test-skeleton.c"