Commit c58c76ef authored by Keith Packard's avatar Keith Packard Committed by Carles Cufi
Browse files

toolchain: Replace GCC_VERSION, CLANG_VERSION and BUILD_ASSERT macros

GCC_VERSION is defined in a few modules, and those headers are often
included first, so replace the one used in zephyr with
TOOLCHAIN_GCC_VERSION. Do the same with CLANG_VERSION, replacing it with
TOOLCHAIN_CLANG_VERSION.

BUILD_ASSERT is also defined in include/toolchain/common.h, which might
get included before gcc.h. We want to use the gcc-specific one instead
of the general one.

Signed-off-by: default avatarKeith Packard <keithp@keithp.com>
parent b27cee0f
Loading
Loading
Loading
Loading
+6 −6
Changes for include/zephyr/toolchain.h: 6 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -68,19 +68,19 @@
#endif

/**
 * @def GCC_VERSION
 * @def TOOLCHAIN_GCC_VERSION
 * @brief GCC version in xxyyzz for xx.yy.zz. Zero if not GCC compatible.
 */
#ifndef GCC_VERSION
#define GCC_VERSION 0
#ifndef TOOLCHAIN_GCC_VERSION
#define TOOLCHAIN_GCC_VERSION 0
#endif

/**
 * @def CLANG_VERSION
 * @def TOOLCHAIN_CLANG_VERSION
 * @brief Clang version in xxyyzz for xx.yy.zz. Zero if not Clang compatible.
 */
#ifndef CLANG_VERSION
#define CLANG_VERSION 0
#ifndef TOOLCHAIN_CLANG_VERSION
#define TOOLCHAIN_CLANG_VERSION 0
#endif

/**
+5 −4
Changes for include/zephyr/toolchain/gcc.h: 5 added lines, 4 removed lines.
Original line number Diff line number Diff line
@@ -14,19 +14,19 @@
 * Macros to abstract compiler capabilities for GCC toolchain.
 */

#define GCC_VERSION \
#define TOOLCHAIN_GCC_VERSION \
	((__GNUC__ * 10000) + (__GNUC_MINOR__ * 100) + __GNUC_PATCHLEVEL__)

/* GCC supports #pragma diagnostics since 4.6.0 */
#if !defined(TOOLCHAIN_HAS_PRAGMA_DIAG) && (GCC_VERSION >= 40600)
#if !defined(TOOLCHAIN_HAS_PRAGMA_DIAG) && (TOOLCHAIN_GCC_VERSION >= 40600)
#define TOOLCHAIN_HAS_PRAGMA_DIAG 1
#endif

#if !defined(TOOLCHAIN_HAS_C_GENERIC) && (GCC_VERSION >= 40900)
#if !defined(TOOLCHAIN_HAS_C_GENERIC) && (TOOLCHAIN_GCC_VERSION >= 40900)
#define TOOLCHAIN_HAS_C_GENERIC 1
#endif

#if !defined(TOOLCHAIN_HAS_C_AUTO_TYPE) && (GCC_VERSION >= 40900)
#if !defined(TOOLCHAIN_HAS_C_AUTO_TYPE) && (TOOLCHAIN_GCC_VERSION >= 40900)
#define TOOLCHAIN_HAS_C_AUTO_TYPE 1
#endif

@@ -64,6 +64,7 @@
#endif


#undef BUILD_ASSERT /* clear out common version */
/* C++11 has static_assert built in */
#if defined(__cplusplus) && (__cplusplus >= 201103L)
#define BUILD_ASSERT(EXPR, MSG...) static_assert(EXPR, "" MSG)
+2 −2
Changes for include/zephyr/toolchain/llvm.h: 2 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -14,13 +14,13 @@
#define __fallthrough __attribute__((fallthrough))
#endif

#define CLANG_VERSION \
#define TOOLCHAIN_CLANG_VERSION \
	((__clang_major__ * 10000) + (__clang_minor__ * 100) + \
	  __clang_patchlevel__)

#define TOOLCHAIN_HAS_PRAGMA_DIAG 1

#if CLANG_VERSION >= 30800
#if TOOLCHAIN_CLANG_VERSION >= 30800
#define TOOLCHAIN_HAS_C_GENERIC 1
#define TOOLCHAIN_HAS_C_AUTO_TYPE 1
#endif