81 lines
2.5 KiB
Diff
81 lines
2.5 KiB
Diff
From ed05d50b808df2bb0d11456515896a40e620389b Mon Sep 17 00:00:00 2001
|
|
From: mahailiang <mahailiang@uniontech.com>
|
|
Date: Sat, 15 Mar 2025 11:46:26 +0800
|
|
Subject: [PATCH] add sw_64 support
|
|
|
|
---
|
|
contrib/pgcrypto/crypt-blowfish.c | 2 +-
|
|
src/include/storage/s_lock.h | 43 +++++++++++++++++++++++++++++++
|
|
2 files changed, 44 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/contrib/pgcrypto/crypt-blowfish.c b/contrib/pgcrypto/crypt-blowfish.c
|
|
index a663852..e6d72b2 100644
|
|
--- a/contrib/pgcrypto/crypt-blowfish.c
|
|
+++ b/contrib/pgcrypto/crypt-blowfish.c
|
|
@@ -41,7 +41,7 @@
|
|
#ifdef __i386__
|
|
#define BF_ASM 0 /* 1 */
|
|
#define BF_SCALE 1
|
|
-#elif defined(__x86_64__) || defined(__alpha__) || defined(__hppa__)
|
|
+#elif defined(__x86_64__) || defined(__alpha__) || defined(__hppa__) || defined(__sw_64__)
|
|
#define BF_ASM 0
|
|
#define BF_SCALE 1
|
|
#else
|
|
diff --git a/src/include/storage/s_lock.h b/src/include/storage/s_lock.h
|
|
index 1ada0a8..3afd20e 100644
|
|
--- a/src/include/storage/s_lock.h
|
|
+++ b/src/include/storage/s_lock.h
|
|
@@ -771,6 +771,49 @@ tas(volatile slock_t *lock)
|
|
|
|
#endif /* __sh__ */
|
|
|
|
+#if defined(__sw_64) || defined(__sw_64__) /* sw_64 */
|
|
+#define HAS_TEST_AND_SET
|
|
+
|
|
+typedef unsigned long slock_t;
|
|
+
|
|
+#define TAS(lock) tas(lock)
|
|
+
|
|
+static __inline__ int
|
|
+tas(volatile slock_t *lock)
|
|
+{
|
|
+ register slock_t _res;
|
|
+ unsigned long tmp;
|
|
+ __asm__ __volatile__(
|
|
+ " ldl $0, %1 \n"
|
|
+ " bne $0, 2f \n"
|
|
+ " ldi %2, %1\n"
|
|
+ " lldl %0, 0(%2) \n"
|
|
+ " mov 1, $0 \n"
|
|
+ " wr_f $0 \n"
|
|
+ " memb \n"
|
|
+ " lstl $0, 0(%2) \n"
|
|
+ " rd_f $0 \n"
|
|
+ " bne %0, 2f \n"
|
|
+ " beq $0, 2f \n"
|
|
+ " memb \n"
|
|
+ " br 3f \n"
|
|
+ "2: mov 1, %0 \n"
|
|
+ "3: \n"
|
|
+: "=&r"(_res), "+m"(*lock),"=r" (tmp)
|
|
+:
|
|
+: "memory", "0");
|
|
+ return (int) _res;
|
|
+}
|
|
+
|
|
+#define S_UNLOCK(lock) \
|
|
+do \
|
|
+{\
|
|
+ __asm__ __volatile__ (" memb \n"); \
|
|
+ *((volatile slock_t *) (lock)) = 0; \
|
|
+} while (0)
|
|
+
|
|
+#endif /* __sw_64 || __sw_64__ */
|
|
+
|
|
|
|
/* These live in s_lock.c, but only for gcc */
|
|
|
|
--
|
|
2.43.5
|
|
|