diff options
author | Alexander Barkov <bar@mariadb.org> | 2015-10-24 20:16:06 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.org> | 2015-10-24 20:16:06 +0400 |
commit | 2c0bcfff8c8e32a9b70d1090ab34a5f53182ad52 (patch) | |
tree | 928c2372a47b54b0ce075953ac750f5d337c8704 /storage/connect/value.h | |
parent | d546d1cc138cc0e6c7d69a55bfee2bebfa4d4c0e (diff) | |
download | mariadb-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.h | 20 |
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); |