!26 add loongarch64 and sw_64 support

From: @panchenbo 
Reviewed-by: @dillon_chen 
Signed-off-by: @dillon_chen
This commit is contained in:
openeuler-ci-bot 2023-09-27 02:40:24 +00:00 committed by Gitee
commit 722232f62c
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 79 additions and 2 deletions

View File

@ -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

View File

@ -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 <panchenbo@kylinsec.com.cn> - 13.12-2
- add loongarch64 sw_64 support
* Thu Aug 31 2023 ZhengZhenyu <zhengzhenyu@openeuler.sh> - 13.12-1
- aupgrade libpq to 13.12,fix CVE-2023-2455, CVE-2023-2454, CVE-2023-39417, CVE-2023-39418, CVE-2020-21469