]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/blob - src/patches/glibc/glibc-rh580498.patch
Merge remote-tracking branch 'origin/next' into thirteen
[people/teissler/ipfire-2.x.git] / src / patches / glibc / glibc-rh580498.patch
1 2010-07-03 Ulrich Drepper <drepper@redhat.com>
2
3 * tst-abstime.c (do_test): Some more cleanups
4
5 2010-07-02 Ulrich Drepper <drepper@redhat.com>
6
7 * tst-abstime.c: Correct testing and add test for sem_timedwait.
8
9 2010-07-01 Andreas Schwab <schwab@redhat.com>
10 Ulrich Drepper <drepper@redhat.com>
11
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):
27 Likewise.
28
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 \
34 tst-sched1 \
35 tst-backtrace1 \
36 tst-oddstacklimit \
37 + tst-abstime \
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:
46 je .Lreltmo
47 # endif
48
49 + cmpl $0, (%edx)
50 + js 8f
51 +
52 movl %ecx, %ebx
53 movl %esi, %ecx
54 movl %edx, %esi
55 @@ -223,6 +226,9 @@ __lll_timedlock_wait:
56 cfi_restore(%ebp)
57 ret
58
59 +8: movl $ETIMEDOUT, %eax
60 + jmp 7b
61 +
62 # ifndef __ASSUME_FUTEX_CLOCK_REALTIME
63 .Lreltmo:
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:
70 je .Lreltmo
71 # endif
72
73 + cmpq $0, (%rdx)
74 + js 5f
75 +
76 pushq %r9
77 cfi_adjust_cfa_offset(8)
78 cfi_rel_offset(%r9, 0)
79 +
80 movq %rdx, %r10
81 movl $0xffffffff, %r9d
82 LOAD_FUTEX_WAIT_ABS (%esi)
83 @@ -202,6 +206,9 @@ __lll_timedlock_wait:
84 cfi_restore(%r9)
85 retq
86
87 +5: movl $ETIMEDOUT, %eax
88 + retq
89 +
90 # ifndef __ASSUME_FUTEX_CLOCK_REALTIME
91 .Lreltmo:
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:
98 je .Lreltmo
99 # endif
100
101 + cmpq $0, (%rdx)
102 + js 7f
103 +
104 pushq %r9
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)
109 cfi_restore(%r9)
110
111 +7: movl $ETIMEDOUT, %eax
112 + retq
113 +
114
115 # ifndef __ASSUME_FUTEX_CLOCK_REALTIME
116 .Lreltmo:
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:
122 movq %r9, 24(%rsp)
123 movl %edx, 4(%rsp)
124
125 + cmpq $0, (%r13)
126 + movq $-ETIMEDOUT, %r14
127 + js 36f
128 +
129 38: movl cond_futex(%rdi), %r12d
130
131 /* Unlock. */
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:
137 je .Lreltmo
138 #endif
139
140 + cmpq $0, (%r13)
141 + js 16f /* Time is already up. */
142 +
143 movl $FUTEX_PRIVATE_FLAG|FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME, %esi
144 xorl PSHARED(%r12), %esi
145 movq %r13, %r10
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:
151 je .Lreltmo
152 #endif
153
154 + cmpq $0, (%r13)
155 + js 16f /* Time is already up. */
156 +
157 movl $FUTEX_PRIVATE_FLAG|FUTEX_WAIT_BITSET|FUTEX_CLOCK_REALTIME, %esi
158 xorl PSHARED(%r12), %esi
159 movq %r13, %r10
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:
165 je .Lreltmo
166 #endif
167
168 + cmpq $0, (%rsi)
169 + js 16f
170 +
171 /* This push is only needed to store the sem_t pointer for the
172 exception handler. */
173 pushq %rdi
174 @@ -169,6 +172,19 @@ sem_timedwait:
175
176 retq
177
178 +16:
179 +#if USE___THREAD
180 + movq errno@gottpoff(%rip), %rdx
181 + movl $ETIMEDOUT, %fs:(%rdx)
182 +#else
183 + callq __errno_location@plt
184 + movl $ETIMEDOUT, (%rax)
185 +#endif
186 +
187 + orl $-1, %eax
188 +
189 + retq
190 +
191 #ifndef __ASSUME_FUTEX_CLOCK_REALTIME
192 .Lreltmo:
193 pushq %r12
194 Index: glibc-2.12-2-gc4ccff1/nptl/tst-abstime.c
195 ===================================================================
196 --- /dev/null
197 +++ glibc-2.12-2-gc4ccff1/nptl/tst-abstime.c
198 @@ -0,0 +1,98 @@
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.
202 +
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.
207 +
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.
212 +
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
216 + 02111-1307 USA. */
217 +
218 +#include <errno.h>
219 +#include <pthread.h>
220 +#include <semaphore.h>
221 +#include <stdio.h>
222 +
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;
228 +static sem_t sem;
229 +
230 +static void *
231 +th (void *arg)
232 +{
233 + long int res = 0;
234 + int r;
235 + struct timespec t = { -2, 0 };
236 +
237 + r = pthread_mutex_timedlock (&m1, &t);
238 + if (r != ETIMEDOUT)
239 + {
240 + puts ("pthread_mutex_timedlock did not return ETIMEDOUT");
241 + res = 1;
242 + }
243 + r = pthread_rwlock_timedrdlock (&rw1, &t);
244 + if (r != ETIMEDOUT)
245 + {
246 + puts ("pthread_rwlock_timedrdlock did not return ETIMEDOUT");
247 + res = 1;
248 + }
249 + r = pthread_rwlock_timedwrlock (&rw2, &t);
250 + if (r != ETIMEDOUT)
251 + {
252 + puts ("pthread_rwlock_timedwrlock did not return ETIMEDOUT");
253 + res = 1;
254 + }
255 + return (void *) res;
256 +}
257 +
258 +static int
259 +do_test (void)
260 +{
261 + int res = 0;
262 + int r;
263 + struct timespec t = { -2, 0 };
264 + pthread_t pth;
265 +
266 + sem_init (&sem, 0, 0);
267 + r = sem_timedwait (&sem, &t);
268 + if (r != -1 || errno != ETIMEDOUT)
269 + {
270 + puts ("sem_timedwait did not fail with ETIMEDOUT");
271 + res = 1;
272 + }
273 +
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)
279 + {
280 + puts ("cannot create thread");
281 + return 1;
282 + }
283 + r = pthread_cond_timedwait (&c, &m2, &t);
284 + if (r != ETIMEDOUT)
285 + {
286 + puts ("pthread_cond_timedwait did not return ETIMEDOUT");
287 + res = 1;
288 + }
289 + void *thres;
290 + pthread_join (pth, &thres);
291 + return res | (thres != NULL);
292 +}
293 +
294 +
295 +#define TEST_FUNCTION do_test ()
296 +#include "../test-skeleton.c"