summaryrefslogtreecommitdiff
path: root/add-sw_64-support.patch
blob: caa0c666fd12ebac2898c8a7d3aa1e4b840a01ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
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