diff --git a/include/arch/arc/arch.h b/include/arch/arc/arch.h index 5eed07aef53..b3fa24a504f 100644 --- a/include/arch/arc/arch.h +++ b/include/arch/arc/arch.h @@ -279,6 +279,12 @@ BUILD_ASSERT(CONFIG_PRIVILEGED_STACK_SIZE % Z_ARC_MPU_ALIGN == 0, #define K_MEM_PARTITION_IS_EXECUTABLE(attr) \ ((attr) & (AUX_MPU_ATTR_KE | AUX_MPU_ATTR_UE)) +/* + * BUILD_ASSERT in case of MWDT is a bit more picky in performing compile-time check. + * For example it can't evaluate variable address at build time like GCC toolchain can do. + * That's why we don't provide _ARCH_MEM_PARTITION_ALIGN_CHECK for MWDT toolchain. + */ +#ifndef __CCAC__ #if CONFIG_ARC_MPU_VER == 2 #define _ARCH_MEM_PARTITION_ALIGN_CHECK(start, size) \ BUILD_ASSERT(!(((size) & ((size) - 1))) && (size) >= Z_ARC_MPU_ALIGN \ @@ -295,6 +301,7 @@ BUILD_ASSERT(CONFIG_PRIVILEGED_STACK_SIZE % Z_ARC_MPU_ALIGN == 0, " and greater than or equal to 32." \ "start address of the partition must align with 32.") #endif +#endif /* __CCAC__ */ #endif /* CONFIG_ARC_MPU*/ /* Typedef for the k_mem_partition attribute*/ diff --git a/include/toolchain/mwdt.h b/include/toolchain/mwdt.h index 9aeb4d1b69f..5a1719e8ec2 100644 --- a/include/toolchain/mwdt.h +++ b/include/toolchain/mwdt.h @@ -84,13 +84,12 @@ #include -/* Metaware toolchain has _Static_assert. However it not able to calculate - * conditional expression in build time for some realy complex cases. ARC GNU - * toolchain works fine in this cases, so it looks like MWDT bug. So, disable - * BUILD_ASSERT macro until we fix that issue in MWDT toolchain. - */ #undef BUILD_ASSERT -#define BUILD_ASSERT(EXPR, MSG...) +#ifdef __cplusplus +#define BUILD_ASSERT(EXPR, MSG...) static_assert(EXPR, "" MSG) +#else +#define BUILD_ASSERT(EXPR, MSG...) _Static_assert(EXPR, "" MSG) +#endif #define __builtin_arc_nop() _nop()