summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2018-03-10 11:26:04 -0800
committerAapo Keskimolo <aapo.keskimolo@qt.io>2018-03-19 20:36:55 +0000
commitdabc76de80e3b433a1a8e2354ca78a34389ea9f8 (patch)
tree7b9934a0b7d527cb6f3e0aee29d7fadc87e72ece /src/corelib
parent081c001deb75fa38385d3ff8cbbdb4f788529133 (diff)
QSemaphore: add minor optimization for 64-bit Linux systems
Since we won't use the high bit of the low 32-bit word at all, we don't need the AND with 0x7fffffff either. Just cast. Change-Id: I72f5230ad59948f784eafffd151aa5a7dee995db Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/thread/qsemaphore.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/corelib/thread/qsemaphore.cpp b/src/corelib/thread/qsemaphore.cpp
index f4674fcc1d..c2e4d7d9d1 100644
--- a/src/corelib/thread/qsemaphore.cpp
+++ b/src/corelib/thread/qsemaphore.cpp
@@ -140,6 +140,13 @@ static const quintptr futexNeedsWakeAllBit =
static int futexAvailCounter(quintptr v)
{
// the low 31 bits
+ if (futexHasWaiterCount) {
+ // the high bit of the low word isn't used
+ Q_ASSERT((v & 0x80000000U) == 0);
+
+ // so we can be a little faster
+ return int(unsigned(v));
+ }
return int(v & 0x7fffffffU);
}