!57 [sync] PR-55: add sw_64 support

From: @openeuler-sync-bot 
Reviewed-by: @dillon_chen 
Signed-off-by: @dillon_chen
This commit is contained in:
openeuler-ci-bot 2025-03-18 05:37:35 +00:00 committed by Gitee
commit 40db556fc9
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 85 additions and 1 deletions

80
add-sw_64-support.patch Normal file
View File

@ -0,0 +1,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

View File

@ -1,6 +1,6 @@
Name: libpq
Version: 15.12
Release: 1
Release: 2
Summary: PostgreSQL client library
License: PostgreSQL
Url: http://www.postgresql.org/
@ -10,6 +10,7 @@ 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
Patch0005: add-sw_64-support.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-15.lang >>libpq-devel.lst
%_libdir/pkgconfig/libpq.pc
%changelog
* Sat Mar 15 2025 mahailiang <mahailiang@uniontech.com> - 15.12-2
- add sw_64 support
* Thu Feb 20 2025 Funda Wang <fundawang@yeah.net> - 15.12-1
- update to 15.12 to fix CVE-2025-1094