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
qtsan_impl.h
Go to the documentation of this file.
1
// Copyright (C) 2017 Intel Corporation.
2
// Copyright (C) 2022 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
3
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
// Qt-Security score:significant reason:default
5
6
#
ifndef
QTSAN_IMPL_H
7
#
define
QTSAN_IMPL_H
8
9
#
include
<
QtCore
/
qglobal
.
h
>
10
11
#
if
(
__has_feature
(
thread_sanitizer
)
||
defined
(
__SANITIZE_THREAD__
)
)
&&
__has_include
(
<
sanitizer
/
tsan_interface
.
h
>
)
12
#
define
QT_BUILDING_UNDER_TSAN
13
#
include
<
sanitizer
/
tsan_interface
.
h
>
14
#
endif
15
16
QT_BEGIN_NAMESPACE
17
18
namespace
QtTsan
{
19
#
ifdef
QT_BUILDING_UNDER_TSAN
20
constexpr
inline
bool
IsEnabled
=
true
;
21
22
inline
void
futexAcquire
(
void
*
addr
,
void
*
addr2
=
nullptr
)
23
{
24
// A futex call ensures total ordering on the futex words
25
// (in either success or failure of the call). Instruct TSAN accordingly,
26
// as TSAN does not understand the futex(2) syscall (or equivalent).
27
::
__tsan_acquire
(
addr
);
28
if
(
addr2
)
29
::
__tsan_acquire
(
addr2
);
30
}
31
32
inline
void
futexRelease
(
void
*
addr
,
void
*
addr2
=
nullptr
)
33
{
34
if
(
addr2
)
35
::
__tsan_release
(
addr2
);
36
::
__tsan_release
(
addr
);
37
}
38
39
inline
void
latchWait
(
const
void
*
addr
)
40
{
41
::
__tsan_acquire
(
const_cast
<
void
*>(
addr
));
42
}
43
44
inline
void
latchCountDown
(
void
*
addr
)
45
{
46
::
__tsan_release
(
addr
);
47
}
48
49
inline
void
mutexPreLock
(
void
*
addr
,
unsigned
flags
)
50
{
51
::
__tsan_mutex_pre_lock
(
addr
,
flags
);
52
}
53
54
inline
void
mutexPostLock
(
void
*
addr
,
unsigned
flags
,
int
recursion
)
55
{
56
::
__tsan_mutex_post_lock
(
addr
,
flags
,
recursion
);
57
}
58
59
inline
void
mutexPreUnlock
(
void
*
addr
,
unsigned
flags
)
60
{
61
::
__tsan_mutex_pre_unlock
(
addr
,
flags
);
62
}
63
64
inline
void
mutexPostUnlock
(
void
*
addr
,
unsigned
flags
)
65
{
66
::
__tsan_mutex_post_unlock
(
addr
,
flags
);
67
}
68
69
enum
:
unsigned
{
70
MutexWriteReentrant
= ::
__tsan_mutex_write_reentrant
,
71
TryLock
= ::
__tsan_mutex_try_lock
,
72
TryLockFailed
= ::
__tsan_mutex_try_lock_failed
,
73
ReadLock
= ::
__tsan_mutex_read_lock
,
74
};
75
#
else
76
constexpr
inline
bool
IsEnabled
=
false
;
77
78
inline
void
futexAcquire
(
void
*,
void
* =
nullptr
) {}
79
inline
void
futexRelease
(
void
*,
void
* =
nullptr
) {}
80
inline
void
latchCountDown
(
void
*) {}
81
inline
void
latchWait
(
const
void
*) {}
82
83
enum
:
unsigned
{
84
MutexWriteReentrant
,
85
TryLock
,
86
TryLockFailed
,
87
ReadLock
,
88
};
89
inline
void
mutexPreLock
(
void
*,
unsigned
) {}
90
inline
void
mutexPostLock
(
void
*,
unsigned
,
int
) {}
91
inline
void
mutexPreUnlock
(
void
*,
unsigned
) {}
92
inline
void
mutexPostUnlock
(
void
*,
unsigned
) {}
93
#
endif
// QT_BUILDING_UNDER_TSAN
94
}
// namespace QtTsan
95
96
QT_END_NAMESPACE
97
98
#
endif
// QTSAN_IMPL_H
QtTsan
Definition
qtsan_impl.h:18
QtTsan::futexRelease
void futexRelease(void *, void *=nullptr)
Definition
qtsan_impl.h:79
QtTsan::latchCountDown
void latchCountDown(void *)
Definition
qtsan_impl.h:80
QtTsan::mutexPostUnlock
void mutexPostUnlock(void *, unsigned)
Definition
qtsan_impl.h:92
QtTsan::futexAcquire
void futexAcquire(void *, void *=nullptr)
Definition
qtsan_impl.h:78
QtTsan::latchWait
void latchWait(const void *)
Definition
qtsan_impl.h:81
QtTsan::mutexPreUnlock
void mutexPreUnlock(void *, unsigned)
Definition
qtsan_impl.h:91
QtTsan::mutexPreLock
void mutexPreLock(void *, unsigned)
Definition
qtsan_impl.h:89
QtTsan::mutexPostLock
void mutexPostLock(void *, unsigned, int)
Definition
qtsan_impl.h:90
QtTsan::IsEnabled
constexpr bool IsEnabled
Definition
qtsan_impl.h:76
QtTsan::MutexWriteReentrant
@ MutexWriteReentrant
Definition
qtsan_impl.h:84
QtTsan::ReadLock
@ ReadLock
Definition
qtsan_impl.h:87
QtTsan::TryLockFailed
@ TryLockFailed
Definition
qtsan_impl.h:86
QtTsan::TryLock
@ TryLock
Definition
qtsan_impl.h:85
__has_include
#define __has_include(x)
Definition
qcompilerdetection.h:459
__has_feature
#define __has_feature(x)
Definition
qcompilerdetection.h:447
qtbase
src
corelib
thread
qtsan_impl.h
Generated on
for Qt by
1.18.0