diff options
| author | Liang Qi <liang.qi@qt.io> | 2016-06-06 08:34:03 +0200 |
|---|---|---|
| committer | Liang Qi <liang.qi@qt.io> | 2016-06-06 09:04:55 +0200 |
| commit | 57057f76add416d0faf2e09a90c126baafb6198e (patch) | |
| tree | 07d54f8e5daeb3ed1161723542e94c324d745166 /src/corelib/global/qendian.h | |
| parent | dc0ae02ebc8e221f952829230c0301a718a6f10b (diff) | |
| parent | fd70978693bd92761e9989bc1c76bf83c1e8c987 (diff) | |
| download | qtbase-57057f76add416d0faf2e09a90c126baafb6198e.tar.gz | |
Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts:
.qmake.conf
config.tests/unix/nis/nis.cpp
mkspecs/unsupported/freebsd-g++/qplatformdefs.h
src/corelib/tools/qdatetime.cpp
src/corelib/tools/qsimd.cpp
src/corelib/tools/qsimd_p.h
src/network/access/access.pri
src/network/access/qnetworkreplynsurlconnectionimpl.mm
src/network/access/qnetworkreplynsurlconnectionimpl_p.h
src/plugins/platforms/cocoa/qnsview.mm
src/plugins/printsupport/windows/qwindowsprintdevice.cpp
tests/auto/corelib/kernel/qobject/tst_qobject.cpp
tests/auto/network/access/qnetworkreply/BLACKLIST
tests/auto/widgets/widgets/qopenglwidget/BLACKLIST
Change-Id: I4b32055bbf922392ef0264fd403405416fffee57
Diffstat (limited to 'src/corelib/global/qendian.h')
| -rw-r--r-- | src/corelib/global/qendian.h | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/src/corelib/global/qendian.h b/src/corelib/global/qendian.h index c5ff82c10a..34bb015a2f 100644 --- a/src/corelib/global/qendian.h +++ b/src/corelib/global/qendian.h @@ -49,6 +49,11 @@ QT_BEGIN_NAMESPACE +#ifdef __has_builtin +# define QT_HAS_BUILTIN(x) __has_builtin(x) +#else +# define QT_HAS_BUILTIN(x) 0 +#endif /* * ENDIAN FUNCTIONS @@ -71,18 +76,29 @@ template <typename T> inline void qbswap(const T src, uchar *dest) // Used to implement a type-safe and alignment-safe copy operation // If you want to avoid the memcpy, you must write specializations for these functions -template <typename T> inline void qToUnaligned(const T src, uchar *dest) +template <typename T> Q_ALWAYS_INLINE void qToUnaligned(const T src, uchar *dest) { // Using sizeof(T) inside memcpy function produces internal compiler error with // MSVC2008/ARM in tst_endian -> use extra indirection to resolve size of T. const size_t size = sizeof(T); - memcpy(dest, &src, size); +#if QT_HAS_BUILTIN(__builtin_memcpy) + __builtin_memcpy +#else + memcpy +#endif + (dest, &src, size); } -template <typename T> inline T qFromUnaligned(const uchar *src) + +template <typename T> Q_ALWAYS_INLINE T qFromUnaligned(const uchar *src) { T dest; const size_t size = sizeof(T); - memcpy(&dest, src, size); +#if QT_HAS_BUILTIN(__builtin_memcpy) + __builtin_memcpy +#else + memcpy +#endif + (&dest, src, size); return dest; } |
