Go to the documentation of this file.
42 # include <QtCore/qglobal.h>
45 #ifndef QPROCESSORDETECTION_H
46 #define QPROCESSORDETECTION_H
71 #if defined(__ORDER_BIG_ENDIAN__)
72 # define Q_BIG_ENDIAN __ORDER_BIG_ENDIAN__
74 # define Q_BIG_ENDIAN 4321
76 #if defined(__ORDER_LITTLE_ENDIAN__)
77 # define Q_LITTLE_ENDIAN __ORDER_LITTLE_ENDIAN__
79 # define Q_LITTLE_ENDIAN 1234
97 #if defined(__arm__) || defined(__TARGET_ARCH_ARM) || defined(_M_ARM) || defined(_M_ARM64) || defined(__aarch64__) || defined(__ARM64__)
98 # if defined(__aarch64__) || defined(__ARM64__) || defined(_M_ARM64)
99 # define Q_PROCESSOR_ARM_64
100 # define Q_PROCESSOR_WORDSIZE 8
102 # define Q_PROCESSOR_ARM_32
104 # if defined(__ARM_ARCH) && __ARM_ARCH > 1
105 # define Q_PROCESSOR_ARM __ARM_ARCH
106 # elif defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM > 1
107 # define Q_PROCESSOR_ARM __TARGET_ARCH_ARM
108 # elif defined(_M_ARM) && _M_ARM > 1
109 # define Q_PROCESSOR_ARM _M_ARM
110 # elif defined(__ARM64_ARCH_8__) \
111 || defined(__aarch64__) \
112 || defined(__ARMv8__) \
113 || defined(__ARMv8_A__) \
115 # define Q_PROCESSOR_ARM 8
116 # elif defined(__ARM_ARCH_7__) \
117 || defined(__ARM_ARCH_7A__) \
118 || defined(__ARM_ARCH_7R__) \
119 || defined(__ARM_ARCH_7M__) \
120 || defined(__ARM_ARCH_7S__) \
121 || defined(_ARM_ARCH_7) \
122 || defined(__CORE_CORTEXA__)
123 # define Q_PROCESSOR_ARM 7
124 # elif defined(__ARM_ARCH_6__) \
125 || defined(__ARM_ARCH_6J__) \
126 || defined(__ARM_ARCH_6T2__) \
127 || defined(__ARM_ARCH_6Z__) \
128 || defined(__ARM_ARCH_6K__) \
129 || defined(__ARM_ARCH_6ZK__) \
130 || defined(__ARM_ARCH_6M__)
131 # define Q_PROCESSOR_ARM 6
132 # elif defined(__ARM_ARCH_5TEJ__) \
133 || defined(__ARM_ARCH_5TE__)
134 # define Q_PROCESSOR_ARM 5
136 # define Q_PROCESSOR_ARM 0
138 # if Q_PROCESSOR_ARM >= 8
139 # define Q_PROCESSOR_ARM_V8
141 # if Q_PROCESSOR_ARM >= 7
142 # define Q_PROCESSOR_ARM_V7
144 # if Q_PROCESSOR_ARM >= 6
145 # define Q_PROCESSOR_ARM_V6
147 # if Q_PROCESSOR_ARM >= 5
148 # define Q_PROCESSOR_ARM_V5
150 # error "ARM architecture too old"
152 # if defined(__ARMEL__) || defined(_M_ARM64)
153 # define Q_BYTE_ORDER Q_LITTLE_ENDIAN
154 # elif defined(__ARMEB__)
155 # define Q_BYTE_ORDER Q_BIG_ENDIAN
183 #elif defined(__i386) || defined(__i386__) || defined(_M_IX86)
184 # define Q_PROCESSOR_X86_32
185 # define Q_BYTE_ORDER Q_LITTLE_ENDIAN
186 # define Q_PROCESSOR_WORDSIZE 4
198 # if defined(_M_IX86)
199 # define Q_PROCESSOR_X86 (_M_IX86/100)
200 # elif defined(__i686__) || defined(__athlon__) || defined(__SSE__) || defined(__pentiumpro__)
201 # define Q_PROCESSOR_X86 6
202 # elif defined(__i586__) || defined(__k6__) || defined(__pentium__)
203 # define Q_PROCESSOR_X86 5
204 # elif defined(__i486__) || defined(__80486__)
205 # define Q_PROCESSOR_X86 4
207 # define Q_PROCESSOR_X86 3
210 #elif defined(__x86_64) || defined(__x86_64__) || defined(__amd64) || defined(_M_X64)
211 # define Q_PROCESSOR_X86 6
212 # define Q_PROCESSOR_X86_64
213 # define Q_BYTE_ORDER Q_LITTLE_ENDIAN
214 # define Q_PROCESSOR_WORDSIZE 8
221 #elif defined(__ia64) || defined(__ia64__) || defined(_M_IA64)
222 # define Q_PROCESSOR_IA64
223 # define Q_PROCESSOR_WORDSIZE 8
231 #elif defined(__mips) || defined(__mips__) || defined(_M_MRX000)
232 # define Q_PROCESSOR_MIPS
233 # if defined(_MIPS_ARCH_MIPS1) || (defined(__mips) && __mips - 0 >= 1)
234 # define Q_PROCESSOR_MIPS_I
236 # if defined(_MIPS_ARCH_MIPS2) || (defined(__mips) && __mips - 0 >= 2)
237 # define Q_PROCESSOR_MIPS_II
239 # if defined(_MIPS_ARCH_MIPS3) || (defined(__mips) && __mips - 0 >= 3)
240 # define Q_PROCESSOR_MIPS_III
242 # if defined(_MIPS_ARCH_MIPS4) || (defined(__mips) && __mips - 0 >= 4)
243 # define Q_PROCESSOR_MIPS_IV
245 # if defined(_MIPS_ARCH_MIPS5) || (defined(__mips) && __mips - 0 >= 5)
246 # define Q_PROCESSOR_MIPS_V
248 # if defined(_MIPS_ARCH_MIPS32) || defined(__mips32) || (defined(__mips) && __mips - 0 >= 32)
249 # define Q_PROCESSOR_MIPS_32
251 # if defined(_MIPS_ARCH_MIPS64) || defined(__mips64)
252 # define Q_PROCESSOR_MIPS_64
253 # define Q_PROCESSOR_WORDSIZE 8
255 # if defined(__MIPSEL__)
256 # define Q_BYTE_ORDER Q_LITTLE_ENDIAN
257 # elif defined(__MIPSEB__)
258 # define Q_BYTE_ORDER Q_BIG_ENDIAN
272 #elif defined(__ppc__) || defined(__ppc) || defined(__powerpc__) \
273 || defined(_ARCH_COM) || defined(_ARCH_PWR) || defined(_ARCH_PPC) \
274 || defined(_M_MPPC) || defined(_M_PPC)
275 # define Q_PROCESSOR_POWER
276 # if defined(__ppc64__) || defined(__powerpc64__) || defined(__64BIT__)
277 # define Q_PROCESSOR_POWER_64
278 # define Q_PROCESSOR_WORDSIZE 8
280 # define Q_PROCESSOR_POWER_32
289 #elif defined(__riscv)
290 # define Q_PROCESSOR_RISCV
291 # if __riscv_xlen == 64
292 # define Q_PROCESSOR_RISCV_64
294 # define Q_PROCESSOR_RISCV_32
296 # define Q_BYTE_ORDER Q_LITTLE_ENDIAN
303 #elif defined(__s390__)
304 # define Q_PROCESSOR_S390
305 # if defined(__s390x__)
306 # define Q_PROCESSOR_S390_X
308 # define Q_BYTE_ORDER Q_BIG_ENDIAN
328 #elif defined(__sparc__)
329 # define Q_PROCESSOR_SPARC
330 # if defined(__sparc_v9__)
331 # define Q_PROCESSOR_SPARC_V9
333 # if defined(__sparc64__)
334 # define Q_PROCESSOR_SPARC_64
336 # define Q_BYTE_ORDER Q_BIG_ENDIAN
339 #elif defined(__EMSCRIPTEN__)
340 # define Q_PROCESSOR_WASM
341 # define Q_BYTE_ORDER Q_LITTLE_ENDIAN
342 # define Q_PROCESSOR_WORDSIZE 8
343 #ifdef QT_COMPILER_SUPPORTS_SSE2
344 # define Q_PROCESSOR_X86 6
358 #if !defined(Q_BYTE_ORDER)
359 # if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == Q_BIG_ENDIAN || __BYTE_ORDER__ == Q_LITTLE_ENDIAN)
361 # define Q_BYTE_ORDER __BYTE_ORDER__
362 # elif defined(__BIG_ENDIAN__) || defined(_big_endian__) || defined(_BIG_ENDIAN)
363 # define Q_BYTE_ORDER Q_BIG_ENDIAN
364 # elif defined(__LITTLE_ENDIAN__) || defined(_little_endian__) || defined(_LITTLE_ENDIAN)
365 # define Q_BYTE_ORDER Q_LITTLE_ENDIAN
367 # error "Unable to determine byte order!"
383 #if defined __SIZEOF_POINTER__
384 # define QT_POINTER_SIZE __SIZEOF_POINTER__
385 #elif defined(__LP64__) || defined(_LP64)
386 # define QT_POINTER_SIZE 8
387 #elif defined(Q_PROCESSOR_WORDSIZE)
388 # define QT_POINTER_SIZE Q_PROCESSOR_WORDSIZE
390 # define QT_POINTER_SIZE 4
400 #ifndef Q_PROCESSOR_WORDSIZE
401 # define Q_PROCESSOR_WORDSIZE QT_POINTER_SIZE