arch: riscv: make arch_current_thread_set() safer
Use the "do { } while (0)" construct so the macro behaves like an actual
C statement in all cases. Also evaluate the macro argument only once.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
This commit is contained in:
committed by
Fabio Baltieri
parent
55602a5b6b
commit
132fa83ed4
@@ -32,10 +32,9 @@ register struct k_thread *__arch_current_thread __asm__("gp");
|
||||
|
||||
#define arch_current_thread() __arch_current_thread
|
||||
#define arch_current_thread_set(thread) \
|
||||
{ \
|
||||
_current_cpu->current = thread; \
|
||||
__arch_current_thread = (thread); \
|
||||
}
|
||||
do { \
|
||||
_current_cpu->current = __arch_current_thread = (thread); \
|
||||
} while (0)
|
||||
#endif /* CONFIG_RISCV_CURRENT_VIA_GP */
|
||||
|
||||
static ALWAYS_INLINE unsigned int arch_num_cpus(void)
|
||||
|
||||
Reference in New Issue
Block a user