27aa74
diff --git a/postgresql-9.1.9/src/include/storage/s_lock.h b/postgresql-9.1.9/src/include/storage/s_lock.h
27aa74
index 987fb9c..1ba718c 100644
27aa74
--- a/postgresql-9.1.9/src/include/storage/s_lock.h
27aa74
+++ b/postgresql-9.1.9/src/include/storage/s_lock.h
27aa74
@@ -296,6 +296,29 @@ tas(volatile slock_t *lock)
27aa74
 #endif	 /* __arm__ */
27aa74
 
27aa74
 
27aa74
+/*
27aa74
+ * On ARM64, we use __sync_lock_test_and_set(int *, int) if available.
27aa74
+ */
27aa74
+#if defined(__aarch64__) || defined(__aarch64)
27aa74
+#ifdef HAVE_GCC_INT_ATOMICS
27aa74
+#define HAS_TEST_AND_SET
27aa74
+
27aa74
+#define TAS(lock) tas(lock)
27aa74
+
27aa74
+typedef int slock_t;
27aa74
+
27aa74
+static __inline__ int
27aa74
+tas(volatile slock_t *lock)
27aa74
+{
27aa74
+	return __sync_lock_test_and_set(lock, 1);
27aa74
+}
27aa74
+
27aa74
+#define S_UNLOCK(lock) __sync_lock_release(lock)
27aa74
+
27aa74
+#endif	 /* HAVE_GCC_INT_ATOMICS */
27aa74
+#endif	 /* __aarch64__ */
27aa74
+
27aa74
+
27aa74
 /* S/390 and S/390x Linux (32- and 64-bit zSeries) */
27aa74
 #if defined(__s390__) || defined(__s390x__)
27aa74
 #define HAS_TEST_AND_SET