19#include <qdeadlinetimer.h>
20#include <qtsan_impl.h>
21#include <private/qglobal_p.h>
33#if QT_CONFIG(appstore_compliant)
35namespace QtFutex = QtDummyFutex;
45__attribute((__weak__))
46extern int __ulock_wait2(uint32_t operation,
void *addr, uint64_t value,
47 uint64_t timeout, uint64_t value2);
48__attribute((__weak__))
49extern int __ulock_wake(uint32_t operation,
void *addr, uint64_t wake_value);
52
53
54#define UL_COMPARE_AND_WAIT 1
55#define UL_COMPARE_AND_WAIT_SHARED 3
56#define UL_COMPARE_AND_WAIT64 5
57#define UL_COMPARE_AND_WAIT64_SHARED 6
60
61
62#define ULF_WAKE_ALL 0x00000100
63#define ULF_WAKE_THREAD 0x00000200
64#define ULF_WAKE_ALLOW_NON_OWNER 0x00000400
67
68
69#define ULF_WAKE_ALL 0x00000100
70#define ULF_WAKE_THREAD 0x00000200
71#define ULF_WAKE_ALLOW_NON_OWNER 0x00000400
74
75
76#define ULF_NO_ERRNO 0x01000000
87template <
typename Atomic>
90 static_assert(
sizeof(Atomic) >=
sizeof(quint32),
"Can only operate on 32- or 64-bit atomics");
93 if (
sizeof(Atomic) ==
sizeof(quint32))
100template <
typename Atomic>
inline int
101do_wait(Atomic &futex,
typename Atomic::Type expectedValue, QDeadlineTimer timer)
105 int ret = __ulock_wait2(baseOperation(futex), &futex, uint64_t(expectedValue),
106 timer.remainingTimeNSecs(), 0);
111template <
typename Atomic>
112inline void futexWait(Atomic &futex,
typename Atomic::Type expectedValue)
114 do_wait(futex, expectedValue, {});
117template <
typename Atomic>
118inline bool futexWait(Atomic &futex,
typename Atomic::Type expectedValue, QDeadlineTimer timer)
120 int r = do_wait(futex, expectedValue, timer);
121 return r == 0 || r != -ETIMEDOUT;
126 __ulock_wake(baseOperation(futex) |
ULF_WAKE_ALL, &futex, 0);
131 __ulock_wake(baseOperation(futex), &futex, 0);
void futexWakeOne(Atomic &futex)
void futexWait(Atomic &futex, typename Atomic::Type expectedValue)
uint32_t baseOperation(Atomic &)
void futexWakeAll(Atomic &futex)
int do_wait(Atomic &futex, typename Atomic::Type expectedValue, QDeadlineTimer timer)
bool futexWait(Atomic &futex, typename Atomic::Type expectedValue, QDeadlineTimer timer)
void futexRelease(void *, void *=nullptr)
void futexAcquire(void *, void *=nullptr)
#define UL_COMPARE_AND_WAIT
#define UL_COMPARE_AND_WAIT64