diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2021-04-09 11:44:28 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2021-04-09 17:58:15 +0200 |
commit | c2348e2c7a4d92be21714deffed9c7a611e1b792 (patch) | |
tree | f427f8064157ae2f5314afb854cc8a6b9d88fe58 /src | |
parent | f3a042c5ab998c0d283017f3569bb72c392580b7 (diff) |
Fix futexNeedsWake() on 64-bit systems
It was mistaking semaphore values over 0 as waiters, regardless of
actual waiters.
Pick-to: 6.1
Change-Id: Icebd01592ca8bdc1687a29dc569e3b630a262606
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/thread/qsemaphore.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/corelib/thread/qsemaphore.cpp b/src/corelib/thread/qsemaphore.cpp index 45983d47ab..213852250f 100644 --- a/src/corelib/thread/qsemaphore.cpp +++ b/src/corelib/thread/qsemaphore.cpp @@ -150,10 +150,11 @@ static int futexAvailCounter(quintptr v) static bool futexNeedsWake(quintptr v) { - // If we're counting waiters, the number of waiters is stored in the low 31 - // bits of the high word (that is, bits 32-62). If we're not, then we use - // bit 31 to indicate anyone is waiting. Either way, if any bit 31 or above - // is set, there are waiters. + // If we're counting waiters, the number of waiters plus value is stored in the + // low 31 bits of the high word (that is, bits 32-62). If we're not, then we only + // use futexNeedsWakeAllBit to indicate anyone is waiting. + if constexpr (futexHasWaiterCount) + return (v >> 32) > (unsigned(v)); return v >> 31; } |