qglobal.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/corelib/global/qglobal.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8-
9-
10-
11-
12-
13-
14-
15-
16-
17-
18__attribute__((visibility("default"))) void *qMemCopy(void *dest, const void *src, size_t n);-
19__attribute__((visibility("default"))) void *qMemSet(void *dest, int c, size_t n);-
20-
21-
22-
23-
24-
25-
26static_assert(bool(sizeof(int) == 4), "Qt assumes that int is 32 bits");-
27static_assert(bool((127 * 2 + 1) == 255), "Qt assumes that char is 8 bits");-
28static_assert(bool(8 == sizeof(void *)), "QT_POINTER_SIZE defined incorrectly");-
29const char *qVersion() noexcept-
30{-
31 return
executed 585 times by 2 tests: return "5.7.1";
Executed by:
  • tst_Lancelot
  • tst_selftests - unknown status
"5.67.4"1";
executed 585 times by 2 tests: return "5.7.1";
Executed by:
  • tst_Lancelot
  • tst_selftests - unknown status
585
32}-
33-
34bool qSharedBuild() noexcept-
35{-
36-
37 return
never executed: return true;
true;
never executed: return true;
0
38-
39-
40-
41}-
42struct QUnixOSVersion-
43{-
44-
45 QString productType;-
46 QString productVersion;-
47 QString prettyName;-
48};-
49-
50static QString unquote(const char *begin, const char *end)-
51{-
52 if (*begin == '"') {-
53 ((!(end[-1] == '"')) ? qt_assert("end[-1] == '\"'",__FILE__,21382217) : qt_noop());-
54 return QString::fromLatin1(begin + 1, end - begin - 2);-
55 }-
56 return QString::fromLatin1(begin, end - begin);-
57}-
58static QByteArray getEtcFileContent(const char *filename)-
59{-
60-
61 int fd = qt_safe_open(filename, 00);-
62 if (fd == -1)-
63 return QByteArray();-
64-
65 struct stat64 sbuf;-
66 if (::fstat64(fd, &sbuf) == -1) {-
67 qt_safe_close(fd);-
68 return QByteArray();-
69 }-
70-
71 QByteArray buffer(sbuf.st_size, Qt::Uninitialized);-
72 buffer.resize(qt_safe_read(fd, buffer.data(), sbuf.st_size));-
73 qt_safe_close(fd);-
74 return buffer;-
75}-
76-
77static bool readEtcFile(QUnixOSVersion &v, const char *filename,-
78 const QByteArray &idKey, const QByteArray &versionKey, const QByteArray &prettyNameKey)-
79{-
80-
81 QByteArray buffer = getEtcFileContent(filename);-
82 if (buffer.isEmpty())-
83 return false;-
84-
85 const char *ptr = buffer.constData();-
86 const char *end = buffer.constEnd();-
87 const char *eol;-
88 QByteArray line;-
89 for ( ; ptr != end; ptr = eol + 1) {-
90-
91 eol = static_cast<const char *>(memchr(ptr, '\n', end - ptr));-
92 if (!eol)-
93 eol = end - 1;-
94 line.setRawData(ptr, eol - ptr);-
95-
96 if (line.startsWith(idKey)) {-
97 ptr += idKey.length();-
98 v.productType = unquote(ptr, eol);-
99 continue;-
100 }-
101-
102 if (line.startsWith(prettyNameKey)) {-
103 ptr += prettyNameKey.length();-
104 v.prettyName = unquote(ptr, eol);-
105 continue;-
106 }-
107-
108 if (line.startsWith(versionKey)) {-
109 ptr += versionKey.length();-
110 v.productVersion = unquote(ptr, eol);-
111 continue;-
112 }-
113 }-
114-
115 return true;-
116}-
117-
118static bool readEtcOsRelease(QUnixOSVersion &v)-
119{-
120 return readEtcFile(v, "/etc/os-release", ([]() -> QByteArray { enum { Size = sizeof("ID=") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "ID=" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }()),-
121 ([]() -> QByteArray { enum { Size = sizeof("VERSION_ID=") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "VERSION_ID=" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }()), ([]() -> QByteArray { enum { Size = sizeof("PRETTY_NAME=") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "PRETTY_NAME=" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }()));-
122}-
123-
124static bool readEtcLsbRelease(QUnixOSVersion &v)-
125{-
126 bool ok = readEtcFile(v, "/etc/lsb-release", ([]() -> QByteArray { enum { Size = sizeof("DISTRIB_ID=") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "DISTRIB_ID=" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }()),-
127 ([]() -> QByteArray { enum { Size = sizeof("DISTRIB_RELEASE=") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "DISTRIB_RELEASE=" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }()), ([]() -> QByteArray { enum { Size = sizeof("DISTRIB_DESCRIPTION=") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "DISTRIB_DESCRIPTION=" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }()));-
128 if (ok && (v.prettyName.isEmpty() || v.prettyName == v.productType)) {-
129-
130-
131-
132-
133 QByteArray distrorelease = "/etc/" + v.productType.toLatin1().toLower() + "-release";-
134 int fd = qt_safe_open(distrorelease, 00);-
135 if (fd != -1) {-
136 struct stat64 sbuf;-
137 if (::fstat64(fd, &sbuf) != -1 && sbuf.st_size > v.prettyName.length()) {-
138-
139 QByteArray buffer(sbuf.st_size, Qt::Uninitialized);-
140 buffer.resize(qt_safe_read(fd, buffer.data(), sbuf.st_size));-
141 v.prettyName = QString::fromLatin1(buffer.trimmed());-
142 }-
143 qt_safe_close(fd);-
144 }-
145 }-
146-
147-
148-
149-
150-
151 return ok && !(v.productType.isEmpty() && v.productVersion.isEmpty());-
152}-
153-
154-
155static QByteArray getEtcFileFirstLine(const char *fileName)-
156{-
157 QByteArray buffer = getEtcFileContent(fileName);-
158 if (buffer.isEmpty())-
159 return QByteArray();-
160-
161 const char *ptr = buffer.constData();-
162 int eol = buffer.indexOf("\n");-
163 return QByteArray(ptr, eol).trimmed();-
164}-
165-
166static bool readEtcRedHatRelease(QUnixOSVersion &v)-
167{-
168-
169-
170-
171 QByteArray line = getEtcFileFirstLine("/etc/redhat-release");-
172 if (line.isEmpty())-
173 return false;-
174-
175 v.prettyName = QString::fromLatin1(line);-
176-
177 const char keyword[] = "release ";-
178 int releaseIndex = line.indexOf(keyword);-
179 v.productType = QString::fromLatin1(line.mid(0, releaseIndex)).remove(QLatin1Char(' '));-
180 int spaceIndex = line.indexOf(' ', releaseIndex + strlen(keyword));-
181 v.productVersion = QString::fromLatin1(line.mid(releaseIndex + strlen(keyword),-
182 spaceIndex > -1 ? spaceIndex - releaseIndex - int(strlen(keyword)) : -1));-
183 return true;-
184}-
185-
186static bool readEtcDebianVersion(QUnixOSVersion &v)-
187{-
188-
189-
190-
191 QByteArray line = getEtcFileFirstLine("/etc/debian_version");-
192 if (line.isEmpty())-
193 return false;-
194-
195 v.productType = ([]() -> QString { enum { Size = sizeof(u"" "Debian")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "Debian" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());-
196 v.productVersion = QString::fromLatin1(line);-
197 return true;-
198}-
199-
200-
201static bool findUnixOsVersion(QUnixOSVersion &v)-
202{-
203 if (readEtcOsRelease(v))-
204 return true;-
205 if (readEtcLsbRelease(v))-
206 return true;-
207-
208 if (readEtcRedHatRelease(v))-
209 return true;-
210 if (readEtcDebianVersion(v))-
211 return true;-
212-
213 return false;-
214}-
215QString QSysInfo::buildCpuArchitecture()-
216{-
217 return ([]() -> QString { enum { Size = sizeof(u"" "x86_64")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "x86_64" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());-
218}-
219QString QSysInfo::currentCpuArchitecture()-
220{-
221 long ret = -1;-
222 struct utsname u;-
223 if (ret == -1)-
224 ret = uname(&u);-
225-
226-
227 if (ret != -1) {-
228-
229-
230-
231 if (strcmp(u.machine, "aarch64") == 0)-
232 return ([]() -> QString { enum { Size = sizeof(u"" "arm64")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "arm64" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());-
233 if (strncmp(u.machine, "armv", 4) == 0)-
234 return ([]() -> QString { enum { Size = sizeof(u"" "arm")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "arm" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());-
235-
236-
237-
238 if (strncmp(u.machine, "ppc", 3) == 0)-
239 return QLatin1String("power") + QLatin1String(u.machine + 3);-
240 if (strncmp(u.machine, "powerpc", 7) == 0)-
241 return QLatin1String("power") + QLatin1String(u.machine + 7);-
242 if (strcmp(u.machine, "Power Macintosh") == 0)-
243 return QLatin1String("power");-
244-
245-
246-
247-
248 if (strcmp(u.machine, "sun4u") == 0 || strcmp(u.machine, "sparc64") == 0)-
249 return ([]() -> QString { enum { Size = sizeof(u"" "sparcv9")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "sparcv9" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());-
250 if (strcmp(u.machine, "sparc32") == 0)-
251 return ([]() -> QString { enum { Size = sizeof(u"" "sparc")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "sparc" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());-
252-
253-
254-
255 if (strlen(u.machine) == 4 && u.machine[0] == 'i'-
256 && u.machine[2] == '8' && u.machine[3] == '6')-
257 return ([]() -> QString { enum { Size = sizeof(u"" "i386")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "i386" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());-
258 if (strcmp(u.machine, "amd64") == 0)-
259 return ([]() -> QString { enum { Size = sizeof(u"" "x86_64")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "x86_64" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());-
260-
261 return QString::fromLatin1(u.machine);-
262 }-
263-
264 return buildCpuArchitecture();-
265}-
266QString QSysInfo::buildAbi()-
267{-
268-
269-
270-
271-
272-
273 return ([]() -> QString { enum { Size = sizeof(u"" "x86_64" "-" "little_endian" "-" "lp64" "" "" "")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "x86_64" "-" "little_endian" "-" "lp64" "" "" "" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());-
274-
275-
276-
277}-
278-
279static QString unknownText()-
280{-
281 return ([]() -> QString { enum { Size = sizeof(u"" "unknown")/2 - 1 }; static const QStaticStringData<Size> qstring_literal = { { { { -1 } }, Size, 0, 0, sizeof(QStringData) }, u"" "unknown" }; QStringDataPtr holder = { qstring_literal.data_ptr() }; const QString qstring_literal_temp(holder); return qstring_literal_temp; }());-
282}-
283QString QSysInfo::kernelType()-
284{-
285-
286-
287-
288-
289-
290 struct utsname u;-
291 if (uname(&u) == 0)-
292 return QString::fromLatin1(u.sysname).toLower();-
293-
294 return unknownText();-
295}-
296QString QSysInfo::kernelVersion()-
297{-
298-
299-
300-
301-
302-
303 struct utsname u;-
304 if (uname(&u) == 0
uname(&u) == 0Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QOpenGlConfig
FALSEnever evaluated
)
0-1
305 return
executed 1 time by 1 test: return QString::fromLatin1(u.release);
Executed by:
  • tst_QOpenGlConfig
QString::fromLatin1(u.release);
executed 1 time by 1 test: return QString::fromLatin1(u.release);
Executed by:
  • tst_QOpenGlConfig
1
306 return
never executed: return QString();
QString();
never executed: return QString();
0
307-
308}-
309QString QSysInfo::productType()-
310{-
311 QUnixOSVersion unixOsVersion;-
312 findUnixOsVersion(unixOsVersion);-
313 if (!unixOsVersion.productType.isEmpty()
!unixOsVersion...Type.isEmpty()Description
TRUEevaluated 6 times by 2 tests
Evaluated by:
  • tst_QFileSelector
  • tst_selftests - unknown status
FALSEnever evaluated
)
0-6
314 return
executed 6 times by 2 tests: return unixOsVersion.productType;
Executed by:
  • tst_QFileSelector
  • tst_selftests - unknown status
unixOsVersion.productType;
executed 6 times by 2 tests: return unixOsVersion.productType;
Executed by:
  • tst_QFileSelector
  • tst_selftests - unknown status
6
315-
316 return
never executed: return unknownText();
unknownText();
never executed: return unknownText();
0
317}-
318QString QSysInfo::productVersion()-
319{-
320 QUnixOSVersion unixOsVersion;-
321 findUnixOsVersion(unixOsVersion);-
322 if (!unixOsVersion.productVersion.isEmpty()
!unixOsVersion...sion.isEmpty()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_selftests - unknown status
FALSEnever evaluated
)
0-2
323 return
executed 2 times by 1 test: return unixOsVersion.productVersion;
Executed by:
  • tst_selftests - unknown status
unixOsVersion.productVersion;
executed 2 times by 1 test: return unixOsVersion.productVersion;
Executed by:
  • tst_selftests - unknown status
2
324-
325-
326-
327 return
never executed: return unknownText();
unknownText();
never executed: return unknownText();
0
328}-
329QString QSysInfo::prettyProductName()-
330{-
331 QUnixOSVersion unixOsVersion;-
332 findUnixOsVersion(unixOsVersion);-
333 if (!unixOsVersion.prettyName.isEmpty()
!unixOsVersion...Name.isEmpty()Description
TRUEevaluated 1 time by 1 test
Evaluated by:
  • tst_QOpenGlConfig
FALSEnever evaluated
)
0-1
334 return
executed 1 time by 1 test: return unixOsVersion.prettyName;
Executed by:
  • tst_QOpenGlConfig
unixOsVersion.prettyName;
executed 1 time by 1 test: return unixOsVersion.prettyName;
Executed by:
  • tst_QOpenGlConfig
1
335-
336 struct utsname u;-
337 if (uname(&u) == 0
uname(&u) == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
338 return
never executed: return QString::fromLatin1(u.sysname) + QLatin1Char(' ') + QString::fromLatin1(u.release);
QString::fromLatin1(u.sysname) + QLatin1Char(' ') + QString::fromLatin1(u.release);
never executed: return QString::fromLatin1(u.sysname) + QLatin1Char(' ') + QString::fromLatin1(u.release);
0
339-
340 return
never executed: return unknownText();
unknownText();
never executed: return unknownText();
0
341}-
342QString QSysInfo::machineHostName()-
343{-
344-
345-
346-
347 struct utsname u;-
348 if (uname(&u) == 0)-
349 return QString::fromLocal8Bit(u.nodename);-
350 return QString();-
351}-
352void qt_check_pointer(const char *n, int l)-
353{-
354 QMessageLogger(__FILE__, 29883051, __PRETTY_FUNCTION__).fatal("In file %s, line %d: Out of memory", n, l);-
355}-
356-
357-
358-
359-
360-
361-
362void qBadAlloc()-
363{-
364 throw std::bad_alloc();-
365}-
366-
367-
368-
369-
370-
371-
372-
373__attribute__((__noreturn__)) void qTerminate() noexcept-
374{-
375 std::terminate();-
376}
never executed: end of block
0
377-
378-
379-
380-
381-
382void qt_assert(const char *assertion, const char *file, int line) noexcept-
383{-
384 QMessageLogger(__FILE__, 30183081, __PRETTY_FUNCTION__).fatal("ASSERT: \"%s\" in file %s, line %d", assertion, file, line);-
385}
never executed: end of block
0
386-
387-
388-
389-
390void qt_assert_x(const char *where, const char *what, const char *file, int line) noexcept-
391{-
392 QMessageLogger(__FILE__, 30263089, __PRETTY_FUNCTION__).fatal("ASSERT failure in %s: \"%s\", file %s, line %d", where, what, file, line);-
393}
never executed: end of block
0
394-
395-
396-
397-
398-
399-
400-
401__attribute__((visibility("default"))) unsigned int qt_int_sqrt(unsigned int n)-
402{-
403-
404 if (n >= ((2147483647 * 2U + 1U)>>2)) {-
405 unsigned int r = 2 * qt_int_sqrt(n / 4);-
406 unsigned int r2 = r + 1;-
407 return (n >= r2 * r2) ? r2 : r;-
408 }-
409 uint h, p= 0, q= 1, r= n;-
410 while (q <= n)-
411 q <<= 2;-
412 while (q != 1) {-
413 q >>= 2;-
414 h= p + q;-
415 p >>= 1;-
416 if (r >= h) {-
417 p += q;-
418 r -= h;-
419 }-
420 }-
421 return p;-
422}-
423-
424void *qMemCopy(void *dest, const void *src, size_t n) { return memcpy(dest, src, n); }-
425void *qMemSet(void *dest, int c, size_t n) { return memset(dest, c, n); }-
426-
427-
428-
429namespace {-
430 static inline __attribute__((__unused__)) QString fromstrerror_helper(int, const QByteArray &buf)-
431 {-
432 return QString::fromLocal8Bit(buf.constData());-
433 }-
434 static inline __attribute__((__unused__)) QString fromstrerror_helper(const char *str, const QByteArray &)-
435 {-
436 return QString::fromLocal8Bit(str);-
437 }-
438}-
439-
440-
441QString qt_error_string(int errorCode)-
442{-
443 const char *s = 0;-
444 QString ret;-
445 if (errorCode == -1) {-
446-
447-
448-
449 errorCode = (*__errno_location ());-
450-
451 }-
452 switch (errorCode) {-
453 case 0:-
454 break;-
455 case 13:-
456 s = "Permission denied";-
457 break;-
458 case 24:-
459 s = "Too many open files";-
460 break;-
461 case 2:-
462 s = "No such file or directory";-
463 break;-
464 case 28:-
465 s = "No space left on device";-
466 break;-
467 default: {-
468 QByteArray buf(1024, '\0');-
469 ret = fromstrerror_helper(strerror_r(errorCode, buf.data(), buf.size()), buf);-
470-
471-
472-
473 break; }-
474 }-
475 if (s)-
476-
477-
478 ret = QString::fromLatin1(s);-
479 return ret.trimmed();-
480}-
481-
482-
483-
484static QBasicMutex environmentMutex;-
485QByteArray qgetenv(const char *varName)-
486{-
487 QMutexLocker locker(&environmentMutex);-
488 return QByteArray(::getenv(varName));-
489-
490}-
491bool qEnvironmentVariableIsEmpty(const char *varName) noexcept-
492{-
493 QMutexLocker locker(&environmentMutex);-
494 const char * const value = ::getenv(varName);-
495 return
executed 1243771 times by 517 tests: return !value || !*value;
Executed by:
  • tst_Collections
  • tst_Compiler
  • tst_Gestures
  • tst_Lancelot
  • tst_LargeFile
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractAnimation
  • tst_QAbstractButton
  • tst_QAbstractFileEngine
  • tst_QAbstractItemModel
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractProxyModel
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSocket
  • tst_QAbstractSpinBox
  • tst_QAbstractTextDocumentLayout
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QAlgorithms
  • ...
!value || !*value;
executed 1243771 times by 517 tests: return !value || !*value;
Executed by:
  • tst_Collections
  • tst_Compiler
  • tst_Gestures
  • tst_Lancelot
  • tst_LargeFile
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractAnimation
  • tst_QAbstractButton
  • tst_QAbstractFileEngine
  • tst_QAbstractItemModel
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractProxyModel
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSocket
  • tst_QAbstractSpinBox
  • tst_QAbstractTextDocumentLayout
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QAlgorithms
  • ...
1243771
496-
497}-
498int qEnvironmentVariableIntValue(const char *varName, bool *ok) noexcept-
499{-
500 QMutexLocker locker(&environmentMutex);-
501 const char * const buffer = ::getenv(varName);-
502 if (!buffer
!bufferDescription
TRUEevaluated 2761 times by 507 tests
Evaluated by:
  • tst_Collections
  • tst_Compiler
  • tst_Gestures
  • tst_LargeFile
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractAnimation
  • tst_QAbstractButton
  • tst_QAbstractFileEngine
  • tst_QAbstractItemModel
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractProxyModel
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSocket
  • tst_QAbstractSpinBox
  • tst_QAbstractTextDocumentLayout
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QAlgorithms
  • tst_QAnimationGroup
  • ...
FALSEevaluated 45 times by 2 tests
Evaluated by:
  • tst_QGestureRecognizer
  • tst_QGetPutEnv
|| !*buffer
!*bufferDescription
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QGetPutEnv
FALSEevaluated 43 times by 2 tests
Evaluated by:
  • tst_QGestureRecognizer
  • tst_QGetPutEnv
) {
2-2761
503 if (ok
okDescription
TRUEevaluated 1503 times by 503 tests
Evaluated by:
  • tst_Collections
  • tst_Compiler
  • tst_Gestures
  • tst_LargeFile
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractAnimation
  • tst_QAbstractButton
  • tst_QAbstractFileEngine
  • tst_QAbstractItemModel
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractProxyModel
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSocket
  • tst_QAbstractSpinBox
  • tst_QAbstractTextDocumentLayout
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QAlgorithms
  • tst_QAnimationGroup
  • ...
FALSEevaluated 1260 times by 196 tests
Evaluated by:
  • tst_Gestures
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QApplication
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QCheckBox
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDBusAbstractAdaptor
  • ...
)
1260-1503
504 *
executed 1503 times by 503 tests: *ok = false;
Executed by:
  • tst_Collections
  • tst_Compiler
  • tst_Gestures
  • tst_LargeFile
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractAnimation
  • tst_QAbstractButton
  • tst_QAbstractFileEngine
  • tst_QAbstractItemModel
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractProxyModel
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSocket
  • tst_QAbstractSpinBox
  • tst_QAbstractTextDocumentLayout
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QAlgorithms
  • tst_QAnimationGroup
  • ...
ok = false;
executed 1503 times by 503 tests: *ok = false;
Executed by:
  • tst_Collections
  • tst_Compiler
  • tst_Gestures
  • tst_LargeFile
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractAnimation
  • tst_QAbstractButton
  • tst_QAbstractFileEngine
  • tst_QAbstractItemModel
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractProxyModel
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSocket
  • tst_QAbstractSpinBox
  • tst_QAbstractTextDocumentLayout
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QAlgorithms
  • tst_QAnimationGroup
  • ...
1503
505 return
executed 2763 times by 507 tests: return 0;
Executed by:
  • tst_Collections
  • tst_Compiler
  • tst_Gestures
  • tst_LargeFile
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractAnimation
  • tst_QAbstractButton
  • tst_QAbstractFileEngine
  • tst_QAbstractItemModel
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractProxyModel
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSocket
  • tst_QAbstractSpinBox
  • tst_QAbstractTextDocumentLayout
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QAlgorithms
  • tst_QAnimationGroup
  • ...
0;
executed 2763 times by 507 tests: return 0;
Executed by:
  • tst_Collections
  • tst_Compiler
  • tst_Gestures
  • tst_LargeFile
  • tst_ModelTest
  • tst_NetworkSelfTest
  • tst_PlatformSocketEngine
  • tst_QAbstractAnimation
  • tst_QAbstractButton
  • tst_QAbstractFileEngine
  • tst_QAbstractItemModel
  • tst_QAbstractItemView
  • tst_QAbstractNetworkCache
  • tst_QAbstractPrintDialog
  • tst_QAbstractProxyModel
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSocket
  • tst_QAbstractSpinBox
  • tst_QAbstractTextDocumentLayout
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QAlgorithms
  • tst_QAnimationGroup
  • ...
2763
506 }-
507-
508 bool ok_ = true;-
509 const qlonglong value = qstrtoll(buffer, nullptr, 0, &ok_);-
510 if (int(value) != value
int(value) != valueDescription
TRUEevaluated 14 times by 1 test
Evaluated by:
  • tst_QGetPutEnv
FALSEevaluated 29 times by 2 tests
Evaluated by:
  • tst_QGestureRecognizer
  • tst_QGetPutEnv
) {
14-29
511 if (ok
okDescription
TRUEevaluated 7 times by 1 test
Evaluated by:
  • tst_QGetPutEnv
FALSEevaluated 7 times by 1 test
Evaluated by:
  • tst_QGetPutEnv
)
7
512 *
executed 7 times by 1 test: *ok = false;
Executed by:
  • tst_QGetPutEnv
ok = false;
executed 7 times by 1 test: *ok = false;
Executed by:
  • tst_QGetPutEnv
7
513 return
executed 14 times by 1 test: return 0;
Executed by:
  • tst_QGetPutEnv
0;
executed 14 times by 1 test: return 0;
Executed by:
  • tst_QGetPutEnv
14
514 } else if (ok
okDescription
TRUEevaluated 15 times by 2 tests
Evaluated by:
  • tst_QGestureRecognizer
  • tst_QGetPutEnv
FALSEevaluated 14 times by 1 test
Evaluated by:
  • tst_QGetPutEnv
) {
14-15
515 *ok = ok_;-
516 }
executed 15 times by 2 tests: end of block
Executed by:
  • tst_QGestureRecognizer
  • tst_QGetPutEnv
15
517 return
executed 29 times by 2 tests: return int(value);
Executed by:
  • tst_QGestureRecognizer
  • tst_QGetPutEnv
int(value);
executed 29 times by 2 tests: return int(value);
Executed by:
  • tst_QGestureRecognizer
  • tst_QGetPutEnv
29
518}-
519bool qEnvironmentVariableIsSet(const char *varName) noexcept-
520{-
521 QMutexLocker locker(&environmentMutex);-
522-
523-
524-
525-
526-
527 return
executed 1985 times by 178 tests: return ::getenv(varName) != 0;
Executed by:
  • tst_Gestures
  • tst_ModelTest
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QApplication
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QCheckBox
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDBusXmlParser
  • tst_QDataWidgetMapper
  • tst_QDateTimeEdit
  • ...
::getenv(varName) != 0;
executed 1985 times by 178 tests: return ::getenv(varName) != 0;
Executed by:
  • tst_Gestures
  • tst_ModelTest
  • tst_QAbstractButton
  • tst_QAbstractItemView
  • tst_QAbstractPrintDialog
  • tst_QAbstractScrollArea
  • tst_QAbstractSlider
  • tst_QAbstractSpinBox
  • tst_QAccessibility
  • tst_QAction
  • tst_QActionGroup
  • tst_QApplication
  • tst_QBackingStore
  • tst_QBoxLayout
  • tst_QButtonGroup
  • tst_QCalendarWidget
  • tst_QCheckBox
  • tst_QColorDialog
  • tst_QColumnView
  • tst_QComboBox
  • tst_QCommandLinkButton
  • tst_QCompleter
  • tst_QDBusXmlParser
  • tst_QDataWidgetMapper
  • tst_QDateTimeEdit
  • ...
1985
528-
529}-
530bool qputenv(const char *varName, const QByteArray& value)-
531{-
532 QMutexLocker locker(&environmentMutex);-
533-
534-
535-
536-
537 return setenv(varName, value.constData(), true) == 0;-
538}-
539bool qunsetenv(const char *varName)-
540{-
541 QMutexLocker locker(&environmentMutex);-
542-
543-
544-
545-
546 return unsetenv(varName) == 0;-
547}-
548-
549-
550-
551-
552-
553-
554-
555typedef uint SeedStorageType;-
556-
557-
558typedef QThreadStorage<SeedStorageType *> SeedStorage;-
559namespace { namespace Q_QGS_randTLS { typedef SeedStorage Type; QBasicAtomicInt guard = { QtGlobalStatic::Uninitialized }; __attribute__((visibility("hidden"))) inline Type *innerFunction() { struct HolderBase { ~HolderBase() noexcept { if (guard.load() == QtGlobalStatic::Initialized) guard.store(QtGlobalStatic::Destroyed); } }; static struct Holder : public HolderBase { Type value; Holder() noexcept(noexcept(Type ())) : value () { guard.store(QtGlobalStatic::Initialized); } } holder; return &holder.value; } } } static QGlobalStatic<SeedStorage, Q_QGS_randTLS::innerFunction, Q_QGS_randTLS::guard> randTLS;-
560void qsrand(uint seed)-
561{-
562-
563 SeedStorage *seedStorage = randTLS();-
564 if (seedStorage
seedStorageDescription
TRUEevaluated 30 times by 6 tests
Evaluated by:
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QNetworkReply
  • tst_QRand
  • tst_QTemporaryFile
  • tst_Spdy
FALSEnever evaluated
) {
0-30
565 SeedStorageType *pseed = seedStorage->localData();-
566 if (!pseed
!pseedDescription
TRUEevaluated 23 times by 2 tests
Evaluated by:
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
FALSEevaluated 7 times by 4 tests
Evaluated by:
  • tst_QNetworkReply
  • tst_QRand
  • tst_QTemporaryFile
  • tst_Spdy
)
7-23
567 seedStorage->setLocalData(pseed = new SeedStorageType);
executed 23 times by 2 tests: seedStorage->setLocalData(pseed = new SeedStorageType);
Executed by:
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
23
568 *pseed = seed;-
569 }
executed 30 times by 6 tests: end of block
Executed by:
  • tst_QDnsLookup
  • tst_QDnsLookup_Appless
  • tst_QNetworkReply
  • tst_QRand
  • tst_QTemporaryFile
  • tst_Spdy
else {
30
570-
571-
572-
573-
574 srand(seed);-
575 }
never executed: end of block
0
576}-
577int qrand()-
578{-
579-
580 SeedStorage *seedStorage = randTLS();-
581 if (seedStorage
seedStorageDescription
TRUEevaluated 20183031 times by 50 tests
Evaluated by:
  • tst_Compiler
  • tst_LargeFile
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QAlgorithms
  • tst_QAuthenticator
  • tst_QColorDialog
  • tst_QDBusMarshall
  • tst_QDir
  • tst_QDnsLookup
  • tst_QFile
  • tst_QFileDialog2
  • tst_QFileInfo
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QFuture
  • tst_QGraphicsItem
  • tst_QGraphicsProxyWidget
  • tst_QGraphicsScene
  • tst_QHttpNetworkConnection
  • tst_QHttpSocketEngine
  • tst_QIcon
  • tst_QImage
  • tst_QImageReader
  • ...
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_qlockfile - unknown status
) {
1-20183031
582 SeedStorageType *pseed = seedStorage->localData();-
583 if (!pseed
!pseedDescription
TRUEevaluated 649 times by 48 tests
Evaluated by:
  • tst_Compiler
  • tst_LargeFile
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QAlgorithms
  • tst_QAuthenticator
  • tst_QColorDialog
  • tst_QDBusMarshall
  • tst_QDir
  • tst_QFile
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QFuture
  • tst_QGraphicsItem
  • tst_QGraphicsProxyWidget
  • tst_QGraphicsScene
  • tst_QHttpNetworkConnection
  • tst_QHttpSocketEngine
  • tst_QIcon
  • tst_QImage
  • tst_QImageReader
  • tst_QImageWriter
  • tst_QLockFile
  • ...
FALSEevaluated 20182382 times by 44 tests
Evaluated by:
  • tst_Compiler
  • tst_LargeFile
  • tst_QAbstractNetworkCache
  • tst_QAlgorithms
  • tst_QAuthenticator
  • tst_QColorDialog
  • tst_QDir
  • tst_QDnsLookup
  • tst_QFile
  • tst_QFileDialog2
  • tst_QFileInfo
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QGraphicsItem
  • tst_QGraphicsProxyWidget
  • tst_QGraphicsScene
  • tst_QHttpNetworkConnection
  • tst_QHttpSocketEngine
  • tst_QIcon
  • tst_QImage
  • tst_QImageReader
  • tst_QImageWriter
  • tst_QMimeDatabase
  • tst_QNetworkAccessManager_And_QProgressDialog
  • ...
) {
649-20182382
584 seedStorage->setLocalData(pseed = new SeedStorageType);-
585 *pseed = 1;-
586 }
executed 649 times by 48 tests: end of block
Executed by:
  • tst_Compiler
  • tst_LargeFile
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QAlgorithms
  • tst_QAuthenticator
  • tst_QColorDialog
  • tst_QDBusMarshall
  • tst_QDir
  • tst_QFile
  • tst_QFileDialog2
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QFuture
  • tst_QGraphicsItem
  • tst_QGraphicsProxyWidget
  • tst_QGraphicsScene
  • tst_QHttpNetworkConnection
  • tst_QHttpSocketEngine
  • tst_QIcon
  • tst_QImage
  • tst_QImageReader
  • tst_QImageWriter
  • tst_QLockFile
  • ...
649
587 return
executed 20183031 times by 50 tests: return rand_r(pseed);
Executed by:
  • tst_Compiler
  • tst_LargeFile
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QAlgorithms
  • tst_QAuthenticator
  • tst_QColorDialog
  • tst_QDBusMarshall
  • tst_QDir
  • tst_QDnsLookup
  • tst_QFile
  • tst_QFileDialog2
  • tst_QFileInfo
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QFuture
  • tst_QGraphicsItem
  • tst_QGraphicsProxyWidget
  • tst_QGraphicsScene
  • tst_QHttpNetworkConnection
  • tst_QHttpSocketEngine
  • tst_QIcon
  • tst_QImage
  • tst_QImageReader
  • ...
rand_r(pseed);
executed 20183031 times by 50 tests: return rand_r(pseed);
Executed by:
  • tst_Compiler
  • tst_LargeFile
  • tst_NetworkSelfTest
  • tst_QAbstractNetworkCache
  • tst_QAlgorithms
  • tst_QAuthenticator
  • tst_QColorDialog
  • tst_QDBusMarshall
  • tst_QDir
  • tst_QDnsLookup
  • tst_QFile
  • tst_QFileDialog2
  • tst_QFileInfo
  • tst_QFileSystemModel
  • tst_QFileSystemWatcher
  • tst_QFiledialog
  • tst_QFuture
  • tst_QGraphicsItem
  • tst_QGraphicsProxyWidget
  • tst_QGraphicsScene
  • tst_QHttpNetworkConnection
  • tst_QHttpSocketEngine
  • tst_QIcon
  • tst_QImage
  • tst_QImageReader
  • ...
20183031
588 } else {-
589-
590-
591-
592-
593 return
executed 1 time by 1 test: return rand();
Executed by:
  • tst_qlockfile - unknown status
rand();
executed 1 time by 1 test: return rand();
Executed by:
  • tst_qlockfile - unknown status
1
594 }-
595}-
596struct QInternal_CallBackTable {-
597 QVector<QList<qInternalCallback> > callbacks;-
598};-
599-
600namespace { namespace Q_QGS_global_callback_table { typedef QInternal_CallBackTable Type; QBasicAtomicInt guard = { QtGlobalStatic::Uninitialized }; __attribute__((visibility("hidden"))) inline Type *innerFunction() { struct HolderBase { ~HolderBase() noexcept { if (guard.load() == QtGlobalStatic::Initialized) guard.store(QtGlobalStatic::Destroyed); } }; static struct Holder : public HolderBase { Type value; Holder() noexcept(noexcept(Type ())) : value () { guard.store(QtGlobalStatic::Initialized); } } holder; return &holder.value; } } } static QGlobalStatic<QInternal_CallBackTable, Q_QGS_global_callback_table::innerFunction, Q_QGS_global_callback_table::guard> global_callback_table;-
601-
602bool QInternal::registerCallback(Callback cb, qInternalCallback callback)-
603{-
604 if (cb >= 0 && cb < QInternal::LastCallback) {-
605 QInternal_CallBackTable *cbt = global_callback_table();-
606 cbt->callbacks.resize(cb + 1);-
607 cbt->callbacks[cb].append(callback);-
608 return true;-
609 }-
610 return false;-
611}-
612-
613bool QInternal::unregisterCallback(Callback cb, qInternalCallback callback)-
614{-
615 if (cb >= 0 && cb < QInternal::LastCallback) {-
616 QInternal_CallBackTable *cbt = global_callback_table();-
617 return (bool) cbt->callbacks[cb].removeAll(callback);-
618 }-
619 return false;-
620}-
621-
622bool QInternal::activateCallbacks(Callback cb, void **parameters)-
623{-
624 ((!(cb >= 0)) ? qt_assert_x("QInternal::activateCallback()", "Callback id must be a valid id",__FILE__,38734032) : qt_noop());-
625-
626 QInternal_CallBackTable *cbt = global_callback_table();-
627 if (cbt && cb < cbt->callbacks.size()) {-
628 QList<qInternalCallback> callbacks = cbt->callbacks[cb];-
629 bool ret = false;-
630 for (int i=0; i<callbacks.size(); ++i)-
631 ret |= (callbacks.at(i))(parameters);-
632 return ret;-
633 }-
634 return false;-
635}-
636-
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9