1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2016 The Qt Company Ltd. |
4 | ** Copyright (C) 2016 Intel Corporation. |
5 | ** Contact: https://www.qt.io/licensing/ |
6 | ** |
7 | ** This file is part of the QtCore module of the Qt Toolkit. |
8 | ** |
9 | ** $QT_BEGIN_LICENSE:LGPL$ |
10 | ** Commercial License Usage |
11 | ** Licensees holding valid commercial Qt licenses may use this file in |
12 | ** accordance with the commercial license agreement provided with the |
13 | ** Software or, alternatively, in accordance with the terms contained in |
14 | ** a written agreement between you and The Qt Company. For licensing terms |
15 | ** and conditions see https://www.qt.io/terms-conditions. For further |
16 | ** information use the contact form at https://www.qt.io/contact-us. |
17 | ** |
18 | ** GNU Lesser General Public License Usage |
19 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
20 | ** General Public License version 3 as published by the Free Software |
21 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the |
22 | ** packaging of this file. Please review the following information to |
23 | ** ensure the GNU Lesser General Public License version 3 requirements |
24 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. |
25 | ** |
26 | ** GNU General Public License Usage |
27 | ** Alternatively, this file may be used under the terms of the GNU |
28 | ** General Public License version 2.0 or (at your option) the GNU General |
29 | ** Public license version 3 or any later version approved by the KDE Free |
30 | ** Qt Foundation. The licenses are as published by the Free Software |
31 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 |
32 | ** included in the packaging of this file. Please review the following |
33 | ** information to ensure the GNU General Public License requirements will |
34 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and |
35 | ** https://www.gnu.org/licenses/gpl-3.0.html. |
36 | ** |
37 | ** $QT_END_LICENSE$ |
38 | ** |
39 | ****************************************************************************/ |
40 | |
41 | #include <QtCore/qglobal.h> |
42 | |
43 | #ifndef QSYSINFO_H |
44 | #define QSYSINFO_H |
45 | |
46 | QT_BEGIN_NAMESPACE |
47 | |
48 | /* |
49 | System information |
50 | */ |
51 | |
52 | /* |
53 | * GCC (5-7) has a regression that causes it to emit wrong deprecated warnings: |
54 | * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77849 |
55 | * |
56 | * Try to work around it by defining our own macro. |
57 | */ |
58 | |
59 | #ifdef QT_SYSINFO_DEPRECATED_X |
60 | #error "QT_SYSINFO_DEPRECATED_X already defined" |
61 | #endif |
62 | |
63 | #ifdef Q_CC_GNU |
64 | #define QT_SYSINFO_DEPRECATED_X(x) |
65 | #else |
66 | #define QT_SYSINFO_DEPRECATED_X(x) QT_DEPRECATED_X(x) |
67 | #endif |
68 | |
69 | class QString; |
70 | class Q_CORE_EXPORT QSysInfo { |
71 | public: |
72 | enum Sizes { |
73 | WordSize = (sizeof(void *)<<3) |
74 | }; |
75 | |
76 | #if defined(QT_BUILD_QMAKE) |
77 | enum Endian { |
78 | BigEndian, |
79 | LittleEndian |
80 | }; |
81 | /* needed to bootstrap qmake */ |
82 | static const int ByteOrder; |
83 | #elif defined(Q_BYTE_ORDER) |
84 | enum Endian { |
85 | BigEndian, |
86 | LittleEndian |
87 | |
88 | # ifdef Q_QDOC |
89 | , ByteOrder = BigEndian or LittleEndian |
90 | # elif Q_BYTE_ORDER == Q_BIG_ENDIAN |
91 | , ByteOrder = BigEndian |
92 | # elif Q_BYTE_ORDER == Q_LITTLE_ENDIAN |
93 | , ByteOrder = LittleEndian |
94 | # else |
95 | # error "Undefined byte order" |
96 | # endif |
97 | }; |
98 | #endif |
99 | #if QT_DEPRECATED_SINCE(5, 9) |
100 | enum QT_DEPRECATED_X("Use QOperatingSystemVersion" ) WinVersion { |
101 | WV_None = 0x0000, |
102 | |
103 | WV_32s = 0x0001, |
104 | WV_95 = 0x0002, |
105 | WV_98 = 0x0003, |
106 | WV_Me = 0x0004, |
107 | WV_DOS_based= 0x000f, |
108 | |
109 | /* codenames */ |
110 | WV_NT = 0x0010, |
111 | WV_2000 = 0x0020, |
112 | WV_XP = 0x0030, |
113 | WV_2003 = 0x0040, |
114 | WV_VISTA = 0x0080, |
115 | WV_WINDOWS7 = 0x0090, |
116 | WV_WINDOWS8 = 0x00a0, |
117 | WV_WINDOWS8_1 = 0x00b0, |
118 | WV_WINDOWS10 = 0x00c0, |
119 | WV_NT_based = 0x00f0, |
120 | |
121 | /* version numbers */ |
122 | WV_4_0 = WV_NT, |
123 | WV_5_0 = WV_2000, |
124 | WV_5_1 = WV_XP, |
125 | WV_5_2 = WV_2003, |
126 | WV_6_0 = WV_VISTA, |
127 | WV_6_1 = WV_WINDOWS7, |
128 | WV_6_2 = WV_WINDOWS8, |
129 | WV_6_3 = WV_WINDOWS8_1, |
130 | WV_10_0 = WV_WINDOWS10, |
131 | |
132 | WV_CE = 0x0100, |
133 | WV_CENET = 0x0200, |
134 | WV_CE_5 = 0x0300, |
135 | WV_CE_6 = 0x0400, |
136 | WV_CE_based = 0x0f00 |
137 | }; |
138 | |
139 | #define Q_MV_OSX(major, minor) (major == 10 ? minor + 2 : (major == 9 ? 1 : 0)) |
140 | #define Q_MV_IOS(major, minor) (QSysInfo::MV_IOS | major << 4 | minor) |
141 | #define Q_MV_TVOS(major, minor) (QSysInfo::MV_TVOS | major << 4 | minor) |
142 | #define Q_MV_WATCHOS(major, minor) (QSysInfo::MV_WATCHOS | major << 4 | minor) |
143 | enum QT_DEPRECATED_X("Use QOperatingSystemVersion" ) MacVersion { |
144 | MV_None = 0xffff, |
145 | MV_Unknown = 0x0000, |
146 | |
147 | /* version */ |
148 | MV_9 = Q_MV_OSX(9, 0), |
149 | MV_10_0 = Q_MV_OSX(10, 0), |
150 | MV_10_1 = Q_MV_OSX(10, 1), |
151 | MV_10_2 = Q_MV_OSX(10, 2), |
152 | MV_10_3 = Q_MV_OSX(10, 3), |
153 | MV_10_4 = Q_MV_OSX(10, 4), |
154 | MV_10_5 = Q_MV_OSX(10, 5), |
155 | MV_10_6 = Q_MV_OSX(10, 6), |
156 | MV_10_7 = Q_MV_OSX(10, 7), |
157 | MV_10_8 = Q_MV_OSX(10, 8), |
158 | MV_10_9 = Q_MV_OSX(10, 9), |
159 | MV_10_10 = Q_MV_OSX(10, 10), |
160 | MV_10_11 = Q_MV_OSX(10, 11), |
161 | MV_10_12 = Q_MV_OSX(10, 12), |
162 | |
163 | /* codenames */ |
164 | MV_CHEETAH = MV_10_0, |
165 | MV_PUMA = MV_10_1, |
166 | MV_JAGUAR = MV_10_2, |
167 | MV_PANTHER = MV_10_3, |
168 | MV_TIGER = MV_10_4, |
169 | MV_LEOPARD = MV_10_5, |
170 | MV_SNOWLEOPARD = MV_10_6, |
171 | MV_LION = MV_10_7, |
172 | MV_MOUNTAINLION = MV_10_8, |
173 | MV_MAVERICKS = MV_10_9, |
174 | MV_YOSEMITE = MV_10_10, |
175 | MV_ELCAPITAN = MV_10_11, |
176 | MV_SIERRA = MV_10_12, |
177 | |
178 | /* iOS */ |
179 | MV_IOS = 1 << 8, |
180 | MV_IOS_4_3 = Q_MV_IOS(4, 3), |
181 | MV_IOS_5_0 = Q_MV_IOS(5, 0), |
182 | MV_IOS_5_1 = Q_MV_IOS(5, 1), |
183 | MV_IOS_6_0 = Q_MV_IOS(6, 0), |
184 | MV_IOS_6_1 = Q_MV_IOS(6, 1), |
185 | MV_IOS_7_0 = Q_MV_IOS(7, 0), |
186 | MV_IOS_7_1 = Q_MV_IOS(7, 1), |
187 | MV_IOS_8_0 = Q_MV_IOS(8, 0), |
188 | MV_IOS_8_1 = Q_MV_IOS(8, 1), |
189 | MV_IOS_8_2 = Q_MV_IOS(8, 2), |
190 | MV_IOS_8_3 = Q_MV_IOS(8, 3), |
191 | MV_IOS_8_4 = Q_MV_IOS(8, 4), |
192 | MV_IOS_9_0 = Q_MV_IOS(9, 0), |
193 | MV_IOS_9_1 = Q_MV_IOS(9, 1), |
194 | MV_IOS_9_2 = Q_MV_IOS(9, 2), |
195 | MV_IOS_9_3 = Q_MV_IOS(9, 3), |
196 | MV_IOS_10_0 = Q_MV_IOS(10, 0), |
197 | |
198 | /* tvOS */ |
199 | MV_TVOS = 1 << 9, |
200 | MV_TVOS_9_0 = Q_MV_TVOS(9, 0), |
201 | MV_TVOS_9_1 = Q_MV_TVOS(9, 1), |
202 | MV_TVOS_9_2 = Q_MV_TVOS(9, 2), |
203 | MV_TVOS_10_0 = Q_MV_TVOS(10, 0), |
204 | |
205 | /* watchOS */ |
206 | MV_WATCHOS = 1 << 10, |
207 | MV_WATCHOS_2_0 = Q_MV_WATCHOS(2, 0), |
208 | MV_WATCHOS_2_1 = Q_MV_WATCHOS(2, 1), |
209 | MV_WATCHOS_2_2 = Q_MV_WATCHOS(2, 2), |
210 | MV_WATCHOS_3_0 = Q_MV_WATCHOS(3, 0) |
211 | }; |
212 | |
213 | QT_WARNING_PUSH |
214 | QT_WARNING_DISABLE_DEPRECATED |
215 | #if defined(Q_OS_WIN) || defined(Q_OS_CYGWIN) |
216 | QT_SYSINFO_DEPRECATED_X("Use QOperatingSystemVersion::current()" ) static const WinVersion WindowsVersion; |
217 | QT_SYSINFO_DEPRECATED_X("Use QOperatingSystemVersion::current()" ) static WinVersion windowsVersion(); |
218 | #else |
219 | QT_SYSINFO_DEPRECATED_X("Use QOperatingSystemVersion::current()" ) static const WinVersion WindowsVersion = WV_None; |
220 | QT_SYSINFO_DEPRECATED_X("Use QOperatingSystemVersion::current()" ) static WinVersion windowsVersion() { return WV_None; } |
221 | #endif |
222 | #if defined(Q_OS_MAC) |
223 | QT_SYSINFO_DEPRECATED_X("Use QOperatingSystemVersion::current()" ) static const MacVersion MacintoshVersion; |
224 | QT_SYSINFO_DEPRECATED_X("Use QOperatingSystemVersion::current()" ) static MacVersion macVersion(); |
225 | #else |
226 | QT_SYSINFO_DEPRECATED_X("Use QOperatingSystemVersion::current()" ) static const MacVersion MacintoshVersion = MV_None; |
227 | QT_SYSINFO_DEPRECATED_X("Use QOperatingSystemVersion::current()" ) static MacVersion macVersion() { return MV_None; } |
228 | #endif |
229 | QT_WARNING_POP |
230 | #endif // QT_DEPRECATED_SINCE(5, 9) |
231 | |
232 | static QString buildCpuArchitecture(); |
233 | static QString currentCpuArchitecture(); |
234 | static QString buildAbi(); |
235 | |
236 | static QString kernelType(); |
237 | static QString kernelVersion(); |
238 | static QString productType(); |
239 | static QString productVersion(); |
240 | static QString prettyProductName(); |
241 | |
242 | static QString machineHostName(); |
243 | static QByteArray machineUniqueId(); |
244 | static QByteArray bootUniqueId(); |
245 | }; |
246 | |
247 | #undef QT_SYSINFO_DEPRECATED_X |
248 | |
249 | QT_END_NAMESPACE |
250 | #endif // QSYSINFO_H |
251 | |