add loongarch support

Signed-off-by: Jingyun Hua <huajingyun@loongson.cn>
This commit is contained in:
Jingyun Hua 2022-12-01 07:03:06 +00:00
parent 1a44794725
commit 901df5e129
2 changed files with 55 additions and 1 deletions

View File

@ -0,0 +1,50 @@
diff --git a/src/include/storage/s_lock.h b/src/include/storage/s_lock.h
index 6b368a5..86e0e84 100644
--- a/src/include/storage/s_lock.h
+++ b/src/include/storage/s_lock.h
@@ -696,6 +696,45 @@ do \
#endif /* __mips__ && !__sgi */
+#if defined(__loongarch__) /* loongarch */
+#define HAS_TEST_AND_SET
+
+typedef unsigned int slock_t;
+
+#define TAS(lock) tas(lock)
+
+static __inline__ int
+tas(volatile slock_t *lock)
+{
+ register volatile slock_t *_l = lock;
+ register int _res;
+ register int _tmp;
+
+ __asm__ __volatile__(
+ " ll.w %0, %2 \n"
+ " ori %1, %0, 1 \n"
+ " sc.w %1, %2 \n"
+ " xori %1, %1, 1 \n"
+ " or %0, %0, %1 \n"
+ " dbar 0 \n"
+: "=&r" (_res), "=&r" (_tmp), "+R" (*_l)
+: /* no inputs */
+: "memory");
+ return _res;
+}
+
+#define S_UNLOCK(lock) \
+do \
+{ \
+ __asm__ __volatile__( \
+ " dbar 0 \n" \
+: /* no outputs */ \
+: /* no inputs */ \
+: "memory"); \
+ *((volatile slock_t *) (lock)) = 0; \
+} while (0)
+#endif /* __loongarch__ */
+
#if defined(__m32r__) && defined(HAVE_SYS_TAS_H) /* Renesas' M32R */
#define HAS_TEST_AND_SET

View File

@ -1,6 +1,6 @@
Name: libpq Name: libpq
Version: 13.7 Version: 13.7
Release: 1 Release: 2
Summary: PostgreSQL client library Summary: PostgreSQL client library
License: PostgreSQL License: PostgreSQL
Url: http://www.postgresql.org/ Url: http://www.postgresql.org/
@ -9,6 +9,7 @@ Source0: https://ftp.postgresql.org/pub/source/v%{version}/postgresql-%{version}
Patch0001: libpq-10.3-rpm-pgsql.patch Patch0001: libpq-10.3-rpm-pgsql.patch
Patch0002: libpq-10.3-var-run-socket.patch Patch0002: libpq-10.3-var-run-socket.patch
Patch0003: libpq-12.1-symbol-versioning.patch Patch0003: libpq-12.1-symbol-versioning.patch
Patch0004: add-loongarch-support.patch
BuildRequires: gcc glibc-devel bison flex gawk zlib-devel openssl-devel BuildRequires: gcc glibc-devel bison flex gawk zlib-devel openssl-devel
BuildRequires: krb5-devel openldap-devel gettext multilib-rpm-config BuildRequires: krb5-devel openldap-devel gettext multilib-rpm-config
@ -79,6 +80,9 @@ cat pg_config-13.lang >>libpq-devel.lst
%_libdir/pkgconfig/libpq.pc %_libdir/pkgconfig/libpq.pc
%changelog %changelog
* Thu Dec 1 2022 huajingyun <huajingyun@loongson.cn> - 13.7-2
- add loongarch support
* Mon Jun 13 2022 duyiwei <duyiwei@kylinos.cn> - 13.7-1 * Mon Jun 13 2022 duyiwei <duyiwei@kylinos.cn> - 13.7-1
- upgrade libpq to 13.7,fix CVE-2021-32027,CVE-2022-1552 - upgrade libpq to 13.7,fix CVE-2021-32027,CVE-2022-1552