From 8530cfa76d66ca623498e94cddf48f0471090709 Mon Sep 17 00:00:00 2001 From: Daniel Leung Date: Mon, 9 Aug 2021 10:04:11 -0700 Subject: [PATCH] kernel: mark z_current_get() as const In commit 00f95032938e1387126f453b64f8c479987ca16e to make k_current_get() work without syscall, a new z_current_get() was introduced since there are times when thread local storage has not been initialized. However, this was not marked with const attribute the same as k_current_get(). This may result in slower compiled code as each call to z_current_get() may actually need to go through the whole function call process instead of reusing the result from previous call in the same scope. So add const attribute to z_current_get() to restore the old behavior. Fixes #37460 Signed-off-by: Daniel Leung --- include/kernel.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/kernel.h b/include/kernel.h index 3a254313241..a4dca2bce3f 100644 --- a/include/kernel.h +++ b/include/kernel.h @@ -494,6 +494,7 @@ __syscall void k_wakeup(k_tid_t thread); * * @return ID of current thread. */ +__attribute_const__ __syscall k_tid_t z_current_get(void); #ifdef CONFIG_THREAD_LOCAL_STORAGE