summaryrefslogtreecommitdiffstats
path: root/src/corelib/global/qendian.h
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2015-01-21 11:14:34 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2015-01-21 11:14:34 +0100
commit112342b32650f56e289c7dcd181d5897b0b77a78 (patch)
tree76e9a37bcaa70097d009628bb2b116ea782c72cb /src/corelib/global/qendian.h
parent3bbc1bf53bac7648637d92abecadc568acfffb2d (diff)
parentb6191b16d41459ed73cea738dfaf8e25e81ae22b (diff)
Merge "Merge remote-tracking branch 'origin/5.4' into dev" into refs/staging/dev
Diffstat (limited to 'src/corelib/global/qendian.h')
-rw-r--r--src/corelib/global/qendian.h12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/corelib/global/qendian.h b/src/corelib/global/qendian.h
index 1d72ba0fae..957ba2ad63 100644
--- a/src/corelib/global/qendian.h
+++ b/src/corelib/global/qendian.h
@@ -87,9 +87,15 @@ template <typename T> inline T qFromUnaligned(const uchar *src)
*/
template <typename T> T qbswap(T source);
+#ifdef __has_builtin
+# define QT_HAS_BUILTIN(x) __has_builtin(x)
+#else
+# define QT_HAS_BUILTIN(x) 0
+#endif
+
// GCC 4.3 implemented all the intrinsics, but the 16-bit one only got implemented in 4.8;
// Clang 2.6 implemented the 32- and 64-bit but waited until 3.2 to implement the 16-bit one
-#if (defined(Q_CC_GNU) && Q_CC_GNU >= 403) || (defined(Q_CC_CLANG) && Q_CC_CLANG >= 206)
+#if (defined(Q_CC_GNU) && Q_CC_GNU >= 403) || QT_HAS_BUILTIN(__builtin_bswap32)
template <> inline quint64 qbswap<quint64>(quint64 source)
{
return __builtin_bswap64(source);
@@ -130,7 +136,7 @@ template <> inline quint32 qbswap<quint32>(quint32 source)
| ((source & 0xff000000) >> 24);
}
#endif // GCC & Clang intrinsics
-#if (defined(Q_CC_GNU) && Q_CC_GNU >= 408) || (defined(Q_CC_CLANG) && Q_CC_CLANG >= 302)
+#if (defined(Q_CC_GNU) && Q_CC_GNU >= 408) || QT_HAS_BUILTIN(__builtin_bswap16)
template <> inline quint16 qbswap<quint16>(quint16 source)
{
return __builtin_bswap16(source);
@@ -148,6 +154,8 @@ template <> inline quint16 qbswap<quint16>(quint16 source)
}
#endif // GCC & Clang intrinsics
+#undef QT_HAS_BUILTIN
+
// signed specializations
template <> inline qint64 qbswap<qint64>(qint64 source)
{