1 commit 1ba025a9a21eda65d8c36cc0dbb51d214a3ebb1a
2 Author: Daniel Jacobowitz <dan@codesourcery.com>
3 Date: Mon Jun 2 01:57:03 2008 +0000
5 2008-06-01 Paul Brook <paul@codesourcery.com>
6 Zack Weinberg <zack@codesourcery.com>
7 Daniel Jacobowitz <dan@codesourcery.com>
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.
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
31 -/* Copyright (C) 2005 Free Software Foundation, Inc.
32 - This file is part of the GNU C Library.
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.
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.
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
54 -ENTRY (pthread_spin_lock)
61 -END (pthread_spin_lock)
62 diff --git a/sysdeps/arm/nptl/pthread_spin_lock.c b/sysdeps/arm/nptl/pthread_spin_lock.c
64 index 0000000..1217b89
66 +++ b/sysdeps/arm/nptl/pthread_spin_lock.c
68 +/* Copyright (C) 2008 Free Software Foundation, Inc.
69 + This file is part of the GNU C Library.
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.
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.
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
87 +#include "pthreadP.h"
90 +pthread_spin_lock (pthread_spinlock_t *lock)
92 + while (atomic_compare_and_exchange_val_acq (lock, 1, 0) != 0)
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
104 -/* Copyright (C) 2005 Free Software Foundation, Inc.
105 - This file is part of the GNU C Library.
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.
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.
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
123 -#include <bits/errno.h>
130 -ENTRY (pthread_spin_trylock)
137 -END (pthread_spin_trylock)
138 diff --git a/sysdeps/arm/nptl/pthread_spin_trylock.c b/sysdeps/arm/nptl/pthread_spin_trylock.c
140 index 0000000..fb998d2
142 +++ b/sysdeps/arm/nptl/pthread_spin_trylock.c
144 +/* Copyright (C) 2008 Free Software Foundation, Inc.
145 + This file is part of the GNU C Library.
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.
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.
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
164 +#include "pthreadP.h"
167 +pthread_spin_trylock (pthread_spinlock_t *lock)
169 + return atomic_compare_and_exchange_val_acq (lock, 1, 0) ? EBUSY : 0;
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
176 # This file is generated from configure.in by Autoconf. DO NOT EDIT!
177 # Local configure fragment for sysdeps/unix/sysv/linux/arm/eabi.
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
187 GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
188 # Local configure fragment for sysdeps/unix/sysv/linux/arm/eabi.
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;
199 void __arm_link_error (void);
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"); \
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");
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" \
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" \
240 - "add\tpc, %1, #(0xffff0fc0 - 0xffff0fff)\n\t" \
241 + "add\tpc, %[tmp], #(0xffff0fc0 - 0xffff0fff)\n\t" \
243 - "mov\t%1, %4\n\t" \
244 + "mov\t%[tmp], %[old2]\n\t" \
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"); \
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 @@
262 -static inline int __attribute__((always_inline))
263 -__lll_mutex_trylock (int *futex)
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)
278 -#define lll_mutex_trylock(lock) __lll_mutex_trylock (&(lock))
281 -static inline int __attribute__((always_inline))
282 -__lll_mutex_cond_trylock (int *futex)
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)
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)
301 +#define lll_mutex_cond_trylock(lock) \
302 + atomic_compare_and_exchange_val_acq(&(lock), 2, 0)
304 #define __lll_robust_trylock(futex, id) \
305 (atomic_compare_and_exchange_val_acq (futex, id, 0) != 0)