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:4631415 | 4631415 |
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:74 | no Evaluation Count:0 |
| 0-74 |
34 | value = 128; executed: value = 128; Execution Count:74 | 74 |
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:73 | 73 |
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:14715604 | yes Evaluation Count:72 |
| 72-14715604 |
49 | return value; executed: return value; Execution Count:14705438 | 14705438 |
50 | return checkFutexPrivateSupport(); executed: return checkFutexPrivateSupport(); Execution Count:73 | 73 |
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:14722852 | 14722852 |
65 | } | - |
66 | | - |
67 | static inline QMutexData *dummyFutexValue() | - |
68 | { | - |
69 | return reinterpret_cast<QMutexData *>(quintptr(3)); executed: return reinterpret_cast<QMutexData *>(quintptr(3)); Execution Count:18492938 | 18492938 |
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:4620449 | yes Evaluation Count:232452 |
| 232452-4620449 |
76 | timeout = -1; executed: timeout = -1; Execution Count:4618076 | 4618076 |
77 | | - |
78 | | - |
79 | if (timeout == 0) evaluated: timeout == 0 yes Evaluation Count:215910 | yes Evaluation Count:4631859 |
| 215910-4631859 |
80 | return false; executed: return false; Execution Count:215393 | 215393 |
81 | | - |
82 | struct timespec ts, *pts = 0; | - |
83 | QElapsedTimer elapsedTimer; | - |
84 | checkElapsedTimerIsTrivial(); | - |
85 | if (IsTimed && timeout > 0) { evaluated: IsTimed yes Evaluation Count:16831 | yes Evaluation Count:4615492 |
evaluated: timeout > 0 yes Evaluation Count:16828 | yes Evaluation Count:4 |
| 4-4615492 |
86 | ts.tv_sec = timeout / 1000; | - |
87 | ts.tv_nsec = (timeout % 1000) * 1000 * 1000; | - |
88 | elapsedTimer.start(); | - |
89 | } executed: } Execution Count:16838 | 16838 |
90 | | - |
91 | | - |
92 | while (d_ptr.fetchAndStoreAcquire(dummyFutexValue()) != 0) { evaluated: d_ptr.fetchAndStoreAcquire(dummyFutexValue()) != 0 yes Evaluation Count:7011362 | yes Evaluation Count:4650469 |
| 4650469-7011362 |
93 | if (IsTimed && pts == &ts) { evaluated: IsTimed yes Evaluation Count:16684 | yes Evaluation Count:7000305 |
evaluated: pts == &ts yes Evaluation Count:292 | yes Evaluation Count:16389 |
| 292-7000305 |
94 | | - |
95 | qint64 xtimeout = qint64(timeout) * 1000 * 1000; | - |
96 | xtimeout -= elapsedTimer.nsecsElapsed(); | - |
97 | if (xtimeout <= 0) { evaluated: xtimeout <= 0 yes Evaluation Count:146 | yes Evaluation Count:146 |
| 146 |
98 | | - |
99 | return false; executed: return false; Execution Count:146 | 146 |
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:146 | 146 |
104 | if (IsTimed && timeout > 0) evaluated: IsTimed yes Evaluation Count:16537 | yes Evaluation Count:7002417 |
evaluated: timeout > 0 yes Evaluation Count:16533 | yes Evaluation Count:4 |
| 4-7002417 |
105 | pts = &ts; executed: pts = &ts; Execution Count:16535 | 16535 |
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:16532 | yes Evaluation Count:7003013 |
evaluated: r != 0 yes Evaluation Count:8035 | yes Evaluation Count:8501 |
evaluated: (*__errno_location ()) == 110 yes Evaluation Count:7903 | yes Evaluation Count:135 |
| 135-7003013 |
110 | return false; executed: return false; Execution Count:7898 | 7898 |
111 | | - |
112 | | - |
113 | | - |
114 | | - |
115 | } executed: } Execution Count:7011219 | 7011219 |
116 | | - |
117 | qt_noop(); | - |
118 | return true; executed: return true; Execution Count:4650436 | 4650436 |
119 | } | - |
120 | | - |
121 | void QBasicMutex::lockInternal() | - |
122 | { | - |
123 | qt_noop(); | - |
124 | lockInternal_helper<false>(d_ptr); | - |
125 | } executed: } Execution Count:4641658 | 4641658 |
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:236010 | 236010 |
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:7868264 | 7868264 |
144 | | - |
145 | | - |
146 | | - |
147 | | - |
| | |