From ccfb9fdce855fd1d1a819a4ce3ed59765217f3c5 Mon Sep 17 00:00:00 2001 From: panchenbo Date: Mon, 25 Sep 2023 13:56:15 +0800 Subject: [PATCH] add sw_64 loongarch64 support --- ...-support-not-upstream-modified-files.patch | 0 ...-support-not-upstream-modified-files.patch | 73 +++++++++++++++++++ libpq.spec | 8 +- 3 files changed, 79 insertions(+), 2 deletions(-) rename add-loongarch-support.patch => 1000-add-loongarch64-support-not-upstream-modified-files.patch (100%) create mode 100644 1001-add-sw_64-support-not-upstream-modified-files.patch diff --git a/add-loongarch-support.patch b/1000-add-loongarch64-support-not-upstream-modified-files.patch similarity index 100% rename from add-loongarch-support.patch rename to 1000-add-loongarch64-support-not-upstream-modified-files.patch diff --git a/1001-add-sw_64-support-not-upstream-modified-files.patch b/1001-add-sw_64-support-not-upstream-modified-files.patch new file mode 100644 index 0000000..b805b17 --- /dev/null +++ b/1001-add-sw_64-support-not-upstream-modified-files.patch @@ -0,0 +1,73 @@ +diff --git a/contrib/pgcrypto/crypt-blowfish.c b/contrib/pgcrypto/crypt-blowfish.c +index a663852..626e917 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(__sw_64__) || defined(__hppa__) + #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 86e0e84..c2805a5 100644 +--- a/src/include/storage/s_lock.h ++++ b/src/include/storage/s_lock.h +@@ -131,6 +131,55 @@ + *---------- + */ + ++#if defined(__sw_64) || defined(__sw_64__) /* sw_64 */ ++/* ++ * Correct multi-processor locking methods are explained in section 5.5.3 ++ * of the sw_64 AXP Architecture Handbook, which at this writing can be ++ * found at ftp://ftp.netbsd.org/pub/NetBSD/misc/dec-docs/index.html. ++ * For gcc we implement the handbook's code directly with inline assembler. ++ */ ++#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__ */ ++ + + #ifdef __i386__ /* 32-bit i386 */ + #define HAS_TEST_AND_SET diff --git a/libpq.spec b/libpq.spec index 4ca74d1..f343258 100644 --- a/libpq.spec +++ b/libpq.spec @@ -1,6 +1,6 @@ Name: libpq Version: 13.12 -Release: 1 +Release: 2 Summary: PostgreSQL client library License: PostgreSQL Url: http://www.postgresql.org/ @@ -9,7 +9,8 @@ Source0: https://ftp.postgresql.org/pub/source/v%{version}/postgresql-%{version} Patch0001: libpq-10.3-rpm-pgsql.patch Patch0002: libpq-10.3-var-run-socket.patch Patch0003: libpq-12.1-symbol-versioning.patch -Patch0004: add-loongarch-support.patch +Patch1000: 1000-add-loongarch64-support-not-upstream-modified-files.patch +Patch1001: 1001-add-sw_64-support-not-upstream-modified-files.patch BuildRequires: gcc glibc-devel bison flex gawk zlib-devel openssl-devel BuildRequires: krb5-devel openldap-devel gettext multilib-rpm-config @@ -80,6 +81,9 @@ cat pg_config-13.lang >>libpq-devel.lst %_libdir/pkgconfig/libpq.pc %changelog +* Mon Sep 25 2023 panchenbo - 13.12-2 +- add loongarch64 sw_64 support + * Thu Aug 31 2023 ZhengZhenyu - 13.12-1 - aupgrade libpq to 13.12,fix CVE-2023-2455, CVE-2023-2454, CVE-2023-39417, CVE-2023-39418, CVE-2020-21469 -- Gitee