summaryrefslogtreecommitdiff
path: root/storage/connect/value.h
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 /storage/connect/value.h
parentd546d1cc138cc0e6c7d69a55bfee2bebfa4d4c0e (diff)
downloadmariadb-git-2c0bcfff8c8e32a9b70d1090ab34a5f53182ad52.tar.gz
MDEV-8693 Tests connect.bin connect.endian fail on armhf (on Debian build system)
Diffstat (limited to 'storage/connect/value.h')
-rw-r--r--storage/connect/value.h20
1 files changed, 20 insertions, 0 deletions
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);