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