Fix return type of _q_futex()
syscall(2) returns long, not int. Says Clang: qfutex_linux_p.h:48:18: error: implicit conversion loses integer precision: 'long' to 'int' [-Werror,-Wshorten-64-to-32] int result = syscall(__NR_futex, addr, op | FUTEX_PRIVATE_FLAG, val, val2, addr2, val3); ~~~~~~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Don't truncate to int in _q_futex(), pass it as long into the few callers that care about the result. Amends the start of the public history, but not picking back all the way because the code moved around a lot. In 6.7 it found its current place. Pick-to: 6.7 Task-number: QTBUG-103528 Task-number: QTBUG-126219 Change-Id: I54ccaf5564bcaf38f05fab153b1b32379a66a178 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> (cherry picked from commit 962539d12b5584e28d32dbc8c6d61a509128d910) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
d519743926
commit
5efc98981b
@ -38,14 +38,14 @@ QT_BEGIN_NAMESPACE
|
||||
namespace QtLinuxFutex {
|
||||
constexpr inline bool futexAvailable() { return true; }
|
||||
|
||||
inline int _q_futex(int *addr, int op, int val, quintptr val2 = 0,
|
||||
int *addr2 = nullptr, int val3 = 0) noexcept
|
||||
inline long _q_futex(int *addr, int op, int val, quintptr val2 = 0,
|
||||
int *addr2 = nullptr, int val3 = 0) noexcept
|
||||
{
|
||||
QtTsan::futexRelease(addr, addr2);
|
||||
|
||||
// we use __NR_futex because some libcs (like Android's bionic) don't
|
||||
// provide SYS_futex etc.
|
||||
int result = syscall(__NR_futex, addr, op | FUTEX_PRIVATE_FLAG, val, val2, addr2, val3);
|
||||
long result = syscall(__NR_futex, addr, op | FUTEX_PRIVATE_FLAG, val, val2, addr2, val3);
|
||||
|
||||
QtTsan::futexAcquire(addr, addr2);
|
||||
|
||||
@ -71,8 +71,8 @@ inline bool futexWait(Atomic &futex, typename Atomic::Type expectedValue, QDeadl
|
||||
{
|
||||
auto timeout = deadline.deadline<std::chrono::steady_clock>().time_since_epoch();
|
||||
struct timespec ts = durationToTimespec(timeout);
|
||||
int r = _q_futex(addr(&futex), FUTEX_WAIT_BITSET, qintptr(expectedValue), quintptr(&ts),
|
||||
nullptr, FUTEX_BITSET_MATCH_ANY);
|
||||
long r = _q_futex(addr(&futex), FUTEX_WAIT_BITSET, qintptr(expectedValue), quintptr(&ts),
|
||||
nullptr, FUTEX_BITSET_MATCH_ANY);
|
||||
return r == 0 || errno != ETIMEDOUT;
|
||||
}
|
||||
template <typename Atomic> inline void futexWakeOne(Atomic &futex)
|
||||
|
Loading…
x
Reference in New Issue
Block a user