]>
Commit | Line | Data |
---|---|---|
07c695a7 MT |
1 | commit 1ba025a9a21eda65d8c36cc0dbb51d214a3ebb1a |
2 | Author: Daniel Jacobowitz <dan@codesourcery.com> | |
3 | Date: Mon Jun 2 01:57:03 2008 +0000 | |
4 | ||
5 | 2008-06-01 Paul Brook <paul@codesourcery.com> | |
6 | Zack Weinberg <zack@codesourcery.com> | |
7 | Daniel Jacobowitz <dan@codesourcery.com> | |
8 | ||
9 | * sysdeps/arm/nptl/pthread_spin_lock.S, | |
10 | sysdeps/arm/nptl/pthread_spin_trylock.S: Delete. | |
11 | * sysdeps/arm/nptl/pthread_spin_lock.c, | |
12 | sysdeps/arm/nptl/pthread_spin_trylock.c: New files using | |
13 | atomic_compare_and_exchange_val_acq to take spinlocks. | |
14 | * sysdeps/unix/sysv/linux/arm/nptl/bits/atomic.h (lll_trylock, | |
15 | lll_cond_trylock): Use atomic_compare_and_exchange_val_acq. | |
16 | (__lll_trylock, __lll_cond_trylock): Delete. | |
17 | * sysdeps/unix/sysv/linux/arm/nptl/bits/atomic.h | |
18 | (atomic_exchange_acq): Delete. | |
19 | (atomic_full_barrier): Define. | |
20 | (__arch_compare_and_exchange_val_32_acq): Use named operands. | |
21 | * sysdeps/unix/sysv/linux/arm/eabi/configure.in: Update | |
22 | arch_minimum_kernel to 2.6.16. | |
23 | * sysdeps/unix/sysv/linux/arm/eabi/configure: Regenerated. | |
24 | ||
25 | diff --git a/sysdeps/arm/nptl/pthread_spin_lock.S b/sysdeps/arm/nptl/pthread_spin_lock.S | |
26 | deleted file mode 100644 | |
27 | index bd6adf7..0000000 | |
28 | --- a/sysdeps/arm/nptl/pthread_spin_lock.S | |
29 | +++ /dev/null | |
30 | @@ -1,31 +0,0 @@ | |
31 | -/* Copyright (C) 2005 Free Software Foundation, Inc. | |
32 | - This file is part of the GNU C Library. | |
33 | - | |
34 | - The GNU C Library is free software; you can redistribute it and/or | |
35 | - modify it under the terms of the GNU Lesser General Public | |
36 | - License as published by the Free Software Foundation; either | |
37 | - version 2.1 of the License, or (at your option) any later version. | |
38 | - | |
39 | - The GNU C Library is distributed in the hope that it will be useful, | |
40 | - but WITHOUT ANY WARRANTY; without even the implied warranty of | |
41 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
42 | - Lesser General Public License for more details. | |
43 | - | |
44 | - You should have received a copy of the GNU Lesser General Public | |
45 | - License along with the GNU C Library; if not, write to the Free | |
46 | - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | |
47 | - 02111-1307 USA. */ | |
48 | - | |
49 | -#include <sysdep.h> | |
50 | - | |
51 | - .text | |
52 | - .align 4 | |
53 | - | |
54 | -ENTRY (pthread_spin_lock) | |
55 | - mov r1, #1 | |
56 | -1: swp r2, r1, [r0] | |
57 | - teq r2, #0 | |
58 | - bne 1b | |
59 | - mov r0, #0 | |
60 | - PSEUDO_RET_NOERRNO | |
61 | -END (pthread_spin_lock) | |
62 | diff --git a/sysdeps/arm/nptl/pthread_spin_lock.c b/sysdeps/arm/nptl/pthread_spin_lock.c | |
63 | new file mode 100644 | |
64 | index 0000000..1217b89 | |
65 | --- /dev/null | |
66 | +++ b/sysdeps/arm/nptl/pthread_spin_lock.c | |
67 | @@ -0,0 +1,30 @@ | |
68 | +/* Copyright (C) 2008 Free Software Foundation, Inc. | |
69 | + This file is part of the GNU C Library. | |
70 | + | |
71 | + The GNU C Library is free software; you can redistribute it and/or | |
72 | + modify it under the terms of the GNU Lesser General Public | |
73 | + License as published by the Free Software Foundation; either | |
74 | + version 2.1 of the License, or (at your option) any later version. | |
75 | + | |
76 | + The GNU C Library is distributed in the hope that it will be useful, | |
77 | + but WITHOUT ANY WARRANTY; without even the implied warranty of | |
78 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
79 | + Lesser General Public License for more details. | |
80 | + | |
81 | + You should have received a copy of the GNU Lesser General Public | |
82 | + License along with the GNU C Library; if not, write to the Free | |
83 | + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | |
84 | + 02111-1307 USA. */ | |
85 | + | |
86 | +#include <atomic.h> | |
87 | +#include "pthreadP.h" | |
88 | + | |
89 | +int | |
90 | +pthread_spin_lock (pthread_spinlock_t *lock) | |
91 | +{ | |
92 | + while (atomic_compare_and_exchange_val_acq (lock, 1, 0) != 0) | |
93 | + while (*lock != 0) | |
94 | + ; | |
95 | + | |
96 | + return 0; | |
97 | +} | |
98 | diff --git a/sysdeps/arm/nptl/pthread_spin_trylock.S b/sysdeps/arm/nptl/pthread_spin_trylock.S | |
99 | deleted file mode 100644 | |
100 | index 8593150..0000000 | |
101 | --- a/sysdeps/arm/nptl/pthread_spin_trylock.S | |
102 | +++ /dev/null | |
103 | @@ -1,34 +0,0 @@ | |
104 | -/* Copyright (C) 2005 Free Software Foundation, Inc. | |
105 | - This file is part of the GNU C Library. | |
106 | - | |
107 | - The GNU C Library is free software; you can redistribute it and/or | |
108 | - modify it under the terms of the GNU Lesser General Public | |
109 | - License as published by the Free Software Foundation; either | |
110 | - version 2.1 of the License, or (at your option) any later version. | |
111 | - | |
112 | - The GNU C Library is distributed in the hope that it will be useful, | |
113 | - but WITHOUT ANY WARRANTY; without even the implied warranty of | |
114 | - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
115 | - Lesser General Public License for more details. | |
116 | - | |
117 | - You should have received a copy of the GNU Lesser General Public | |
118 | - License along with the GNU C Library; if not, write to the Free | |
119 | - Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | |
120 | - 02111-1307 USA. */ | |
121 | - | |
122 | -#define _ERRNO_H 1 | |
123 | -#include <bits/errno.h> | |
124 | - | |
125 | -#include <sysdep.h> | |
126 | - | |
127 | - .text | |
128 | - .align 4 | |
129 | - | |
130 | -ENTRY (pthread_spin_trylock) | |
131 | - mov r1, #1 | |
132 | - swp r2, r1, [r0] | |
133 | - teq r2, #0 | |
134 | - moveq r0, #0 | |
135 | - movne r0, #EBUSY | |
136 | - PSEUDO_RET_NOERRNO | |
137 | -END (pthread_spin_trylock) | |
138 | diff --git a/sysdeps/arm/nptl/pthread_spin_trylock.c b/sysdeps/arm/nptl/pthread_spin_trylock.c | |
139 | new file mode 100644 | |
140 | index 0000000..fb998d2 | |
141 | --- /dev/null | |
142 | +++ b/sysdeps/arm/nptl/pthread_spin_trylock.c | |
143 | @@ -0,0 +1,27 @@ | |
144 | +/* Copyright (C) 2008 Free Software Foundation, Inc. | |
145 | + This file is part of the GNU C Library. | |
146 | + | |
147 | + The GNU C Library is free software; you can redistribute it and/or | |
148 | + modify it under the terms of the GNU Lesser General Public | |
149 | + License as published by the Free Software Foundation; either | |
150 | + version 2.1 of the License, or (at your option) any later version. | |
151 | + | |
152 | + The GNU C Library is distributed in the hope that it will be useful, | |
153 | + but WITHOUT ANY WARRANTY; without even the implied warranty of | |
154 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
155 | + Lesser General Public License for more details. | |
156 | + | |
157 | + You should have received a copy of the GNU Lesser General Public | |
158 | + License along with the GNU C Library; if not, write to the Free | |
159 | + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | |
160 | + 02111-1307 USA. */ | |
161 | + | |
162 | +#include <errno.h> | |
163 | +#include <atomic.h> | |
164 | +#include "pthreadP.h" | |
165 | + | |
166 | +int | |
167 | +pthread_spin_trylock (pthread_spinlock_t *lock) | |
168 | +{ | |
169 | + return atomic_compare_and_exchange_val_acq (lock, 1, 0) ? EBUSY : 0; | |
170 | +} | |
171 | diff --git a/sysdeps/unix/sysv/linux/arm/eabi/configure b/sysdeps/unix/sysv/linux/arm/eabi/configure | |
172 | index ab83048..28fb9ef 100644 | |
173 | --- a/sysdeps/unix/sysv/linux/arm/eabi/configure | |
174 | +++ b/sysdeps/unix/sysv/linux/arm/eabi/configure | |
175 | @@ -1,5 +1,5 @@ | |
176 | # This file is generated from configure.in by Autoconf. DO NOT EDIT! | |
177 | # Local configure fragment for sysdeps/unix/sysv/linux/arm/eabi. | |
178 | ||
179 | -arch_minimum_kernel=2.6.14 | |
180 | +arch_minimum_kernel=2.6.16 | |
181 | libc_cv_gcc_unwind_find_fde=no | |
182 | diff --git a/sysdeps/unix/sysv/linux/arm/eabi/configure.in b/sysdeps/unix/sysv/linux/arm/eabi/configure.in | |
183 | index 83aa8fc..d1fb7f4 100644 | |
184 | --- a/sysdeps/unix/sysv/linux/arm/eabi/configure.in | |
185 | +++ b/sysdeps/unix/sysv/linux/arm/eabi/configure.in | |
186 | @@ -1,5 +1,5 @@ | |
187 | GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory. | |
188 | # Local configure fragment for sysdeps/unix/sysv/linux/arm/eabi. | |
189 | ||
190 | -arch_minimum_kernel=2.6.14 | |
191 | +arch_minimum_kernel=2.6.16 | |
192 | libc_cv_gcc_unwind_find_fde=no | |
193 | diff --git a/sysdeps/unix/sysv/linux/arm/nptl/bits/atomic.h b/sysdeps/unix/sysv/linux/arm/nptl/bits/atomic.h | |
194 | index 71ed714..247ddd3 100644 | |
195 | --- a/sysdeps/unix/sysv/linux/arm/nptl/bits/atomic.h | |
196 | +++ b/sysdeps/unix/sysv/linux/arm/nptl/bits/atomic.h | |
197 | @@ -37,22 +37,12 @@ typedef uintmax_t uatomic_max_t; | |
198 | ||
199 | void __arm_link_error (void); | |
200 | ||
201 | -#define atomic_exchange_acq(mem, newvalue) \ | |
202 | - ({ __typeof (*mem) result; \ | |
203 | - if (sizeof (*mem) == 1) \ | |
204 | - __asm__ __volatile__ ("swpb %0, %1, [%2]" \ | |
205 | - : "=&r,&r" (result) \ | |
206 | - : "r,0" (newvalue), "r,r" (mem) : "memory"); \ | |
207 | - else if (sizeof (*mem) == 4) \ | |
208 | - __asm__ __volatile__ ("swp %0, %1, [%2]" \ | |
209 | - : "=&r,&r" (result) \ | |
210 | - : "r,0" (newvalue), "r,r" (mem) : "memory"); \ | |
211 | - else \ | |
212 | - { \ | |
213 | - result = 0; \ | |
214 | - abort (); \ | |
215 | - } \ | |
216 | - result; }) | |
217 | +#define atomic_full_barrier() \ | |
218 | + __asm__ __volatile__ \ | |
219 | + ("mov\tip, #0xffff0fff\n\t" \ | |
220 | + "mov\tlr, pc\n\t" \ | |
221 | + "add\tpc, ip, #(0xffff0fa0 - 0xffff0fff)" \ | |
222 | + : : : "ip", "lr", "cc", "memory"); | |
223 | ||
224 | /* Atomic compare and exchange. This sequence relies on the kernel to | |
225 | provide a compare and exchange operation which is atomic on the | |
226 | @@ -76,18 +66,19 @@ void __arm_link_error (void); | |
227 | register __typeof (oldval) a_tmp asm ("r3"); \ | |
228 | register __typeof (oldval) a_oldval2 asm ("r4") = (oldval); \ | |
229 | __asm__ __volatile__ \ | |
230 | - ("0:\tldr\t%1,[%3]\n\t" \ | |
231 | - "cmp\t%1, %4\n\t" \ | |
232 | + ("0:\tldr\t%[tmp],[%[ptr]]\n\t" \ | |
233 | + "cmp\t%[tmp], %[old2]\n\t" \ | |
234 | "bne\t1f\n\t" \ | |
235 | - "mov\t%0, %4\n\t" \ | |
236 | - "mov\t%1, #0xffff0fff\n\t" \ | |
237 | + "mov\t%[old], %[old2]\n\t" \ | |
238 | + "mov\t%[tmp], #0xffff0fff\n\t" \ | |
239 | "mov\tlr, pc\n\t" \ | |
240 | - "add\tpc, %1, #(0xffff0fc0 - 0xffff0fff)\n\t" \ | |
241 | + "add\tpc, %[tmp], #(0xffff0fc0 - 0xffff0fff)\n\t" \ | |
242 | "bcc\t0b\n\t" \ | |
243 | - "mov\t%1, %4\n\t" \ | |
244 | + "mov\t%[tmp], %[old2]\n\t" \ | |
245 | "1:" \ | |
246 | - : "=&r" (a_oldval), "=&r" (a_tmp) \ | |
247 | - : "r" (a_newval), "r" (a_ptr), "r" (a_oldval2) \ | |
248 | + : [old] "=&r" (a_oldval), [tmp] "=&r" (a_tmp) \ | |
249 | + : [new] "r" (a_newval), [ptr] "r" (a_ptr), \ | |
250 | + [old2] "r" (a_oldval2) \ | |
251 | : "ip", "lr", "cc", "memory"); \ | |
252 | a_tmp; }) | |
253 | ||
254 | diff --git a/sysdeps/unix/sysv/linux/arm/nptl/lowlevellock.h b/sysdeps/unix/sysv/linux/arm/nptl/lowlevellock.h | |
255 | index f48e867..889f97c 100644 | |
256 | --- a/sysdeps/unix/sysv/linux/arm/nptl/lowlevellock.h | |
257 | +++ b/sysdeps/unix/sysv/linux/arm/nptl/lowlevellock.h | |
258 | @@ -126,43 +126,11 @@ | |
259 | }) | |
260 | ||
261 | ||
262 | -static inline int __attribute__((always_inline)) | |
263 | -__lll_mutex_trylock (int *futex) | |
264 | -{ | |
265 | - int flag = 1, old; | |
266 | - asm volatile ( | |
267 | - "\tswp %[old], %[flag], [%[futex]] @ try to take the lock\n" | |
268 | - "\tcmp %[old], #1 @ check old lock value\n" | |
269 | - "\tmovlo %[flag], #0 @ if we got it, return 0\n" | |
270 | - "\tswphi %[flag], %[old], [%[futex]] @ if it was contested,\n" | |
271 | - " @ restore the contested flag,\n" | |
272 | - " @ and check whether that won." | |
273 | - : [futex] "+&r" (futex), [flag] "+&r" (flag), [old] "=&r" (old) | |
274 | - : : "memory" ); | |
275 | - | |
276 | - return flag; | |
277 | -} | |
278 | -#define lll_mutex_trylock(lock) __lll_mutex_trylock (&(lock)) | |
279 | - | |
280 | - | |
281 | -static inline int __attribute__((always_inline)) | |
282 | -__lll_mutex_cond_trylock (int *futex) | |
283 | -{ | |
284 | - int flag = 2, old; | |
285 | - asm volatile ( | |
286 | - "\tswp %[old], %[flag], [%[futex]] @ try to take the lock\n" | |
287 | - "\tcmp %[old], #1 @ check old lock value\n" | |
288 | - "\tmovlo %[flag], #0 @ if we got it, return 0\n" | |
289 | - "\tswphi %[flag], %[old], [%[futex]] @ if it was contested,\n" | |
290 | - " @ restore the contested flag,\n" | |
291 | - " @ and check whether that won." | |
292 | - : [futex] "+&r" (futex), [flag] "+&r" (flag), [old] "=&r" (old) | |
293 | - : : "memory" ); | |
294 | - | |
295 | - return flag; | |
296 | -} | |
297 | -#define lll_mutex_cond_trylock(lock) __lll_mutex_cond_trylock (&(lock)) | |
298 | +#define lll_mutex_trylock(lock) \ | |
299 | + atomic_compare_and_exchange_val_acq(&(lock), 1, 0) | |
300 | ||
301 | +#define lll_mutex_cond_trylock(lock) \ | |
302 | + atomic_compare_and_exchange_val_acq(&(lock), 2, 0) | |
303 | ||
304 | #define __lll_robust_trylock(futex, id) \ | |
305 | (atomic_compare_and_exchange_val_acq (futex, id, 0) != 0) |