Line | Source Code | Coverage |
---|
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | | - |
8 | | - |
9 | | - |
10 | | - |
11 | | - |
12 | static void checkElapsedTimerIsTrivial() | - |
13 | { | - |
14 | static_assert(bool(std::has_trivial_default_constructor< ::QElapsedTimer>::value), "std::has_trivial_default_constructor<QT_PREPEND_NAMESPACE(QElapsedTimer)>::value"); | - |
15 | } executed: } Execution Count:4623506 | 4623506 |
16 | | - |
17 | static QBasicAtomicInt futexFlagSupport = { (-1) }; | - |
18 | | - |
19 | static int checkFutexPrivateSupport() | - |
20 | { | - |
21 | int value = 0; | - |
22 | | - |
23 | | - |
24 | | - |
25 | static_assert(bool(128 != 0x80000000), "FUTEX_PRIVATE_FLAG != 0x80000000"); | - |
26 | | - |
27 | | - |
28 | | - |
29 | | - |
30 | value = syscall(202, &futexFlagSupport, | - |
31 | 1 | 128, | - |
32 | 42, 0, 0, 0); | - |
33 | if (value != -1) partially evaluated: value != -1 yes Evaluation Count:71 | no Evaluation Count:0 |
| 0-71 |
34 | value = 128; executed: value = 128; Execution Count:71 | 71 |
35 | else | - |
36 | value = 0; never executed: value = 0; | 0 |
37 | | - |
38 | | - |
39 | | - |
40 | | - |
41 | futexFlagSupport.store(value); | - |
42 | return value; executed: return value; Execution Count:71 | 71 |
43 | } | - |
44 | | - |
45 | static inline int futexFlags() | - |
46 | { | - |
47 | int value = futexFlagSupport.load(); | - |
48 | if (__builtin_expect(!!(value != -1), true)) evaluated: __builtin_expect(!!(value != -1), true) yes Evaluation Count:14698187 | yes Evaluation Count:69 |
| 69-14698187 |
49 | return value; executed: return value; Execution Count:14691742 | 14691742 |
50 | return checkFutexPrivateSupport(); executed: return checkFutexPrivateSupport(); Execution Count:69 | 69 |
51 | } | - |
52 | | - |
53 | static inline int _q_futex(void *addr, int op, int val, const struct timespec *timeout) | - |
54 | { | - |
55 | volatile int *int_addr = reinterpret_cast<volatile int *>(addr); | - |
56 | | - |
57 | | - |
58 | | - |
59 | int *addr2 = 0; | - |
60 | int val2 = 0; | - |
61 | | - |
62 | | - |
63 | | - |
64 | return syscall(202, int_addr, op | futexFlags(), val, timeout, addr2, val2); executed: return syscall(202, int_addr, op | futexFlags(), val, timeout, addr2, val2); Execution Count:14708516 | 14708516 |
65 | } | - |
66 | | - |
67 | static inline QMutexData *dummyFutexValue() | - |
68 | { | - |
69 | return reinterpret_cast<QMutexData *>(quintptr(3)); executed: return reinterpret_cast<QMutexData *>(quintptr(3)); Execution Count:18465488 | 18465488 |
70 | } | - |
71 | | - |
72 | template <bool IsTimed> static inline | - |
73 | bool lockInternal_helper(QBasicAtomicPointer<QMutexData> &d_ptr, int timeout = -1) | - |
74 | { | - |
75 | if (!IsTimed) evaluated: !IsTimed yes Evaluation Count:4612870 | yes Evaluation Count:219504 |
| 219504-4612870 |
76 | timeout = -1; executed: timeout = -1; Execution Count:4611078 | 4611078 |
77 | | - |
78 | | - |
79 | if (timeout == 0) evaluated: timeout == 0 yes Evaluation Count:204234 | yes Evaluation Count:4624083 |
| 204234-4624083 |
80 | return false; executed: return false; Execution Count:204032 | 204032 |
81 | | - |
82 | struct timespec ts, *pts = 0; | - |
83 | QElapsedTimer elapsedTimer; | - |
84 | checkElapsedTimerIsTrivial(); | - |
85 | if (IsTimed && timeout > 0) { evaluated: IsTimed yes Evaluation Count:16476 | yes Evaluation Count:4608335 |
evaluated: timeout > 0 yes Evaluation Count:16473 | yes Evaluation Count:4 |
| 4-4608335 |
86 | ts.tv_sec = timeout / 1000; | - |
87 | ts.tv_nsec = (timeout % 1000) * 1000 * 1000; | - |
88 | elapsedTimer.start(); | - |
89 | } executed: } Execution Count:16476 | 16476 |
90 | | - |
91 | | - |
92 | while (d_ptr.fetchAndStoreAcquire(dummyFutexValue()) != 0) { evaluated: d_ptr.fetchAndStoreAcquire(dummyFutexValue()) != 0 yes Evaluation Count:7007316 | yes Evaluation Count:4645042 |
| 4645042-7007316 |
93 | if (IsTimed && pts == &ts) { evaluated: IsTimed yes Evaluation Count:16299 | yes Evaluation Count:6994379 |
evaluated: pts == &ts yes Evaluation Count:276 | yes Evaluation Count:16020 |
| 276-6994379 |
94 | | - |
95 | qint64 xtimeout = qint64(timeout) * 1000 * 1000; | - |
96 | xtimeout -= elapsedTimer.nsecsElapsed(); | - |
97 | if (xtimeout <= 0) { evaluated: xtimeout <= 0 yes Evaluation Count:145 | yes Evaluation Count:131 |
| 131-145 |
98 | | - |
99 | return false; executed: return false; Execution Count:145 | 145 |
100 | } | - |
101 | ts.tv_sec = xtimeout / static_cast<long long>(1000LL) / 1000 / 1000; | - |
102 | ts.tv_nsec = xtimeout % (static_cast<long long>(1000LL) * 1000 * 1000); | - |
103 | } executed: } Execution Count:131 | 131 |
104 | if (IsTimed && timeout > 0) evaluated: IsTimed yes Evaluation Count:16153 | yes Evaluation Count:6996898 |
evaluated: timeout > 0 yes Evaluation Count:16149 | yes Evaluation Count:4 |
| 4-6996898 |
105 | pts = &ts; executed: pts = &ts; Execution Count:16152 | 16152 |
106 | | - |
107 | | - |
108 | int r = _q_futex(&d_ptr, 0, quintptr(dummyFutexValue()), pts); | - |
109 | if (IsTimed && r != 0 && (*__errno_location ()) == 110) evaluated: IsTimed yes Evaluation Count:16147 | yes Evaluation Count:6997741 |
evaluated: r != 0 yes Evaluation Count:7947 | yes Evaluation Count:8210 |
evaluated: (*__errno_location ()) == 110 yes Evaluation Count:7807 | yes Evaluation Count:140 |
| 140-6997741 |
110 | return false; executed: return false; Execution Count:7805 | 7805 |
111 | | - |
112 | | - |
113 | | - |
114 | | - |
115 | } executed: } Execution Count:7005507 | 7005507 |
116 | | - |
117 | qt_noop(); | - |
118 | return true; executed: return true; Execution Count:4645036 | 4645036 |
119 | } | - |
120 | | - |
121 | void QBasicMutex::lockInternal() | - |
122 | { | - |
123 | qt_noop(); | - |
124 | lockInternal_helper<false>(d_ptr); | - |
125 | } executed: } Execution Count:4636512 | 4636512 |
126 | | - |
127 | bool QBasicMutex::lockInternal(int timeout) | - |
128 | { | - |
129 | qt_noop(); | - |
130 | return lockInternal_helper<true>(d_ptr, timeout); executed: return lockInternal_helper<true>(d_ptr, timeout); Execution Count:222053 | 222053 |
131 | } | - |
132 | | - |
133 | void QBasicMutex::unlockInternal() | - |
134 | { | - |
135 | QMutexData *d = d_ptr.load(); | - |
136 | qt_noop(); | - |
137 | qt_noop(); | - |
138 | (void)d;; | - |
139 | qt_noop(); | - |
140 | | - |
141 | d_ptr.storeRelease(0); | - |
142 | _q_futex(&d_ptr, 1, 1, 0); | - |
143 | } executed: } Execution Count:7842315 | 7842315 |
144 | | - |
145 | | - |
146 | | - |
147 | | - |
| | |