postgresql: add support for atomic operations in aarch64

Version: 9.2.4-2
Resolves: #970661
This commit is contained in:
Pavel Raiskup 2013-06-05 09:34:58 +02:00
parent b6b61d6de7
commit 30d053b7a5
2 changed files with 61 additions and 2 deletions

View File

@ -0,0 +1,52 @@
From: Tom Lane <tgl@sss.pgh.pa.us>
Date: Tue, 4 Jun 2013 19:42:02 +0000 (-0400)
Subject: Add ARM64 (aarch64) support to s_lock.h.
X-Git-Url: http://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff_plain;h=612ecf311bf253cdb0c54252854c5298aa668203
Add ARM64 (aarch64) support to s_lock.h.
Use the same gcc atomic functions as we do on newer ARM chips.
(Basically this is a copy and paste of the __arm__ code block,
but omitting the SWPB option since that definitely won't work.)
Back-patch to 9.2. The patch would work further back, but we'd also
need to update config.guess/config.sub in older branches to make them
build out-of-the-box, and there hasn't been demand for it.
Mark Salter
---
diff --git a/src/include/storage/s_lock.h b/src/include/storage/s_lock.h
index d4a783f..29124b1 100644
--- a/src/include/storage/s_lock.h
+++ b/src/include/storage/s_lock.h
@@ -335,6 +335,29 @@ tas(volatile slock_t *lock)
#endif /* __arm__ */
+/*
+ * On ARM64, we use __sync_lock_test_and_set(int *, int) if available.
+ */
+#if defined(__aarch64__) || defined(__aarch64)
+#ifdef HAVE_GCC_INT_ATOMICS
+#define HAS_TEST_AND_SET
+
+#define TAS(lock) tas(lock)
+
+typedef int slock_t;
+
+static __inline__ int
+tas(volatile slock_t *lock)
+{
+ return __sync_lock_test_and_set(lock, 1);
+}
+
+#define S_UNLOCK(lock) __sync_lock_release(lock)
+
+#endif /* HAVE_GCC_INT_ATOMICS */
+#endif /* __aarch64__ */
+
+
/* S/390 and S/390x Linux (32- and 64-bit zSeries) */
#if defined(__s390__) || defined(__s390x__)
#define HAS_TEST_AND_SET

View File

@ -58,7 +58,7 @@ Summary: PostgreSQL client programs
Name: postgresql
%global majorversion 9.2
Version: 9.2.4
Release: 1%{?dist}
Release: 2%{?dist}
# The PostgreSQL license is very similar to other MIT licenses, but the OSI
# recognizes it as an independent license, so we do as well.
@ -103,6 +103,11 @@ Patch4: postgresql-config-comment.patch
Patch5: postgresql-multi-sockets.patch
Patch6: postgresql-var-run-socket.patch
# Add support for atomic operations TAS/S_UNLOCK in aarch64.
# ~> upstream (612ecf311b)
# ~> #970661
Patch7: postgresql-9.2.4-aarch64-atomic.patch
BuildRequires: perl(ExtUtils::MakeMaker) glibc-devel bison flex gawk
BuildRequires: perl(ExtUtils::Embed), perl-devel
BuildRequires: readline-devel zlib-devel
@ -329,6 +334,7 @@ benchmarks.
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1 -b .atomic-aarch64
# We used to run autoconf here, but there's no longer any real need to,
# since Postgres ships with a reasonably modern configure script.
@ -1097,8 +1103,9 @@ fi
%endif
%changelog
* Tue Jun 04 2013 Pavel Raiskup <praiskup@redhat.com> - 9.2.4-1
* Wed Jun 05 2013 Pavel Raiskup <praiskup@redhat.com> - 9.2.4-2
- fix rpmlint warnings
- fix aarch64 build by defining missing atomic operations (#970661)
* Thu Apr 4 2013 Tom Lane <tgl@redhat.com> 9.2.4-1
- Update to PostgreSQL 9.2.4, for various fixes described at