summaryrefslogtreecommitdiffstats
path: root/src/corelib/global
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2011-04-05 01:53:34 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2011-04-05 01:53:34 (GMT)
commitc3e903409b96fede96cb4a7b95ba308663c88879 (patch)
tree58d70c5c1a5af72aa5220b1132786e065cb56154 /src/corelib/global
parent3840002c93cadb22a67b1f06475d5c1708f507df (diff)
parent3290e4c1956bc6df63af669523391565c67e8c42 (diff)
downloadQt-c3e903409b96fede96cb4a7b95ba308663c88879.zip
Qt-c3e903409b96fede96cb4a7b95ba308663c88879.tar.gz
Qt-c3e903409b96fede96cb4a7b95ba308663c88879.tar.bz2
Merge branch 'master' of scm.dev.nokia.troll.no:qt/oslo-staging-1 into master-integration
* 'master' of scm.dev.nokia.troll.no:qt/oslo-staging-1: Add branch prediction macros Add methods for traversing and combining QProcessEnvironment. Handle the HTTP 418 reply properly in QNAM absorb translations.pri into translations.pro let generated flag control SQL generation Add version attributes as per ODF specification
Diffstat (limited to 'src/corelib/global')
-rw-r--r--src/corelib/global/qglobal.cpp34
-rw-r--r--src/corelib/global/qglobal.h11
2 files changed, 45 insertions, 0 deletions
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index bcaed41..97b4407 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -2870,6 +2870,40 @@ int qrand()
*/
/*!
+ \macro Q_LIKELY(expr)
+ \relates <QtGlobal>
+ \since 4.8
+
+ \brief Hints the compiler that the enclosed condition is likely to evaluate
+ to \c true.
+
+ Use of this macro can help the compiler to optimize the code.
+
+ Example:
+
+ \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp qlikely
+
+ \sa Q_UNLIKELY()
+*/
+
+/*!
+ \macro Q_UNLIKELY(expr)
+ \relates <QtGlobal>
+ \since 4.8
+
+ \brief Hints the compiler that the enclosed condition is likely to evaluate
+ to \c false.
+
+ Use of this macro can help the compiler to optimize the code.
+
+ Example:
+
+ \snippet doc/src/snippets/code/src_corelib_global_qglobal.cpp qunlikely
+
+ \sa Q_LIKELY()
+*/
+
+/*!
\macro QT_POINTER_SIZE
\relates <QtGlobal>
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index d3b3e14..7c5c354 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -497,6 +497,10 @@ namespace QT_NAMESPACE {}
# define Q_TYPEOF(expr) __typeof__(expr)
# define Q_DECL_ALIGN(n) __attribute__((__aligned__(n)))
# endif
+# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
+# define Q_LIKELY(expr) __builtin_expect(!!(expr), true)
+# define Q_UNLIKELY(expr) __builtin_expect(!!(expr), false)
+# endif
/* GCC 3.1 and GCC 3.2 wrongly define _SB_CTYPE_MACROS on HP-UX */
# if defined(Q_OS_HPUX) && __GNUC__ == 3 && __GNUC_MINOR__ >= 1
# define Q_WRONG_SB_CTYPE_MACROS
@@ -801,6 +805,13 @@ namespace QT_NAMESPACE {}
# undef Q_NO_PACKED_REFERENCE
#endif
+#ifndef Q_LIKELY
+# define Q_LIKELY(x) (x)
+#endif
+#ifndef Q_UNLIKELY
+# define Q_UNLIKELY(x) (x)
+#endif
+
#ifndef Q_CONSTRUCTOR_FUNCTION
# define Q_CONSTRUCTOR_FUNCTION0(AFUNC) \
static const int AFUNC ## __init_variable__ = AFUNC();