Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qfutex_mac_p.h
Go to the documentation of this file.
1
// Copyright (C) 2023 Intel Corporation.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
// Qt-Security score:significant reason:default
4
5
#
ifndef
QFUTEX_MAC_P_H
6
#
define
QFUTEX_MAC_P_H
7
8
//
9
// W A R N I N G
10
// -------------
11
//
12
// This file is not part of the Qt API. It exists purely as an
13
// implementation detail. This header file may change from version to
14
// version without notice, or even be removed.
15
//
16
// We mean it.
17
//
18
19
#
include
<
qdeadlinetimer
.
h
>
20
#
include
<
qtsan_impl
.
h
>
21
#
include
<
private
/
qglobal_p
.
h
>
22
23
#
include
<
os
/
os_sync_wait_on_address
.
h
>
24
25
#
define
QT_ALWAYS_USE_FUTEX
26
27
QT_BEGIN_NAMESPACE
28
29
namespace
QtDarwinFutex
{
30
31
constexpr
bool
futexAvailable
() {
return
true
; }
32
33
template
<
typename
Atomic>
34
inline
void
futexWait
(Atomic &futex,
typename
Atomic::Type expectedValue)
35
{
36
QtTsan
::
futexRelease
(
&futex
)
;
37
static_assert
(
sizeof
(
typename
Atomic::Type) == 4 ||
sizeof
(
typename
Atomic::Type) == 8);
38
os_sync_wait_on_address(&futex, quint64(expectedValue),
sizeof
(
typename
Atomic::Type),
39
OS_SYNC_WAIT_ON_ADDRESS_NONE);
40
QtTsan
::
futexAcquire
(
&futex
)
;
41
}
42
43
template
<
typename
Atomic>
44
inline
bool
futexWait
(Atomic &futex,
typename
Atomic::Type expectedValue, QDeadlineTimer timer)
45
{
46
QtTsan
::
futexRelease
(
&futex
)
;
47
static_assert
(
sizeof
(
typename
Atomic::Type) == 4 ||
sizeof
(
typename
Atomic::Type) == 8);
48
int
r = os_sync_wait_on_address_with_timeout(
49
&futex, quint64(expectedValue),
sizeof
(
typename
Atomic::Type),
50
OS_SYNC_WAIT_ON_ADDRESS_NONE, OS_CLOCK_MACH_ABSOLUTE_TIME, timer.remainingTimeNSecs());
51
QtTsan
::
futexAcquire
(
&futex
)
;
52
return
r >= 0 || errno != ETIMEDOUT;
53
}
54
55
template
<
typename
Atomic>
56
inline
void
futexWakeAll
(Atomic &futex)
57
{
58
static_assert
(
sizeof
(
typename
Atomic::Type) == 4 ||
sizeof
(
typename
Atomic::Type) == 8);
59
os_sync_wake_by_address_all(&futex,
sizeof
(
typename
Atomic::Type),
60
OS_SYNC_WAKE_BY_ADDRESS_NONE);
61
}
62
63
template
<
typename
Atomic>
64
inline
void
futexWakeOne
(Atomic &futex)
65
{
66
static_assert
(
sizeof
(
typename
Atomic::Type) == 4 ||
sizeof
(
typename
Atomic::Type) == 8);
67
os_sync_wake_by_address_any(&futex,
sizeof
(
typename
Atomic::Type),
68
OS_SYNC_WAKE_BY_ADDRESS_NONE);
69
}
70
}
//namespace QtDarwinFutex
71
72
namespace
QtFutex =
QtDarwinFutex
;
73
74
QT_END_NAMESPACE
75
76
#
endif
// QFUTEX_MAC_P_H
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
QtDarwinFutex
Definition
qfutex_mac_p.h:29
QtDarwinFutex::futexAvailable
constexpr bool futexAvailable()
Definition
qfutex_mac_p.h:31
QtDarwinFutex::futexWakeOne
void futexWakeOne(Atomic &futex)
Definition
qfutex_mac_p.h:64
QtDarwinFutex::futexWait
void futexWait(Atomic &futex, typename Atomic::Type expectedValue)
Definition
qfutex_mac_p.h:34
QtDarwinFutex::futexWakeAll
void futexWakeAll(Atomic &futex)
Definition
qfutex_mac_p.h:56
QtDarwinFutex::futexWait
bool futexWait(Atomic &futex, typename Atomic::Type expectedValue, QDeadlineTimer timer)
Definition
qfutex_mac_p.h:44
QtTsan
Definition
qtsan_impl.h:18
QtTsan::futexRelease
void futexRelease(void *, void *=nullptr)
Definition
qtsan_impl.h:79
QtTsan::futexAcquire
void futexAcquire(void *, void *=nullptr)
Definition
qtsan_impl.h:78
qtbase
src
corelib
thread
qfutex_mac_p.h
Generated on
for Qt by
1.18.0