[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[commits] r3063 - in /trunk/ports: ./ sysdeps/arm/nptl/ sysdeps/unix/sysv/linux/arm/nptl/bits/
- To: commits@xxxxxxxxxx
- Subject: [commits] r3063 - in /trunk/ports: ./ sysdeps/arm/nptl/ sysdeps/unix/sysv/linux/arm/nptl/bits/
- From: joseph@xxxxxxxxxx
- Date: Mon, 06 Aug 2007 12:52:45 -0000
Author: joseph
Date: Mon Aug 6 05:52:45 2007
New Revision: 3063
Log:
2007-08-06 Zack Weinberg <zack@xxxxxxxxxxxxxxxx>
* sysdeps/arm/nptl/pthread_spin_lock.S
* sysdeps/arm/nptl/pthread_spin_trylock.S: Delete.
* sysdeps/arm/nptl/pthread_spin_lock.c
* sysdeps/arm/nptl/pthread_spin_trylock.c: New files using <atomic.h>
primitives to take spinlocks.
* sysdeps/unix/sysv/linux/arm/nptl/bits/atomic.h: Use kernel helpers
unconditionally.
Added:
trunk/ports/sysdeps/arm/nptl/pthread_spin_lock.c
trunk/ports/sysdeps/arm/nptl/pthread_spin_trylock.c
Removed:
trunk/ports/sysdeps/arm/nptl/pthread_spin_lock.S
trunk/ports/sysdeps/arm/nptl/pthread_spin_trylock.S
Modified:
trunk/ports/ChangeLog.eglibc
trunk/ports/sysdeps/unix/sysv/linux/arm/nptl/bits/atomic.h
Modified: trunk/ports/ChangeLog.eglibc
==============================================================================
--- trunk/ports/ChangeLog.eglibc (original)
+++ trunk/ports/ChangeLog.eglibc Mon Aug 6 05:52:45 2007
@@ -1,3 +1,13 @@
+2007-08-06 Zack Weinberg <zack@xxxxxxxxxxxxxxxx>
+
+ * sysdeps/arm/nptl/pthread_spin_lock.S
+ * sysdeps/arm/nptl/pthread_spin_trylock.S: Delete.
+ * sysdeps/arm/nptl/pthread_spin_lock.c
+ * sysdeps/arm/nptl/pthread_spin_trylock.c: New files using <atomic.h>
+ primitives to take spinlocks.
+ * sysdeps/unix/sysv/linux/arm/nptl/bits/atomic.h: Use kernel helpers
+ unconditionally.
+
2007-08-06 Paul Brook <paul@xxxxxxxxxxxxxxxx>
* sysdeps/arm/dl-machine.h (elf_machine_dynamic): Add missing
Added: trunk/ports/sysdeps/arm/nptl/pthread_spin_lock.c
==============================================================================
--- trunk/ports/sysdeps/arm/nptl/pthread_spin_lock.c (added)
+++ trunk/ports/sysdeps/arm/nptl/pthread_spin_lock.c Mon Aug 6 05:52:45 2007
@@ -1,0 +1,30 @@
+/* Copyright (C) 2005, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <atomic.h>
+#include "pthreadP.h"
+
+int
+pthread_spin_lock (pthread_spinlock_t *lock)
+{
+ while (atomic_compare_and_exchange_val_acq(lock, 1, 0) != 0)
+ while (*lock != 0)
+ ;
+
+ return 0;
+}
Added: trunk/ports/sysdeps/arm/nptl/pthread_spin_trylock.c
==============================================================================
--- trunk/ports/sysdeps/arm/nptl/pthread_spin_trylock.c (added)
+++ trunk/ports/sysdeps/arm/nptl/pthread_spin_trylock.c Mon Aug 6 05:52:45 2007
@@ -1,0 +1,27 @@
+/* Copyright (C) 2005, 2007 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <atomic.h>
+#include "pthreadP.h"
+
+int
+pthread_spin_trylock (pthread_spinlock_t *lock)
+{
+ return atomic_compare_and_exchange_val_acq(lock, 1, 0) ? EBUSY : 0;
+}
Modified: trunk/ports/sysdeps/unix/sysv/linux/arm/nptl/bits/atomic.h
==============================================================================
--- trunk/ports/sysdeps/unix/sysv/linux/arm/nptl/bits/atomic.h (original)
+++ trunk/ports/sysdeps/unix/sysv/linux/arm/nptl/bits/atomic.h Mon Aug 6 05:52:45 2007
@@ -37,29 +37,6 @@
void __arm_link_error (void);
-#ifdef UP
-
-/* We require kernel assisted barriers for SMP safety, so it is only worth
- defining this on UP. */
-#define atomic_exchange_acq(mem, newvalue) \
- ({ __typeof (*mem) result; \
- if (sizeof (*mem) == 1) \
- __asm__ __volatile__ ("swpb %0, %1, [%2]" \
- : "=&r,&r" (result) \
- : "r,0" (newvalue), "r,r" (mem) : "memory"); \
- else if (sizeof (*mem) == 4) \
- __asm__ __volatile__ ("swp %0, %1, [%2]" \
- : "=&r,&r" (result) \
- : "r,0" (newvalue), "r,r" (mem) : "memory"); \
- else \
- { \
- result = 0; \
- abort (); \
- } \
- result; })
-
-#else
-
#ifdef __thumb2__
#define atomic_full_barrier() \
__asm__ __volatile__ \
@@ -74,8 +51,6 @@
"mov\tlr, pc\n\t" \
"add\tpc, ip, #(0xffff0fa0 - 0xffff0fff)" \
: : : "ip", "lr", "cc", "memory");
-#endif
-
#endif
/* Atomic compare and exchange. This sequence relies on the kernel to