summaryrefslogtreecommitdiff
path: root/storage/connect/value.h
diff options
context:
space:
mode:
authorOlivier Bertrand <bertrandop@gmail.com>2016-12-02 23:03:43 +0100
committerOlivier Bertrand <bertrandop@gmail.com>2016-12-02 23:03:43 +0100
commit599d8cc2deee615526838ddc962778e51cd3a15a (patch)
tree03b377d18bb107521fb5327ff8015f7452517c0d /storage/connect/value.h
parent2d78b25c49407fb3f17fd4e44b551e8b43ffa4b5 (diff)
downloadmariadb-git-599d8cc2deee615526838ddc962778e51cd3a15a.tar.gz
- MDEV-11366 SIGBUS errors in Connect Storage Engine for ArmHF and MIPS.
Fix includes launchpad fix plus more to cover writing BIN tables. modified: storage/connect/tabfix.cpp modified: storage/connect/value.cpp modified: storage/connect/value.h - Typo: Change the name of filamzip to filamgz to prepare future ZIP tables. modified: storage/connect/CMakeLists.txt added: storage/connect/filamgz.cpp added: storage/connect/filamgz.h deleted: storage/connect/filamzip.cpp deleted: storage/connect/filamzip.h modified: storage/connect/plgdbsem.h modified: storage/connect/reldef.cpp modified: storage/connect/tabdos.cpp modified: storage/connect/tabdos.h modified: storage/connect/tabfix.cpp modified: storage/connect/tabfmt.cpp modified: storage/connect/tabjson.cpp
Diffstat (limited to 'storage/connect/value.h')
-rw-r--r--storage/connect/value.h66
1 files changed, 46 insertions, 20 deletions
diff --git a/storage/connect/value.h b/storage/connect/value.h
index c5a381e89da..a670ade4c28 100644
--- a/storage/connect/value.h
+++ b/storage/connect/value.h
@@ -1,7 +1,7 @@
/**************** Value H Declares Source Code File (.H) ***************/
-/* Name: VALUE.H Version 2.1 */
+/* Name: VALUE.H Version 2.2 */
/* */
-/* (C) Copyright to the author Olivier BERTRAND 2001-2014 */
+/* (C) Copyright to the author Olivier BERTRAND 2001-2016 */
/* */
/* This file contains the VALUE and derived classes declares. */
/***********************************************************************/
@@ -17,6 +17,13 @@
#include "block.h"
/***********************************************************************/
+/* This should list the processors accepting unaligned numeral values.*/
+/***********************************************************************/
+#if defined(__i386__) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_X64) || defined(_M_AMD64) || defined(_M_IA64)
+#define UNALIGNED_OK
+#endif
+
+/***********************************************************************/
/* Types used in some class definitions. */
/***********************************************************************/
enum CONV {CNV_ANY = 0, /* Convert to any type */
@@ -116,27 +123,46 @@ class DllExport VALUE : public BLOCK {
virtual bool Compute(PGLOBAL g, PVAL *vp, int np, OPVAL op);
virtual bool FormatValue(PVAL vp, char *fmt) = 0;
- /**
- Set value from a non-aligned in-memory value in the machine byte order.
- TYPE can be either of:
- - int, short, longlong
- - uint, ushort, ulonglong
- - float, double
- @param - a pointer to a non-aligned value of type TYPE.
- */
- template<typename TYPE>
- void SetValueNonAligned(const char *p)
- {
-#if defined(__i386__) || defined(__x86_64__)
- SetValue(*((TYPE*) p)); // x86 can cast non-aligned memory directly
+ /**
+ Set value from a non-aligned in-memory value in the machine byte order.
+ TYPE can be either of:
+ - int, short, longlong
+ - uint, ushort, ulonglong
+ - float, double
+ @param - a pointer to a non-aligned value of type TYPE.
+ */
+ template<typename TYPE>
+ void SetValueNonAligned(const char *p)
+ {
+#if defined(UNALIGNED_OK)
+ SetValue(*((TYPE*)p)); // x86 can cast non-aligned memory directly
#else
- TYPE tmp; // a slower version for non-x86 platforms
- memcpy(&tmp, p, sizeof(tmp));
- SetValue(tmp);
+ TYPE tmp; // a slower version for non-x86 platforms
+ memcpy(&tmp, p, sizeof(tmp));
+ SetValue(tmp);
#endif
- }
+ } // end of SetValueNonAligned
+
+ /**
+ Get value from a non-aligned in-memory value in the machine byte order.
+ TYPE can be either of:
+ - int, short, longlong
+ - uint, ushort, ulonglong
+ - float, double
+ @params - a pointer to a non-aligned value of type TYPE, the TYPE value.
+ */
+ template<typename TYPE>
+ void GetValueNonAligned(char *p, TYPE n)
+ {
+#if defined(UNALIGNED_OK)
+ *(TYPE *)p = n; // x86 can cast non-aligned memory directly
+#else
+ TYPE tmp = n; // a slower version for non-x86 platforms
+ memcpy(p, &tmp, sizeof(tmp));
+#endif
+ } // end of SetValueNonAligned
- protected:
+protected:
virtual bool SetConstFormat(PGLOBAL, FORMAT&) = 0;
const char *GetXfmt(void);