18#include <qdeadlinetimer.h>
19#include <qtsan_impl.h>
20#include <private/qglobal_p.h>
32#if QT_CONFIG(appstore_compliant)
34namespace QtFutex = QtDummyFutex;
44__attribute((__weak__))
45extern int __ulock_wait2(uint32_t operation,
void *addr, uint64_t value,
46 uint64_t timeout, uint64_t value2);
47__attribute((__weak__))
48extern int __ulock_wake(uint32_t operation,
void *addr, uint64_t wake_value);
51
52
53#define UL_COMPARE_AND_WAIT 1
54#define UL_COMPARE_AND_WAIT_SHARED 3
55#define UL_COMPARE_AND_WAIT64 5
56#define UL_COMPARE_AND_WAIT64_SHARED 6
59
60
61#define ULF_WAKE_ALL 0x00000100
62#define ULF_WAKE_THREAD 0x00000200
63#define ULF_WAKE_ALLOW_NON_OWNER 0x00000400
66
67
68#define ULF_WAKE_ALL 0x00000100
69#define ULF_WAKE_THREAD 0x00000200
70#define ULF_WAKE_ALLOW_NON_OWNER 0x00000400
73
74
75#define ULF_NO_ERRNO 0x01000000
86template <
typename Atomic>
89 static_assert(
sizeof(Atomic) >=
sizeof(quint32),
"Can only operate on 32- or 64-bit atomics");
92 if (
sizeof(Atomic) ==
sizeof(quint32))
99template <
typename Atomic>
inline int
100do_wait(Atomic &futex,
typename Atomic::Type expectedValue, QDeadlineTimer timer)
104 int ret = __ulock_wait2(baseOperation(futex), &futex, uint64_t(expectedValue),
105 timer.remainingTimeNSecs(), 0);
110template <
typename Atomic>
111inline void futexWait(Atomic &futex,
typename Atomic::Type expectedValue)
113 do_wait(futex, expectedValue, {});
116template <
typename Atomic>
117inline bool futexWait(Atomic &futex,
typename Atomic::Type expectedValue, QDeadlineTimer timer)
119 int r = do_wait(futex, expectedValue, timer);
120 return r == 0 || r != -ETIMEDOUT;
125 __ulock_wake(baseOperation(futex) |
ULF_WAKE_ALL, &futex, 0);
130 __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