diff options
author | Liang Qi <liang.qi@theqtcompany.com> | 2016-03-13 18:39:03 +0000 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2016-03-13 19:27:21 +0000 |
commit | 59a3ca679ede2cb9b6a162edf8eba5cf6d9af4a9 (patch) | |
tree | 0d0f76caa042db299cddaa84c14c28e4c80b2ffd /src/corelib/tools/qsimd_p.h | |
parent | 447a508d003ce487f2be69af9ab05aeec272e64d (diff) | |
parent | 50d0f57b77b8088875d7185c5906b5f57985d5fb (diff) |
Merge "Merge remote-tracking branch 'origin/5.6' into 5.7" into refs/staging/5.7
Diffstat (limited to 'src/corelib/tools/qsimd_p.h')
-rw-r--r-- | src/corelib/tools/qsimd_p.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/corelib/tools/qsimd_p.h b/src/corelib/tools/qsimd_p.h index 02439a2a9c..1a795a670d 100644 --- a/src/corelib/tools/qsimd_p.h +++ b/src/corelib/tools/qsimd_p.h @@ -521,6 +521,32 @@ unsigned _bit_scan_forward(unsigned val) #define ALIGNMENT_PROLOGUE_16BYTES(ptr, i, length) \ for (; i < static_cast<int>(qMin(static_cast<quintptr>(length), ((4 - ((reinterpret_cast<quintptr>(ptr) >> 2) & 0x3)) & 0x3))); ++i) +template <typename T> +Q_ALWAYS_INLINE +T qUnalignedLoad(const void *ptr) Q_DECL_NOTHROW +{ + T result; +#if QT_HAS_BUILTIN(__builtin_memcpy) + __builtin_memcpy +#else + memcpy +#endif + /*memcpy*/(&result, ptr, sizeof result); + return result; +} + +template <typename T> +Q_ALWAYS_INLINE +void qUnalignedStore(void *ptr, T t) Q_DECL_NOTHROW +{ +#if QT_HAS_BUILTIN(__builtin_memcpy) + __builtin_memcpy +#else + memcpy +#endif + /*memcpy*/(ptr, &t, sizeof t); +} + QT_END_NAMESPACE #endif // QSIMD_P_H |