summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.org>2015-10-24 20:16:06 +0400
committerAlexander Barkov <bar@mariadb.org>2015-10-24 20:16:06 +0400
commit2c0bcfff8c8e32a9b70d1090ab34a5f53182ad52 (patch)
tree928c2372a47b54b0ce075953ac750f5d337c8704
parentd546d1cc138cc0e6c7d69a55bfee2bebfa4d4c0e (diff)
downloadmariadb-git-2c0bcfff8c8e32a9b70d1090ab34a5f53182ad52.tar.gz
MDEV-8693 Tests connect.bin connect.endian fail on armhf (on Debian build system)
-rw-r--r--storage/connect/tabfix.cpp12
-rw-r--r--storage/connect/value.h20
2 files changed, 26 insertions, 6 deletions
diff --git a/storage/connect/tabfix.cpp b/storage/connect/tabfix.cpp
index acd548c86ab..55c254f41ea 100644
--- a/storage/connect/tabfix.cpp
+++ b/storage/connect/tabfix.cpp
@@ -511,29 +511,29 @@ void BINCOL::ReadColumn(PGLOBAL g)
switch (Fmt) {
case 'X': // Standard not converted values
if (Eds && IsTypeChar(Buf_Type))
- Value->SetValue(*(longlong*)p);
+ Value->SetValueNonAligned<longlong>(p);
else
Value->SetBinValue(p);
break;
case 'S': // Short integer
- Value->SetValue(*(short*)p);
+ Value->SetValueNonAligned<short>(p);
break;
case 'T': // Tiny integer
Value->SetValue(*p);
break;
case 'I': // Integer
- Value->SetValue(*(int*)p);
+ Value->SetValueNonAligned<int>(p);
break;
case 'G': // Large (great) integer
- Value->SetValue(*(longlong*)p);
+ Value->SetValueNonAligned<longlong>(p);
break;
case 'F': // Float
case 'R': // Real
- Value->SetValue((double)*(float*)p);
+ Value->SetValueNonAligned<float>(p);
break;
case 'D': // Double
- Value->SetValue(*(double*)p);
+ Value->SetValueNonAligned<double>(p);
break;
case 'C': // Text
if (Value->SetValue_char(p, Long)) {
diff --git a/storage/connect/value.h b/storage/connect/value.h
index 780917c9962..471da851423 100644
--- a/storage/connect/value.h
+++ b/storage/connect/value.h
@@ -116,6 +116,26 @@ 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
+#else
+ TYPE tmp; // a slower version for non-x86 platforms
+ memcpy(&tmp, p, sizeof(tmp));
+ SetValue(tmp);
+#endif
+ }
+
protected:
virtual bool SetConstFormat(PGLOBAL, FORMAT&) = 0;
const char *GetXfmt(void);