Store the GCC version number in Q_CC_GNU
The sequence of (__GNUC__ * 100 + __GNUC_MINOR__) was used in quite a few places. Simplify it to make the code more readable. This follows the change done for Clang, which was quite necessary since Apple's version of Clang has different build numbers. Change-Id: I886271a5a5f21ae59485ecf8d140527723345a46 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
This commit is contained in:
parent
85a7138114
commit
729541f7ca
@ -137,7 +137,7 @@
|
|||||||
# endif
|
# endif
|
||||||
|
|
||||||
#elif defined(__GNUC__)
|
#elif defined(__GNUC__)
|
||||||
# define Q_CC_GNU
|
# define Q_CC_GNU (__GNUC__ * 100 + __GNUC_MINOR__)
|
||||||
# define Q_C_CALLBACKS
|
# define Q_C_CALLBACKS
|
||||||
# if defined(__MINGW32__)
|
# if defined(__MINGW32__)
|
||||||
# define Q_CC_MINGW
|
# define Q_CC_MINGW
|
||||||
@ -187,7 +187,7 @@
|
|||||||
# endif
|
# endif
|
||||||
# else
|
# else
|
||||||
/* Plain GCC */
|
/* Plain GCC */
|
||||||
# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 405
|
# if Q_CC_GNU >= 405
|
||||||
# define Q_ASSUME_IMPL(expr) if (expr){} else __builtin_unreachable()
|
# define Q_ASSUME_IMPL(expr) if (expr){} else __builtin_unreachable()
|
||||||
# define Q_UNREACHABLE_IMPL() __builtin_unreachable()
|
# define Q_UNREACHABLE_IMPL() __builtin_unreachable()
|
||||||
# define Q_DECL_DEPRECATED_X(text) __attribute__ ((__deprecated__(text)))
|
# define Q_DECL_DEPRECATED_X(text) __attribute__ ((__deprecated__(text)))
|
||||||
@ -221,7 +221,7 @@
|
|||||||
# define QT_NO_ARM_EABI
|
# define QT_NO_ARM_EABI
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 403 && !defined(Q_CC_CLANG)
|
# if Q_CC_GNU >= 403 && !defined(Q_CC_CLANG)
|
||||||
# define Q_ALLOC_SIZE(x) __attribute__((alloc_size(x)))
|
# define Q_ALLOC_SIZE(x) __attribute__((alloc_size(x)))
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
@ -728,7 +728,7 @@
|
|||||||
#if defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && !defined(Q_CC_CLANG)
|
#if defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && !defined(Q_CC_CLANG)
|
||||||
# define Q_COMPILER_RESTRICTED_VLA
|
# define Q_COMPILER_RESTRICTED_VLA
|
||||||
# define Q_COMPILER_THREADSAFE_STATICS
|
# define Q_COMPILER_THREADSAFE_STATICS
|
||||||
# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 403
|
# if Q_CC_GNU >= 403
|
||||||
// GCC supports binary literals in C, C++98 and C++11 modes
|
// GCC supports binary literals in C, C++98 and C++11 modes
|
||||||
# define Q_COMPILER_BINARY_LITERALS
|
# define Q_COMPILER_BINARY_LITERALS
|
||||||
# endif
|
# endif
|
||||||
@ -739,13 +739,13 @@
|
|||||||
# define Q_COMPILER_VARIADIC_MACROS
|
# define Q_COMPILER_VARIADIC_MACROS
|
||||||
# endif
|
# endif
|
||||||
# if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L
|
# if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L
|
||||||
# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 403
|
# if Q_CC_GNU >= 403
|
||||||
/* C++11 features supported in GCC 4.3: */
|
/* C++11 features supported in GCC 4.3: */
|
||||||
# define Q_COMPILER_DECLTYPE
|
# define Q_COMPILER_DECLTYPE
|
||||||
# define Q_COMPILER_RVALUE_REFS
|
# define Q_COMPILER_RVALUE_REFS
|
||||||
# define Q_COMPILER_STATIC_ASSERT
|
# define Q_COMPILER_STATIC_ASSERT
|
||||||
# endif
|
# endif
|
||||||
# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404
|
# if Q_CC_GNU >= 404
|
||||||
/* C++11 features supported in GCC 4.4: */
|
/* C++11 features supported in GCC 4.4: */
|
||||||
# define Q_COMPILER_AUTO_FUNCTION
|
# define Q_COMPILER_AUTO_FUNCTION
|
||||||
# define Q_COMPILER_AUTO_TYPE
|
# define Q_COMPILER_AUTO_TYPE
|
||||||
@ -754,7 +754,7 @@
|
|||||||
# define Q_COMPILER_UNICODE_STRINGS
|
# define Q_COMPILER_UNICODE_STRINGS
|
||||||
# define Q_COMPILER_VARIADIC_TEMPLATES
|
# define Q_COMPILER_VARIADIC_TEMPLATES
|
||||||
# endif
|
# endif
|
||||||
# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 405
|
# if Q_CC_GNU >= 405
|
||||||
/* C++11 features supported in GCC 4.5: */
|
/* C++11 features supported in GCC 4.5: */
|
||||||
# define Q_COMPILER_EXPLICIT_CONVERSIONS
|
# define Q_COMPILER_EXPLICIT_CONVERSIONS
|
||||||
/* GCC 4.4 implements initializer_list but does not define typedefs required
|
/* GCC 4.4 implements initializer_list but does not define typedefs required
|
||||||
@ -764,7 +764,7 @@
|
|||||||
# define Q_COMPILER_RAW_STRINGS
|
# define Q_COMPILER_RAW_STRINGS
|
||||||
# define Q_COMPILER_CLASS_ENUM
|
# define Q_COMPILER_CLASS_ENUM
|
||||||
# endif
|
# endif
|
||||||
# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 406
|
# if Q_CC_GNU >= 406
|
||||||
/* Pre-4.6 compilers implement a non-final snapshot of N2346, hence default and delete
|
/* Pre-4.6 compilers implement a non-final snapshot of N2346, hence default and delete
|
||||||
* functions are supported only if they are public. Starting from 4.6, GCC handles
|
* functions are supported only if they are public. Starting from 4.6, GCC handles
|
||||||
* final version - the access modifier is not relevant. */
|
* final version - the access modifier is not relevant. */
|
||||||
@ -776,7 +776,7 @@
|
|||||||
# define Q_COMPILER_UNRESTRICTED_UNIONS
|
# define Q_COMPILER_UNRESTRICTED_UNIONS
|
||||||
# define Q_COMPILER_RANGE_FOR
|
# define Q_COMPILER_RANGE_FOR
|
||||||
# endif
|
# endif
|
||||||
# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 407
|
# if Q_CC_GNU >= 407
|
||||||
/* GCC 4.4 implemented <atomic> and std::atomic using its old intrinsics.
|
/* GCC 4.4 implemented <atomic> and std::atomic using its old intrinsics.
|
||||||
* However, the implementation is incomplete for most platforms until GCC 4.7:
|
* However, the implementation is incomplete for most platforms until GCC 4.7:
|
||||||
* instead, std::atomic would use an external lock. Since we need an std::atomic
|
* instead, std::atomic would use an external lock. Since we need an std::atomic
|
||||||
@ -792,20 +792,20 @@
|
|||||||
# define Q_COMPILER_TEMPLATE_ALIAS
|
# define Q_COMPILER_TEMPLATE_ALIAS
|
||||||
# define Q_COMPILER_UDL
|
# define Q_COMPILER_UDL
|
||||||
# endif
|
# endif
|
||||||
# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 408
|
# if Q_CC_GNU >= 408
|
||||||
# define Q_COMPILER_ATTRIBUTES
|
# define Q_COMPILER_ATTRIBUTES
|
||||||
# define Q_COMPILER_ALIGNAS
|
# define Q_COMPILER_ALIGNAS
|
||||||
# define Q_COMPILER_ALIGNOF
|
# define Q_COMPILER_ALIGNOF
|
||||||
# define Q_COMPILER_INHERITING_CONSTRUCTORS
|
# define Q_COMPILER_INHERITING_CONSTRUCTORS
|
||||||
# define Q_COMPILER_THREAD_LOCAL
|
# define Q_COMPILER_THREAD_LOCAL
|
||||||
# if (__GNUC__ * 100 + __GNUC_MINOR__) > 408 || __GNUC_PATCHLEVEL__ >= 1
|
# if Q_CC_GNU > 408 || __GNUC_PATCHLEVEL__ >= 1
|
||||||
# define Q_COMPILER_REF_QUALIFIERS
|
# define Q_COMPILER_REF_QUALIFIERS
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
/* C++11 features are complete as of GCC 4.8.1 */
|
/* C++11 features are complete as of GCC 4.8.1 */
|
||||||
# endif
|
# endif
|
||||||
# if __cplusplus > 201103L
|
# if __cplusplus > 201103L
|
||||||
# if (__GNUC__ * 100 + __GNUC_MINOR__) >= 409
|
# if Q_CC_GNU >= 409
|
||||||
/* C++1y features in GCC 4.9 - deprecated, do not update this list */
|
/* C++1y features in GCC 4.9 - deprecated, do not update this list */
|
||||||
//# define Q_COMPILER_BINARY_LITERALS // already supported since GCC 4.3 as an extension
|
//# define Q_COMPILER_BINARY_LITERALS // already supported since GCC 4.3 as an extension
|
||||||
# define Q_COMPILER_LAMBDA_CAPTURES
|
# define Q_COMPILER_LAMBDA_CAPTURES
|
||||||
|
@ -877,7 +877,7 @@ public:
|
|||||||
// (http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#382).
|
// (http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#382).
|
||||||
// GCC 4.3 and 4.4 have support for decltype, but are affected by DR 382.
|
// GCC 4.3 and 4.4 have support for decltype, but are affected by DR 382.
|
||||||
# if defined(Q_COMPILER_DECLTYPE) && \
|
# if defined(Q_COMPILER_DECLTYPE) && \
|
||||||
(defined(Q_CC_CLANG) || defined(Q_CC_INTEL) || !defined(Q_CC_GNU) || (__GNUC__ * 100 + __GNUC_MINOR__) >= 405)
|
(defined(Q_CC_CLANG) || defined(Q_CC_INTEL) || !defined(Q_CC_GNU) || Q_CC_GNU >= 405)
|
||||||
# define QT_FOREACH_DECLTYPE(x) typename QtPrivate::remove_reference<decltype(x)>::type
|
# define QT_FOREACH_DECLTYPE(x) typename QtPrivate::remove_reference<decltype(x)>::type
|
||||||
# else
|
# else
|
||||||
# define QT_FOREACH_DECLTYPE(x) __typeof__((x))
|
# define QT_FOREACH_DECLTYPE(x) __typeof__((x))
|
||||||
|
@ -519,7 +519,7 @@ QBasicAtomicInt qt_cpu_features = Q_BASIC_ATOMIC_INITIALIZER(0);
|
|||||||
void qDetectCpuFeatures()
|
void qDetectCpuFeatures()
|
||||||
{
|
{
|
||||||
#if defined(Q_CC_GNU) && !defined(Q_CC_CLANG) && !defined(Q_CC_INTEL)
|
#if defined(Q_CC_GNU) && !defined(Q_CC_CLANG) && !defined(Q_CC_INTEL)
|
||||||
# if (__GNUC__ * 100 + __GNUC_MINOR__) < 403
|
# if Q_CC_GNU < 403
|
||||||
// GCC 4.2 (at least the one that comes with Apple's XCode, on Mac) is
|
// GCC 4.2 (at least the one that comes with Apple's XCode, on Mac) is
|
||||||
// known to be broken beyond repair in dealing with the inline assembly
|
// known to be broken beyond repair in dealing with the inline assembly
|
||||||
// above. It will generate bad code that could corrupt important registers
|
// above. It will generate bad code that could corrupt important registers
|
||||||
|
@ -218,7 +218,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// other x86 intrinsics
|
// other x86 intrinsics
|
||||||
#if defined(Q_PROCESSOR_X86) && ((defined(Q_CC_GNU) && (__GNUC__ * 100 + __GNUC_MINOR__ >= 404)) \
|
#if defined(Q_PROCESSOR_X86) && ((defined(Q_CC_GNU) && (Q_CC_GNU >= 404)) \
|
||||||
|| (defined(Q_CC_CLANG) && (Q_CC_CLANG >= 208)) \
|
|| (defined(Q_CC_CLANG) && (Q_CC_CLANG >= 208)) \
|
||||||
|| defined(Q_CC_INTEL))
|
|| defined(Q_CC_INTEL))
|
||||||
# define QT_COMPILER_SUPPORTS_X86INTRIN
|
# define QT_COMPILER_SUPPORTS_X86INTRIN
|
||||||
@ -332,7 +332,7 @@ static __forceinline unsigned long _bit_scan_forward(uint val)
|
|||||||
_BitScanForward(&result, val);
|
_BitScanForward(&result, val);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
# elif (defined(Q_CC_CLANG) || (defined(Q_CC_GNU) && __GNUC__ * 100 + __GNUC_MINOR__ < 405)) \
|
# elif (defined(Q_CC_CLANG) || (defined(Q_CC_GNU) && Q_CC_GNU < 405)) \
|
||||||
&& !defined(Q_CC_INTEL)
|
&& !defined(Q_CC_INTEL)
|
||||||
// Clang is missing the intrinsic for _bit_scan_reverse
|
// Clang is missing the intrinsic for _bit_scan_reverse
|
||||||
// GCC only added it in version 4.5
|
// GCC only added it in version 4.5
|
||||||
|
Loading…
Reference in New Issue
Block a user