diff --git a/include/zephyr/kernel_structs.h b/include/zephyr/kernel_structs.h index 5cea718f0b4c38..56df49dcb23dbb 100644 --- a/include/zephyr/kernel_structs.h +++ b/include/zephyr/kernel_structs.h @@ -263,7 +263,7 @@ bool z_smp_cpu_mobile(void); #define _current_cpu ({ __ASSERT_NO_MSG(!z_smp_cpu_mobile()); \ arch_curr_cpu(); }) -struct k_thread *z_smp_current_get(void); +__attribute_const__ struct k_thread *z_smp_current_get(void); #define _current z_smp_current_get() #else diff --git a/kernel/smp.c b/kernel/smp.c index f97f1b2a17e3ac..63ac7bc8975e7b 100644 --- a/kernel/smp.c +++ b/kernel/smp.c @@ -249,7 +249,7 @@ bool z_smp_cpu_mobile(void) return !pinned; } -struct k_thread *z_smp_current_get(void) +__attribute_const__ struct k_thread *z_smp_current_get(void) { /* * _current is a field read from _current_cpu, which can race