From effd2fa834ead5d5af71b47e45e5e286d8a8d5c8 Mon Sep 17 00:00:00 2001 From: Eugeniy Paltsev Date: Wed, 23 Sep 2020 00:22:17 +0300 Subject: [PATCH] toolchain: define __no_optimization attribute across toolchains The __attribute__((optimize("-O0"))) attribute is used to disable optimization of some test functions. ARC MWDT toolchain doesn't support it, however it supports __attribute__((optnone)) with similar functionality. Define __no_optimization attribute across all toolchains so it can be used in tests. NOTE: we don't define __no_optimization for XCC as it includes GCC header with __no_optimization defined. Signed-off-by: Eugeniy Paltsev --- include/toolchain/gcc.h | 4 ++++ include/toolchain/mwdt.h | 2 ++ tests/kernel/gen_isr_table/src/main.c | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/include/toolchain/gcc.h b/include/toolchain/gcc.h index e8be67633ef..ea6a0dd9227 100644 --- a/include/toolchain/gcc.h +++ b/include/toolchain/gcc.h @@ -194,6 +194,10 @@ do { \ #define popcount(x) __builtin_popcount(x) +#ifndef __no_optimization +#define __no_optimization __attribute__((optimize("-O0"))) +#endif + #ifndef __weak #define __weak __attribute__((__weak__)) #endif diff --git a/include/toolchain/mwdt.h b/include/toolchain/mwdt.h index 3eb83fb3bd0..a97f8a05618 100644 --- a/include/toolchain/mwdt.h +++ b/include/toolchain/mwdt.h @@ -61,6 +61,8 @@ #else /* defined(_ASMLANGUAGE) */ +#define __no_optimization __attribute__((optnone)) + #include /* Metaware toolchain has _Static_assert. However it not able to calculate diff --git a/tests/kernel/gen_isr_table/src/main.c b/tests/kernel/gen_isr_table/src/main.c index 1a7cb53b7d8..cdb9f80ce5d 100644 --- a/tests/kernel/gen_isr_table/src/main.c +++ b/tests/kernel/gen_isr_table/src/main.c @@ -160,7 +160,7 @@ void isr6(const void *param) * doesn't support this; we need to tell the compiler not to reorder memory * accesses to trigger_check around calls to trigger_irq. */ -__attribute__((optimize("-O0"))) +__no_optimization #endif int test_irq(int offset) {