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