[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[commits] r3065 - in /branches/eglibc-2_5/ports: ./ sysdeps/arm/nptl/ sysdeps/unix/sysv/linux/arm/nptl/bits/



Author: joseph
Date: Mon Aug  6 05:55:00 2007
New Revision: 3065

Log:
	* 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:
    branches/eglibc-2_5/ports/sysdeps/arm/nptl/pthread_spin_lock.c
    branches/eglibc-2_5/ports/sysdeps/arm/nptl/pthread_spin_trylock.c
Removed:
    branches/eglibc-2_5/ports/sysdeps/arm/nptl/pthread_spin_lock.S
    branches/eglibc-2_5/ports/sysdeps/arm/nptl/pthread_spin_trylock.S
Modified:
    branches/eglibc-2_5/ports/ChangeLog.eglibc
    branches/eglibc-2_5/ports/sysdeps/unix/sysv/linux/arm/nptl/bits/atomic.h

Modified: branches/eglibc-2_5/ports/ChangeLog.eglibc
==============================================================================
--- branches/eglibc-2_5/ports/ChangeLog.eglibc (original)
+++ branches/eglibc-2_5/ports/ChangeLog.eglibc Mon Aug  6 05:55:00 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: branches/eglibc-2_5/ports/sysdeps/arm/nptl/pthread_spin_lock.c
==============================================================================
--- branches/eglibc-2_5/ports/sysdeps/arm/nptl/pthread_spin_lock.c (added)
+++ branches/eglibc-2_5/ports/sysdeps/arm/nptl/pthread_spin_lock.c Mon Aug  6 05:55:00 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: branches/eglibc-2_5/ports/sysdeps/arm/nptl/pthread_spin_trylock.c
==============================================================================
--- branches/eglibc-2_5/ports/sysdeps/arm/nptl/pthread_spin_trylock.c (added)
+++ branches/eglibc-2_5/ports/sysdeps/arm/nptl/pthread_spin_trylock.c Mon Aug  6 05:55:00 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: branches/eglibc-2_5/ports/sysdeps/unix/sysv/linux/arm/nptl/bits/atomic.h
==============================================================================
--- branches/eglibc-2_5/ports/sysdeps/unix/sysv/linux/arm/nptl/bits/atomic.h (original)
+++ branches/eglibc-2_5/ports/sysdeps/unix/sysv/linux/arm/nptl/bits/atomic.h Mon Aug  6 05:55:00 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