Description: use gcc intrinsics rather than assembler to implement tas
Author: Alexander Sack <asac@ubuntu.com>
Author: Martin Pitt <martin.pitt@ubuntu.com>
Bug-Ubuntu: https://launchpad.net/bugs/497331
Bug-Ubuntu: https://launchpad.net/bugs/904828

Index: postgresql-9.1-9.1.2/src/include/storage/s_lock.h
===================================================================
--- postgresql-9.1-9.1.2.orig/src/include/storage/s_lock.h	2011-12-01 22:47:20.000000000 +0100
+++ postgresql-9.1-9.1.2/src/include/storage/s_lock.h	2011-12-15 21:17:32.965569760 +0100
@@ -255,21 +255,15 @@
 #if defined(__arm__) || defined(__arm)
 #define HAS_TEST_AND_SET
 
-typedef unsigned char slock_t;
+typedef unsigned int slock_t;
 
 #define TAS(lock) tas(lock)
+#define S_UNLOCK(lock) __sync_lock_release(lock)
 
 static __inline__ int
 tas(volatile slock_t *lock)
 {
-	register slock_t _res = 1;
-
-	__asm__ __volatile__(
-		"	swpb 	%0, %0, [%2]	\n"
-:		"+r"(_res), "+m"(*lock)
-:		"r"(lock)
-:		"memory");
-	return (int) _res;
+	return __sync_lock_test_and_set (lock, 1);
 }
 
 #endif	 /* __arm__ */
