summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri John Ledkov <dimitri.j.ledkov@linux.intel.com>2015-08-30 22:50:06 +0100
committerDimitri John Ledkov <dimitri.j.ledkov@linux.intel.com>2015-08-30 22:50:06 +0100
commitd404cdf68c140caa4a83647f65bc1b124f0d605d (patch)
tree4b02bbfaedc8be527ca518c8b1b4dafb012b987a
parent7cd967453c7f098820fd0583ba8c443fbf6062c2 (diff)
Generalise fix-mips.patch to resolve same issues on other architecutres.HEADdebian/1%2.11.2675-1.2master
Use packed structure, and gcc 64-bit atomic defines check.
-rw-r--r--debian/changelog9
-rw-r--r--debian/patches/fix-atomic-and-align.patch (renamed from debian/patches/fix-mips.patch)62
-rw-r--r--debian/patches/series2
-rw-r--r--galerautils/src/gu_atomic.h6
-rw-r--r--galerautils/src/gu_rand.c16
5 files changed, 41 insertions, 54 deletions
diff --git a/debian/changelog b/debian/changelog
index 491ea92..d64e188 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,12 @@
+percona-xtradb-cluster-galera-2.x (1:2.11.2675-1.2) unstable; urgency=medium
+
+ * Non-maintainer upload.
+ * Generalise fix-mips.patch to resolve same issues on other
+ architecutres. Use packed structure, and gcc 64-bit atomic defines
+ check.
+
+ -- Dimitri John Ledkov <dimitri.j.ledkov@linux.intel.com> Sun, 30 Aug 2015 22:48:33 +0100
+
percona-xtradb-cluster-galera-2.x (1:2.11.2675-1.1) unstable; urgency=medium
* Non-maintainer upload.
diff --git a/debian/patches/fix-mips.patch b/debian/patches/fix-atomic-and-align.patch
index d603395..2924ebc 100644
--- a/debian/patches/fix-mips.patch
+++ b/debian/patches/fix-atomic-and-align.patch
@@ -40,11 +40,18 @@ behaviuor it is needed to use corresponding __atomic_* from libatomic library.
Patch that solves both issues for mips/mipsel is attached.
-Index: percona-xtradb-cluster-galera-2.x-175/SConstruct
-===================================================================
---- percona-xtradb-cluster-galera-2.x-175.orig/SConstruct
-+++ percona-xtradb-cluster-galera-2.x-175/SConstruct
-@@ -368,7 +368,7 @@ else:
+[ Dimitri John Ledkov ]
+
+ps. These issues, also affect other architectures, e.g. armel, armhf,
+powerpc, etc. Thus generalise these fixes to be platform independant.
+Instead of __mips__ defines, use gcc macro to check for 64-bit atomics
+support. And instead of using pre-computed packed alignment for mips
+only, explicitely request packed struct alignment, to avoid
+un-initialised access on any architecture.
+
+--- a/SConstruct
++++ b/SConstruct
+@@ -368,7 +368,7 @@
print 'Not using boost'
# Check to see if -latomic is need for GCC atomic built-ins.
@@ -53,15 +60,13 @@ Index: percona-xtradb-cluster-galera-2.x-175/SConstruct
conf.env.Append(LIBS=['atomic'])
# asio
-Index: percona-xtradb-cluster-galera-2.x-175/galerautils/src/gu_atomic.h
-===================================================================
---- percona-xtradb-cluster-galera-2.x-175.orig/galerautils/src/gu_atomic.h
-+++ percona-xtradb-cluster-galera-2.x-175/galerautils/src/gu_atomic.h
+--- a/galerautils/src/gu_atomic.h
++++ b/galerautils/src/gu_atomic.h
@@ -11,6 +11,8 @@
#ifdef __GNUC__
-+#if !defined(__mips__) || defined(__mips64)
++#if defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8)
+
#define gu_sync_fetch_and_add __sync_fetch_and_add
#define gu_sync_fetch_and_sub __sync_fetch_and_sub
@@ -70,9 +75,9 @@ Index: percona-xtradb-cluster-galera-2.x-175/galerautils/src/gu_atomic.h
#define gu_sync_xor_and_fetch __sync_xor_and_fetch
#define gu_sync_nand_and_fetch __gu_sync_nand_and_fetch
-+#else /* __mips__ */
++#else /* no builtin 64-bit atomics */
+
-+/* Mips platform does not have 64-bit __sync_* operations.
++/* Platform does not have 64-bit __sync_* operations.
+ * so it is needed to use corresponding __atomic_* operations from libatomic library. */
+
+#define gu_sync_fetch_and_add(value_, x) __atomic_fetch_add(value_, x, __ATOMIC_SEQ_CST)
@@ -95,35 +100,18 @@ Index: percona-xtradb-cluster-galera-2.x-175/galerautils/src/gu_atomic.h
#else /* __GNUC__ */
#error "Compiler not supported"
#endif
-Index: percona-xtradb-cluster-galera-2.x-175/galerautils/src/gu_rand.c
-===================================================================
---- percona-xtradb-cluster-galera-2.x-175.orig/galerautils/src/gu_rand.c
-+++ percona-xtradb-cluster-galera-2.x-175/galerautils/src/gu_rand.c
-@@ -16,6 +16,16 @@
+--- a/galerautils/src/gu_rand.c
++++ b/galerautils/src/gu_rand.c
+@@ -16,7 +16,11 @@
/*! Structure to hold entropy data.
* Should be at least 20 bytes on 32-bit systems and 28 bytes on 64-bit */
+-struct gu_rse
+
-+/* Unlike ia32, aligment of long long for MIPS ISA is 8, and size of gu_rse is 24.
-+ * As "long long" atribute is first in gu_rse structure there is no harm in use pack(4) to avoid
-+ * undexpected behavior while using gu_rse structure. */
-+
-+#if defined(__mips__) && !defined(__mips64__)
-+#pragma pack(push)
-+#pragma pack(4)
-+#endif
++/* This structure is overall aligned, and should be packed, as it's
++ * bit-wise accessed. */
+
- struct gu_rse
++struct __attribute__((__packed__)) gu_rse
{
long long time;
-@@ -24,6 +34,10 @@ struct gu_rse
- long pid;
- };
-
-+#if defined(__mips__) && !defined(__mips64__)
-+#pragma pack(pop)
-+#endif
-+
- typedef struct gu_rse gu_rse_t;
-
- long int
+ const void* heap_ptr;
diff --git a/debian/patches/series b/debian/patches/series
index 2ef66d7..6fb43c4 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,3 +1,3 @@
detect-atomic.patch
-fix-mips.patch
+fix-atomic-and-align.patch
gcc5.patch
diff --git a/galerautils/src/gu_atomic.h b/galerautils/src/gu_atomic.h
index d707419..c9430de 100644
--- a/galerautils/src/gu_atomic.h
+++ b/galerautils/src/gu_atomic.h
@@ -11,7 +11,7 @@
#ifdef __GNUC__
-#if !defined(__mips__) || defined(__mips64)
+#if defined(__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8)
#define gu_sync_fetch_and_add __sync_fetch_and_add
#define gu_sync_fetch_and_sub __sync_fetch_and_sub
@@ -28,9 +28,9 @@
#define gu_sync_xor_and_fetch __sync_xor_and_fetch
#define gu_sync_nand_and_fetch __gu_sync_nand_and_fetch
-#else /* __mips__ */
+#else /* no builtin 64-bit atomics */
-/* Mips platform does not have 64-bit __sync_* operations.
+/* Platform does not have 64-bit __sync_* operations.
* so it is needed to use corresponding __atomic_* operations from libatomic library. */
#define gu_sync_fetch_and_add(value_, x) __atomic_fetch_add(value_, x, __ATOMIC_SEQ_CST)
diff --git a/galerautils/src/gu_rand.c b/galerautils/src/gu_rand.c
index 7cfee9e..e5bb897 100644
--- a/galerautils/src/gu_rand.c
+++ b/galerautils/src/gu_rand.c
@@ -17,16 +17,10 @@
/*! Structure to hold entropy data.
* Should be at least 20 bytes on 32-bit systems and 28 bytes on 64-bit */
-/* Unlike ia32, aligment of long long for MIPS ISA is 8, and size of gu_rse is 24.
- * As "long long" atribute is first in gu_rse structure there is no harm in use pack(4) to avoid
- * undexpected behavior while using gu_rse structure. */
+/* This structure is overall aligned, and should be packed, as it's
+ * bit-wise accessed. */
-#if defined(__mips__) && !defined(__mips64__)
-#pragma pack(push)
-#pragma pack(4)
-#endif
-
-struct gu_rse
+struct __attribute__((__packed__)) gu_rse
{
long long time;
const void* heap_ptr;
@@ -34,10 +28,6 @@ struct gu_rse
long pid;
};
-#if defined(__mips__) && !defined(__mips64__)
-#pragma pack(pop)
-#endif
-
typedef struct gu_rse gu_rse_t;
long int