From f6b960601c84d5729ca27b4d163cdf8c7662f1e3 Mon Sep 17 00:00:00 2001 From: Hailiang Date: Sat, 15 Mar 2025 14:02:31 +0800 Subject: [PATCH] add sw_64 support --- add-sw_64-support.patch | 80 +++++++++++++++++++++++++++++++++++++++++ postgresql.spec | 6 +++- 2 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 add-sw_64-support.patch diff --git a/add-sw_64-support.patch b/add-sw_64-support.patch new file mode 100644 index 0000000..caa0c66 --- /dev/null +++ b/add-sw_64-support.patch @@ -0,0 +1,80 @@ +From ed05d50b808df2bb0d11456515896a40e620389b Mon Sep 17 00:00:00 2001 +From: mahailiang +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 + diff --git a/postgresql.spec b/postgresql.spec index 94a9f30..e29c974 100644 --- a/postgresql.spec +++ b/postgresql.spec @@ -32,7 +32,7 @@ Summary: PostgreSQL client programs Name: postgresql %global majorversion 15 Version: %{majorversion}.12 -Release: 1 +Release: 2 # The PostgreSQL license is very similar to other MIT licenses, but the OSI # recognizes it as an independent license, so we do as well. @@ -77,6 +77,7 @@ Patch9: postgresql-server-pg_config.patch Patch10: postgresql-no-libecpg.patch Patch11: postgresql-datalayout-mismatch-on-s390.patch Patch16: postgresql-pgcrypto-openssl3-tests.patch +Patch17: add-sw_64-support.patch BuildRequires: gcc clang BuildRequires: perl(ExtUtils::MakeMaker) glibc-devel bison flex gawk @@ -1295,6 +1296,9 @@ make -C postgresql-setup-%{setup_version} check %changelog +* Sat Mar 15 2025 mahailiang - 15.12-2 +- add sw_64 support + * Thu Feb 20 2025 Funda Wang - 15.12-1 - update to 15.12 -- Gitee