global/qglobal.cpp

Switch to Source codePreprocessed file
LineSource CodeCoverage
1 -
2 -
3 -
4 -
5 -
6 -
7 -
8 -
9 -
10__attribute__((visibility("default"))) void *qMemCopy(void *dest, const void *src, size_t n); -
11__attribute__((visibility("default"))) void *qMemSet(void *dest, int c, size_t n); -
12const char *qVersion() -
13{ -
14 return "5.0.2";
executed: return "5.0.2";
Execution Count:400
400
15} -
16 -
17bool qSharedBuild() -
18{ -
19 -
20 return true;
never executed: return true;
0
21 -
22 -
23 -
24} -
25void qt_check_pointer(const char *n, int l) -
26{ -
27 QMessageLogger("global/qglobal.cpp", 1947, __PRETTY_FUNCTION__).fatal("In file %s, line %d: Out of memory", n, l); -
28}
never executed: }
0
29 -
30 -
31 -
32 -
33 -
34 -
35void qBadAlloc() -
36{ -
37 throw std::bad_alloc();
executed: throw std::bad_alloc();
Execution Count:2
2
38} -
39 -
40 -
41 -
42 -
43 -
44 -
45 -
46__attribute__((__noreturn__)) void qTerminate() -
47{ -
48 std::terminate(); -
49}
never executed: }
0
50 -
51 -
52 -
53 -
54 -
55void qt_assert(const char *assertion, const char *file, int line) -
56{ -
57 QMessageLogger("global/qglobal.cpp", 1977, __PRETTY_FUNCTION__).fatal("ASSERT: \"%s\" in file %s, line %d", assertion, file, line); -
58}
never executed: }
0
59 -
60 -
61 -
62 -
63void qt_assert_x(const char *where, const char *what, const char *file, int line) -
64{ -
65 QMessageLogger("global/qglobal.cpp", 1985, __PRETTY_FUNCTION__).fatal("ASSERT failure in %s: \"%s\", file %s, line %d", where, what, file, line); -
66}
never executed: }
0
67 -
68 -
69 -
70 -
71 -
72 -
73 -
74__attribute__((visibility("default"))) unsigned int qt_int_sqrt(unsigned int n) -
75{ -
76 -
77 if (n >= ((2147483647 * 2U + 1U)>>2)) {
partially evaluated: n >= ((2147483647 * 2U + 1U)>>2)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:13
0-13
78 unsigned int r = 2 * qt_int_sqrt(n / 4); -
79 unsigned int r2 = r + 1; -
80 return (n >= r2 * r2) ? r2 : r;
never executed: return (n >= r2 * r2) ? r2 : r;
0
81 } -
82 uint h, p= 0, q= 1, r= n; -
83 while (q <= n)
evaluated: q <= n
TRUEFALSE
yes
Evaluation Count:122
yes
Evaluation Count:13
13-122
84 q <<= 2;
executed: q <<= 2;
Execution Count:122
122
85 while (q != 1) {
evaluated: q != 1
TRUEFALSE
yes
Evaluation Count:122
yes
Evaluation Count:13
13-122
86 q >>= 2; -
87 h= p + q; -
88 p >>= 1; -
89 if (r >= h) {
evaluated: r >= h
TRUEFALSE
yes
Evaluation Count:76
yes
Evaluation Count:46
46-76
90 p += q; -
91 r -= h; -
92 }
executed: }
Execution Count:76
76
93 }
executed: }
Execution Count:122
122
94 return p;
executed: return p;
Execution Count:13
13
95} -
96 -
97void *qMemCopy(void *dest, const void *src, size_t n) { return memcpy(dest, src, n); }
never executed: return memcpy(dest, src, n);
0
98void *qMemSet(void *dest, int c, size_t n) { return memset(dest, c, n); }
never executed: return memset(dest, c, n);
0
99 -
100 -
101 -
102namespace { -
103 static inline QString fromstrerror_helper(int, const QByteArray &buf) -
104 { -
105 return QString::fromLocal8Bit(buf);
never executed: return QString::fromLocal8Bit(buf);
0
106 } -
107 static inline QString fromstrerror_helper(const char *str, const QByteArray &) -
108 { -
109 return QString::fromLocal8Bit(str);
executed: return QString::fromLocal8Bit(str);
Execution Count:12
12
110 } -
111} -
112 -
113 -
114QString qt_error_string(int errorCode) -
115{ -
116 const char *s = 0; -
117 QString ret; -
118 if (errorCode == -1) {
partially evaluated: errorCode == -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3104
0-3104
119 -
120 -
121 -
122 errorCode = (*__errno_location ()); -
123 -
124 }
never executed: }
0
125 switch (errorCode) { -
126 case 0: -
127 break;
never executed: break;
0
128 case 13: -
129 s = "Permission denied"; -
130 break;
executed: break;
Execution Count:44
44
131 case 24: -
132 s = "Too many open files"; -
133 break;
never executed: break;
0
134 case 2: -
135 s = "No such file or directory"; -
136 break;
executed: break;
Execution Count:3042
3042
137 case 28: -
138 s = "No space left on device"; -
139 break;
executed: break;
Execution Count:6
6
140 default: { -
141 QByteArray buf(1024, '\0'); -
142 ret = fromstrerror_helper(strerror_r(errorCode, buf.data(), buf.size()), buf); -
143 -
144 -
145 -
146 break; }
executed: break;
Execution Count:12
12
147 } -
148 if (s)
evaluated: s
TRUEFALSE
yes
Evaluation Count:3092
yes
Evaluation Count:12
12-3092
149 -
150 -
151 ret = QString::fromLatin1(s);
executed: ret = QString::fromLatin1(s);
Execution Count:3092
3092
152 return ret.trimmed();
executed: return ret.trimmed();
Execution Count:3104
3104
153} -
154QByteArray qgetenv(const char *varName) -
155{ -
156 return QByteArray(::getenv(varName));
executed: return QByteArray(::getenv(varName));
Execution Count:9260
9260
157 -
158} -
159bool qEnvironmentVariableIsEmpty(const char *varName) -
160{ -
161 const char * const value = ::getenv(varName); -
162 return !value || !*value;
executed: return !value || !*value;
Execution Count:5152476
5152476
163 -
164} -
165bool qEnvironmentVariableIsSet(const char *varName) -
166{ -
167 -
168 -
169 -
170 -
171 -
172 return ::getenv(varName) != 0;
executed: return ::getenv(varName) != 0;
Execution Count:244
244
173 -
174} -
175bool qputenv(const char *varName, const QByteArray& value) -
176{ -
177 -
178 -
179 -
180 -
181 return setenv(varName, value.constData(), true) == 0;
executed: return setenv(varName, value.constData(), true) == 0;
Execution Count:192
192
182} -
183 -
184 -
185 -
186 -
187 -
188 -
189 -
190typedef uint SeedStorageType; -
191 -
192 -
193typedef QThreadStorage<SeedStorageType *> SeedStorage; -
194static SeedStorage *randTLS() { static QGlobalStatic<SeedStorage > thisGlobalStatic = { { (0) }, false }; if (!thisGlobalStatic.pointer.load() && !thisGlobalStatic.destroyed) { SeedStorage *x = new SeedStorage; if (!thisGlobalStatic.pointer.testAndSetOrdered(0, x)) delete x; else static QGlobalStaticDeleter<SeedStorage > cleanup(thisGlobalStatic); } return thisGlobalStatic.pointer.load(); }
never executed: delete x;
executed: return thisGlobalStatic.pointer.load();
Execution Count:6964240
partially evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:21
evaluated: !thisGlobalStatic.pointer.load()
TRUEFALSE
yes
Evaluation Count:21
yes
Evaluation Count:6964219
partially evaluated: !thisGlobalStatic.destroyed
TRUEFALSE
yes
Evaluation Count:21
no
Evaluation Count:0
0-6964240
195void qsrand(uint seed) -
196{ -
197 -
198 SeedStorage *seedStorage = randTLS(); -
199 if (seedStorage) {
partially evaluated: seedStorage
TRUEFALSE
yes
Evaluation Count:27
no
Evaluation Count:0
0-27
200 SeedStorageType *pseed = seedStorage->localData(); -
201 if (!pseed)
evaluated: !pseed
TRUEFALSE
yes
Evaluation Count:23
yes
Evaluation Count:4
4-23
202 seedStorage->setLocalData(pseed = new SeedStorageType);
executed: seedStorage->setLocalData(pseed = new SeedStorageType);
Execution Count:23
23
203 *pseed = seed; -
204 } else {
executed: }
Execution Count:27
27
205 -
206 -
207 -
208 -
209 srand(seed); -
210 }
never executed: }
0
211 -
212 -
213 -
214 -
215 -
216 -
217} -
218int qrand() -
219{ -
220 -
221 SeedStorage *seedStorage = randTLS(); -
222 if (seedStorage) {
partially evaluated: seedStorage
TRUEFALSE
yes
Evaluation Count:6964213
no
Evaluation Count:0
0-6964213
223 SeedStorageType *pseed = seedStorage->localData(); -
224 if (!pseed) {
evaluated: !pseed
TRUEFALSE
yes
Evaluation Count:536
yes
Evaluation Count:6963677
536-6963677
225 seedStorage->setLocalData(pseed = new SeedStorageType); -
226 *pseed = 1; -
227 }
executed: }
Execution Count:536
536
228 return rand_r(pseed);
executed: return rand_r(pseed);
Execution Count:6964213
6964213
229 } else { -
230 -
231 -
232 -
233 -
234 return rand();
never executed: return rand();
0
235 } -
236 -
237 -
238 -
239 -
240 -
241 -
242} -
243struct QInternal_CallBackTable { -
244 QVector<QList<qInternalCallback> > callbacks; -
245}; -
246 -
247static QInternal_CallBackTable *global_callback_table() { static QGlobalStatic<QInternal_CallBackTable > thisGlobalStatic = { { (0) }, false }; if (!thisGlobalStatic.pointer.load() && !thisGlobalStatic.destroyed) { QInternal_CallBackTable *x = new QInternal_CallBackTable; if (!thisGlobalStatic.pointer.testAndSetOrdered(0, x)) delete x; else static QGlobalStaticDeleter<QInternal_CallBackTable > cleanup(thisGlobalStatic); } return thisGlobalStatic.pointer.load(); }
never executed: delete x;
executed: return thisGlobalStatic.pointer.load();
Execution Count:1194729
partially evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
evaluated: !thisGlobalStatic.pointer.load()
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:1194713
partially evaluated: !thisGlobalStatic.destroyed
TRUEFALSE
yes
Evaluation Count:6
no
Evaluation Count:0
0-1194729
248 -
249bool QInternal::registerCallback(Callback cb, qInternalCallback callback) -
250{ -
251 if (cb >= 0 && cb < QInternal::LastCallback) {
never evaluated: cb >= 0
never evaluated: cb < QInternal::LastCallback
0
252 QInternal_CallBackTable *cbt = global_callback_table(); -
253 cbt->callbacks.resize(cb + 1); -
254 cbt->callbacks[cb].append(callback); -
255 return true;
never executed: return true;
0
256 } -
257 return false;
never executed: return false;
0
258} -
259 -
260bool QInternal::unregisterCallback(Callback cb, qInternalCallback callback) -
261{ -
262 if (cb >= 0 && cb < QInternal::LastCallback) {
never evaluated: cb >= 0
never evaluated: cb < QInternal::LastCallback
0
263 QInternal_CallBackTable *cbt = global_callback_table(); -
264 return (bool) cbt->callbacks[cb].removeAll(callback);
never executed: return (bool) cbt->callbacks[cb].removeAll(callback);
0
265 } -
266 return false;
never executed: return false;
0
267} -
268 -
269bool QInternal::activateCallbacks(Callback cb, void **parameters) -
270{ -
271 qt_noop(); -
272 -
273 QInternal_CallBackTable *cbt = global_callback_table(); -
274 if (cbt && cb < cbt->callbacks.size()) {
partially evaluated: cbt
TRUEFALSE
yes
Evaluation Count:1194735
no
Evaluation Count:0
partially evaluated: cb < cbt->callbacks.size()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1194736
0-1194736
275 QList<qInternalCallback> callbacks = cbt->callbacks[cb]; -
276 bool ret = false; -
277 for (int i=0; i<callbacks.size(); ++i)
never evaluated: i<callbacks.size()
0
278 ret |= (callbacks.at(i))(parameters);
never executed: ret |= (callbacks.at(i))(parameters);
0
279 return ret;
never executed: return ret;
0
280 } -
281 return false;
executed: return false;
Execution Count:1194749
1194749
282} -
283 -
284 -
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial