Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/corelib/global/qglobal.cpp |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
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 | - | |||||||||||||
26 | static_assert(bool(sizeof(int) == 4), "Qt assumes that int is 32 bits"); | - | ||||||||||||
27 | static_assert(bool((127 * 2 + 1) == 255), "Qt assumes that char is 8 bits"); | - | ||||||||||||
28 | static_assert(bool(8 == sizeof(void *)), "QT_POINTER_SIZE defined incorrectly"); | - | ||||||||||||
29 | const char *qVersion() noexcept | - | ||||||||||||
30 | { | - | ||||||||||||
31 | return executed 585 times by 2 tests: "5.67.4"1";return "5.7.1"; Executed by:
executed 585 times by 2 tests: return "5.7.1"; Executed by:
| 585 | ||||||||||||
32 | } | - | ||||||||||||
33 | - | |||||||||||||
34 | bool qSharedBuild() noexcept | - | ||||||||||||
35 | { | - | ||||||||||||
36 | - | |||||||||||||
37 | return never executed: true;return true; never executed: return true; | 0 | ||||||||||||
38 | - | |||||||||||||
39 | - | |||||||||||||
40 | - | |||||||||||||
41 | } | - | ||||||||||||
42 | struct QUnixOSVersion | - | ||||||||||||
43 | { | - | ||||||||||||
44 | - | |||||||||||||
45 | QString productType; | - | ||||||||||||
46 | QString productVersion; | - | ||||||||||||
47 | QString prettyName; | - | ||||||||||||
48 | }; | - | ||||||||||||
49 | - | |||||||||||||
50 | static 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 | } | - | ||||||||||||
58 | static 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 | - | |||||||||||||
77 | static 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 | - | |||||||||||||
118 | static 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 | - | |||||||||||||
124 | static 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 | - | |||||||||||||
155 | static 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 | - | |||||||||||||
166 | static 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 | - | |||||||||||||
186 | static 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 | - | |||||||||||||
201 | static 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 | } | - | ||||||||||||
215 | QString 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 | } | - | ||||||||||||
219 | QString 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 | } | - | ||||||||||||
266 | QString 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 | - | |||||||||||||
279 | static 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 | } | - | ||||||||||||
283 | QString 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 | } | - | ||||||||||||
296 | QString QSysInfo::kernelVersion() | - | ||||||||||||
297 | { | - | ||||||||||||
298 | - | |||||||||||||
299 | - | |||||||||||||
300 | - | |||||||||||||
301 | - | |||||||||||||
302 | - | |||||||||||||
303 | struct utsname u; | - | ||||||||||||
304 | if (uname(&u) == 0
| 0-1 | ||||||||||||
305 | return executed 1 time by 1 test: QString::fromLatin1(u.release);return QString::fromLatin1(u.release); Executed by:
executed 1 time by 1 test: return QString::fromLatin1(u.release); Executed by:
| 1 | ||||||||||||
306 | return never executed: QString();return QString(); never executed: return QString(); | 0 | ||||||||||||
307 | - | |||||||||||||
308 | } | - | ||||||||||||
309 | QString QSysInfo::productType() | - | ||||||||||||
310 | { | - | ||||||||||||
311 | QUnixOSVersion unixOsVersion; | - | ||||||||||||
312 | findUnixOsVersion(unixOsVersion); | - | ||||||||||||
313 | if (!unixOsVersion.productType.isEmpty()
| 0-6 | ||||||||||||
314 | return executed 6 times by 2 tests: unixOsVersion.productType;return unixOsVersion.productType; Executed by:
executed 6 times by 2 tests: return unixOsVersion.productType; Executed by:
| 6 | ||||||||||||
315 | - | |||||||||||||
316 | return never executed: unknownText();return unknownText(); never executed: return unknownText(); | 0 | ||||||||||||
317 | } | - | ||||||||||||
318 | QString QSysInfo::productVersion() | - | ||||||||||||
319 | { | - | ||||||||||||
320 | QUnixOSVersion unixOsVersion; | - | ||||||||||||
321 | findUnixOsVersion(unixOsVersion); | - | ||||||||||||
322 | if (!unixOsVersion.productVersion.isEmpty()
| 0-2 | ||||||||||||
323 | return executed 2 times by 1 test: unixOsVersion.productVersion;return unixOsVersion.productVersion; Executed by:
executed 2 times by 1 test: return unixOsVersion.productVersion; Executed by:
| 2 | ||||||||||||
324 | - | |||||||||||||
325 | - | |||||||||||||
326 | - | |||||||||||||
327 | return never executed: unknownText();return unknownText(); never executed: return unknownText(); | 0 | ||||||||||||
328 | } | - | ||||||||||||
329 | QString QSysInfo::prettyProductName() | - | ||||||||||||
330 | { | - | ||||||||||||
331 | QUnixOSVersion unixOsVersion; | - | ||||||||||||
332 | findUnixOsVersion(unixOsVersion); | - | ||||||||||||
333 | if (!unixOsVersion.prettyName.isEmpty()
| 0-1 | ||||||||||||
334 | return executed 1 time by 1 test: unixOsVersion.prettyName;return unixOsVersion.prettyName; Executed by:
executed 1 time by 1 test: return unixOsVersion.prettyName; Executed by:
| 1 | ||||||||||||
335 | - | |||||||||||||
336 | struct utsname u; | - | ||||||||||||
337 | if (uname(&u) == 0
| 0 | ||||||||||||
338 | return never executed: QString::fromLatin1(u.sysname) + QLatin1Char(' ') + QString::fromLatin1(u.release);return 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: unknownText();return unknownText(); never executed: return unknownText(); | 0 | ||||||||||||
341 | } | - | ||||||||||||
342 | QString 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 | } | - | ||||||||||||
352 | void 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 | - | |||||||||||||
362 | void 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 | - | |||||||||||||
382 | void 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 | - | |||||||||||||
390 | void 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 | - | |||||||||||||
424 | void *qMemCopy(void *dest, const void *src, size_t n) { return memcpy(dest, src, n); } | - | ||||||||||||
425 | void *qMemSet(void *dest, int c, size_t n) { return memset(dest, c, n); } | - | ||||||||||||
426 | - | |||||||||||||
427 | - | |||||||||||||
428 | - | |||||||||||||
429 | namespace { | - | ||||||||||||
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 | - | |||||||||||||
441 | QString 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 | - | |||||||||||||
484 | static QBasicMutex environmentMutex; | - | ||||||||||||
485 | QByteArray qgetenv(const char *varName) | - | ||||||||||||
486 | { | - | ||||||||||||
487 | QMutexLocker locker(&environmentMutex); | - | ||||||||||||
488 | return QByteArray(::getenv(varName)); | - | ||||||||||||
489 | - | |||||||||||||
490 | } | - | ||||||||||||
491 | bool 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: !value || !*value;return !value || !*value; Executed by:
executed 1243771 times by 517 tests: return !value || !*value; Executed by:
| 1243771 | ||||||||||||
496 | - | |||||||||||||
497 | } | - | ||||||||||||
498 | int qEnvironmentVariableIntValue(const char *varName, bool *ok) noexcept | - | ||||||||||||
499 | { | - | ||||||||||||
500 | QMutexLocker locker(&environmentMutex); | - | ||||||||||||
501 | const char * const buffer = ::getenv(varName); | - | ||||||||||||
502 | if (!buffer
| 2-2761 | ||||||||||||
503 | if (ok
| 1260-1503 | ||||||||||||
504 | * executed 1503 times by 503 tests: ok = false;*ok = false; Executed by:
executed 1503 times by 503 tests: *ok = false; Executed by:
| 1503 | ||||||||||||
505 | return executed 2763 times by 507 tests: 0;return 0; Executed by:
executed 2763 times by 507 tests: return 0; Executed by:
| 2763 | ||||||||||||
506 | } | - | ||||||||||||
507 | - | |||||||||||||
508 | bool ok_ = true; | - | ||||||||||||
509 | const qlonglong value = qstrtoll(buffer, nullptr, 0, &ok_); | - | ||||||||||||
510 | if (int(value) != value
| 14-29 | ||||||||||||
511 | if (ok
| 7 | ||||||||||||
512 | * executed 7 times by 1 test: ok = false;*ok = false; Executed by:
executed 7 times by 1 test: *ok = false; Executed by:
| 7 | ||||||||||||
513 | return executed 14 times by 1 test: 0;return 0; Executed by:
executed 14 times by 1 test: return 0; Executed by:
| 14 | ||||||||||||
514 | } else if (ok
| 14-15 | ||||||||||||
515 | *ok = ok_; | - | ||||||||||||
516 | } executed 15 times by 2 tests: end of block Executed by:
| 15 | ||||||||||||
517 | return executed 29 times by 2 tests: int(value);return int(value); Executed by:
executed 29 times by 2 tests: return int(value); Executed by:
| 29 | ||||||||||||
518 | } | - | ||||||||||||
519 | bool qEnvironmentVariableIsSet(const char *varName) noexcept | - | ||||||||||||
520 | { | - | ||||||||||||
521 | QMutexLocker locker(&environmentMutex); | - | ||||||||||||
522 | - | |||||||||||||
523 | - | |||||||||||||
524 | - | |||||||||||||
525 | - | |||||||||||||
526 | - | |||||||||||||
527 | return executed 1985 times by 178 tests: ::getenv(varName) != 0;return ::getenv(varName) != 0; Executed by:
executed 1985 times by 178 tests: return ::getenv(varName) != 0; Executed by:
| 1985 | ||||||||||||
528 | - | |||||||||||||
529 | } | - | ||||||||||||
530 | bool 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 | } | - | ||||||||||||
539 | bool 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 | - | |||||||||||||
555 | typedef uint SeedStorageType; | - | ||||||||||||
556 | - | |||||||||||||
557 | - | |||||||||||||
558 | typedef QThreadStorage<SeedStorageType *> SeedStorage; | - | ||||||||||||
559 | namespace { 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; | - | ||||||||||||
560 | void qsrand(uint seed) | - | ||||||||||||
561 | { | - | ||||||||||||
562 | - | |||||||||||||
563 | SeedStorage *seedStorage = randTLS(); | - | ||||||||||||
564 | if (seedStorage
| 0-30 | ||||||||||||
565 | SeedStorageType *pseed = seedStorage->localData(); | - | ||||||||||||
566 | if (!pseed
| 7-23 | ||||||||||||
567 | seedStorage->setLocalData(pseed = new SeedStorageType); executed 23 times by 2 tests: seedStorage->setLocalData(pseed = new SeedStorageType); Executed by:
| 23 | ||||||||||||
568 | *pseed = seed; | - | ||||||||||||
569 | } executed 30 times by 6 tests: else {end of block Executed by:
| 30 | ||||||||||||
570 | - | |||||||||||||
571 | - | |||||||||||||
572 | - | |||||||||||||
573 | - | |||||||||||||
574 | srand(seed); | - | ||||||||||||
575 | } never executed: end of block | 0 | ||||||||||||
576 | } | - | ||||||||||||
577 | int qrand() | - | ||||||||||||
578 | { | - | ||||||||||||
579 | - | |||||||||||||
580 | SeedStorage *seedStorage = randTLS(); | - | ||||||||||||
581 | if (seedStorage
| 1-20183031 | ||||||||||||
582 | SeedStorageType *pseed = seedStorage->localData(); | - | ||||||||||||
583 | if (!pseed
| 649-20182382 | ||||||||||||
584 | seedStorage->setLocalData(pseed = new SeedStorageType); | - | ||||||||||||
585 | *pseed = 1; | - | ||||||||||||
586 | } executed 649 times by 48 tests: end of block Executed by:
| 649 | ||||||||||||
587 | return executed 20183031 times by 50 tests: rand_r(pseed);return rand_r(pseed); Executed by:
executed 20183031 times by 50 tests: return rand_r(pseed); Executed by:
| 20183031 | ||||||||||||
588 | } else { | - | ||||||||||||
589 | - | |||||||||||||
590 | - | |||||||||||||
591 | - | |||||||||||||
592 | - | |||||||||||||
593 | return executed 1 time by 1 test: rand();return rand(); Executed by:
executed 1 time by 1 test: return rand(); Executed by:
| 1 | ||||||||||||
594 | } | - | ||||||||||||
595 | } | - | ||||||||||||
596 | struct QInternal_CallBackTable { | - | ||||||||||||
597 | QVector<QList<qInternalCallback> > callbacks; | - | ||||||||||||
598 | }; | - | ||||||||||||
599 | - | |||||||||||||
600 | namespace { 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 | - | |||||||||||||
602 | bool 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 | - | |||||||||||||
613 | bool 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 | - | |||||||||||||
622 | bool 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 code | Preprocessed file |