diff --git a/include/arch/riscv/error.h b/include/arch/riscv/error.h index eec72a1352a..935f9f67403 100644 --- a/include/arch/riscv/error.h +++ b/include/arch/riscv/error.h @@ -36,7 +36,7 @@ extern "C" { */ #define ARCH_EXCEPT(reason_p) do { \ - if (_is_user_context()) { \ + if (k_is_user_context()) { \ arch_syscall_invoke1(reason_p, \ K_SYSCALL_USER_FAULT); \ } else { \ diff --git a/include/logging/log_core.h b/include/logging/log_core.h index 39eaec2f513..c06320409c5 100644 --- a/include/logging/log_core.h +++ b/include/logging/log_core.h @@ -262,7 +262,7 @@ static inline char z_log_minimal_level_to_char(int level) #define __LOG(_level, _id, _filter, ...) \ do { \ if (Z_LOG_CONST_LEVEL_CHECK(_level)) { \ - bool is_user_context = _is_user_context(); \ + bool is_user_context = k_is_user_context(); \ \ if (IS_ENABLED(CONFIG_LOG_MINIMAL)) { \ Z_LOG_TO_PRINTK(_level, __VA_ARGS__); \ @@ -316,7 +316,7 @@ static inline char z_log_minimal_level_to_char(int level) #define __LOG_HEXDUMP(_level, _id, _filter, _data, _length, _str) \ do { \ if (Z_LOG_CONST_LEVEL_CHECK(_level)) { \ - bool is_user_context = _is_user_context(); \ + bool is_user_context = k_is_user_context(); \ \ if (IS_ENABLED(CONFIG_LOG_MINIMAL)) { \ Z_LOG_TO_PRINTK(_level, "%s", _str); \ @@ -723,7 +723,7 @@ __syscall void z_log_hexdump_from_user(uint32_t src_level_val, #define __LOG_VA(_level, _id, _filter, _str, _valist, _argnum, _strdup_action) \ do { \ if (Z_LOG_CONST_LEVEL_CHECK(_level)) { \ - bool is_user_context = _is_user_context(); \ + bool is_user_context = k_is_user_context(); \ \ if (IS_ENABLED(CONFIG_LOG_MINIMAL)) { \ z_log_minimal_printk(_str, _valist); \ diff --git a/include/syscall.h b/include/syscall.h index 4894471ccb3..3f24f622309 100644 --- a/include/syscall.h +++ b/include/syscall.h @@ -110,7 +110,7 @@ static ALWAYS_INLINE bool z_syscall_trap(void) * * @return true if the CPU is currently running with user permissions */ -static inline bool _is_user_context(void) +static inline bool k_is_user_context(void) { #ifdef CONFIG_USERSPACE return arch_is_user_context(); diff --git a/lib/os/assert.c b/lib/os/assert.c index a66bc45e28b..2a16dc78cff 100644 --- a/lib/os/assert.c +++ b/lib/os/assert.c @@ -37,7 +37,7 @@ __weak void assert_post_action(const char *file, unsigned int line) /* User threads aren't allowed to induce kernel panics; generate * an oops instead. */ - if (_is_user_context()) { + if (k_is_user_context()) { k_oops(); } #endif diff --git a/lib/os/printk.c b/lib/os/printk.c index 938483f0e92..36523f20edc 100644 --- a/lib/os/printk.c +++ b/lib/os/printk.c @@ -120,7 +120,7 @@ static int char_out(int c, void *ctx_p) #ifdef CONFIG_USERSPACE void vprintk(const char *fmt, va_list ap) { - if (_is_user_context()) { + if (k_is_user_context()) { struct buf_out_context ctx = { 0 }; cbvprintf(buf_char_out, &ctx, fmt, ap); diff --git a/samples/subsys/logging/logger/src/main.c b/samples/subsys/logging/logger/src/main.c index 6ae264953c0..433aed27c53 100644 --- a/samples/subsys/logging/logger/src/main.c +++ b/samples/subsys/logging/logger/src/main.c @@ -278,7 +278,7 @@ static void external_log_system_showcase(void) static void log_demo_thread(void *p1, void *p2, void *p3) { - bool usermode = _is_user_context(); + bool usermode = k_is_user_context(); k_sleep(K_MSEC(100)); diff --git a/subsys/logging/log_core.c b/subsys/logging/log_core.c index dad5507941a..12b728b3ad8 100644 --- a/subsys/logging/log_core.c +++ b/subsys/logging/log_core.c @@ -338,7 +338,7 @@ void log_printk(const char *fmt, va_list ap) } }; - if (_is_user_context()) { + if (k_is_user_context()) { uint8_t str[CONFIG_LOG_PRINTK_MAX_STRING_LENGTH + 1]; vsnprintk(str, sizeof(str), fmt, ap); @@ -391,7 +391,7 @@ uint32_t log_count_args(const char *fmt) void log_generic(struct log_msg_ids src_level, const char *fmt, va_list ap, enum log_strdup_action strdup_action) { - if (_is_user_context()) { + if (k_is_user_context()) { log_generic_from_user(src_level, fmt, ap); } else if (IS_ENABLED(CONFIG_LOG_IMMEDIATE) && (!IS_ENABLED(CONFIG_LOG_FRONTEND))) { @@ -895,7 +895,7 @@ char *log_strdup(const char *str) int err; if (IS_ENABLED(CONFIG_LOG_IMMEDIATE) || - is_rodata(str) || _is_user_context()) { + is_rodata(str) || k_is_user_context()) { return (char *)str; } diff --git a/subsys/shell/modules/device_service.c b/subsys/shell/modules/device_service.c index 788061e4fa3..90de6ef032a 100644 --- a/subsys/shell/modules/device_service.c +++ b/subsys/shell/modules/device_service.c @@ -156,7 +156,7 @@ static int cmd_device_list(const struct shell *shell, } shell_fprintf(shell, SHELL_NORMAL, " (%s)\n", state); - if (!_is_user_context()) { + if (!k_is_user_context()) { struct cmd_device_list_visitor_context ctx = { .shell = shell, .buf = buf, diff --git a/subsys/testsuite/include/tc_util.h b/subsys/testsuite/include/tc_util.h index 0bb65c02e12..8d36da7e1a7 100644 --- a/subsys/testsuite/include/tc_util.h +++ b/subsys/testsuite/include/tc_util.h @@ -101,7 +101,7 @@ static inline void get_start_time_cyc(void) * TC_START() in their code. But the caller thread cannot be * in userspace. */ - if (!_is_user_context()) { + if (!k_is_user_context()) { tc_start_time = k_cycle_get_32(); } } diff --git a/subsys/testsuite/ztest/src/ztest_error_hook.c b/subsys/testsuite/ztest/src/ztest_error_hook.c index 401e035cc0d..0c3a9733f42 100644 --- a/subsys/testsuite/ztest/src/ztest_error_hook.c +++ b/subsys/testsuite/ztest/src/ztest_error_hook.c @@ -137,7 +137,7 @@ void assert_post_action(const char *file, unsigned int line) /* User threads aren't allowed to induce kernel panics; generate * an oops instead. */ - if (_is_user_context()) { + if (k_is_user_context()) { k_oops(); } #endif diff --git a/tests/kernel/common/src/errno.c b/tests/kernel/common/src/errno.c index e1e43e28e50..e31895194d4 100644 --- a/tests/kernel/common/src/errno.c +++ b/tests/kernel/common/src/errno.c @@ -144,7 +144,7 @@ void test_errno(void) k_tid_t tid; uint32_t perm = K_INHERIT_PERMS; - if (_is_user_context()) { + if (k_is_user_context()) { perm = perm | K_USER; } diff --git a/tests/kernel/mem_protect/mem_protect/src/kobject.c b/tests/kernel/mem_protect/mem_protect/src/kobject.c index 3ecf7f304bb..dd646eeb33f 100644 --- a/tests/kernel/mem_protect/mem_protect/src/kobject.c +++ b/tests/kernel/mem_protect/mem_protect/src/kobject.c @@ -1104,7 +1104,7 @@ void test_kobject_free_error(void) { uint32_t perm = K_INHERIT_PERMS; - if (_is_user_context()) { + if (k_is_user_context()) { perm = perm | K_USER; } diff --git a/tests/kernel/mem_protect/userspace/src/main.c b/tests/kernel/mem_protect/userspace/src/main.c index 603d573b29f..e09a2714fc5 100644 --- a/tests/kernel/mem_protect/userspace/src/main.c +++ b/tests/kernel/mem_protect/userspace/src/main.c @@ -97,7 +97,7 @@ static void test_is_usermode(void) /* Confirm that we are in fact running in user mode. */ clear_fault(); - zassert_true(_is_user_context(), "thread left in kernel mode"); + zassert_true(k_is_user_context(), "thread left in kernel mode"); } /** @@ -547,7 +547,7 @@ static void test_access_after_revoke(void) static void umode_enter_func(void) { - zassert_true(_is_user_context(), + zassert_true(k_is_user_context(), "Thread did not enter user mode"); } diff --git a/tests/kernel/mutex/mutex_error_case/src/test_mutex_error.c b/tests/kernel/mutex/mutex_error_case/src/test_mutex_error.c index 3e4738d3d70..2c9df0ffee4 100644 --- a/tests/kernel/mutex/mutex_error_case/src/test_mutex_error.c +++ b/tests/kernel/mutex/mutex_error_case/src/test_mutex_error.c @@ -95,7 +95,7 @@ static int create_negative_test_thread(int choice) int ret; uint32_t perm = K_INHERIT_PERMS; - if (_is_user_context()) { + if (k_is_user_context()) { perm = perm | K_USER; } diff --git a/tests/kernel/spinlock/src/spinlock_error_case.c b/tests/kernel/spinlock/src/spinlock_error_case.c index 1c27783ea1e..7e5d97d9462 100644 --- a/tests/kernel/spinlock/src/spinlock_error_case.c +++ b/tests/kernel/spinlock/src/spinlock_error_case.c @@ -52,7 +52,7 @@ void assert_post_action(const char *file, unsigned int line) /* User threads aren't allowed to induce kernel panics; generate * an oops instead. */ - if (_is_user_context()) { + if (k_is_user_context()) { k_oops(); } #endif diff --git a/tests/kernel/threads/thread_error_case/src/main.c b/tests/kernel/threads/thread_error_case/src/main.c index 12015038da1..daee6f865d7 100644 --- a/tests/kernel/threads/thread_error_case/src/main.c +++ b/tests/kernel/threads/thread_error_case/src/main.c @@ -62,7 +62,7 @@ static void tThread_entry_negative(void *p1, void *p2, void *p3) break; case THREAD_CREATE_NEWTHREAD_NULL: ztest_set_fault_valid(true); - if (_is_user_context()) { + if (k_is_user_context()) { perm = perm | K_USER; } @@ -73,7 +73,7 @@ static void tThread_entry_negative(void *p1, void *p2, void *p3) break; case THREAD_CREATE_STACK_NULL: ztest_set_fault_valid(true); - if (_is_user_context()) { + if (k_is_user_context()) { perm = perm | K_USER; } @@ -84,7 +84,7 @@ static void tThread_entry_negative(void *p1, void *p2, void *p3) break; case THREAD_CTEATE_STACK_SIZE_OVERFLOW: ztest_set_fault_valid(true); - if (_is_user_context()) { + if (k_is_user_context()) { perm = perm | K_USER; } k_thread_create(&test_tdata, test_stack, -1, @@ -108,7 +108,7 @@ static void create_negative_test_thread(int choice) int ret; uint32_t perm = K_INHERIT_PERMS; - if (_is_user_context()) { + if (k_is_user_context()) { perm = perm | K_USER; } diff --git a/tests/subsys/edac/ibecc/src/ibecc.c b/tests/subsys/edac/ibecc/src/ibecc.c index 436ee44c90b..deee0933266 100644 --- a/tests/subsys/edac/ibecc/src/ibecc.c +++ b/tests/subsys/edac/ibecc/src/ibecc.c @@ -195,7 +195,7 @@ static int check_values(void *p1, void *p2, void *p3) #if defined(CONFIG_USERSPACE) TC_PRINT("Test communication in user mode thread\n"); - zassert_true(_is_user_context(), "thread left in kernel mode"); + zassert_true(k_is_user_context(), "thread left in kernel mode"); #endif /* Load to local variables to avoid using volatile in assert */ diff --git a/tests/ztest/error_hook/src/main.c b/tests/ztest/error_hook/src/main.c index 8dc580bf6ec..ddc6b359bcb 100644 --- a/tests/ztest/error_hook/src/main.c +++ b/tests/ztest/error_hook/src/main.c @@ -201,7 +201,7 @@ static int run_trigger_thread(int i) case_type = i; - if (_is_user_context()) { + if (k_is_user_context()) { perm = perm | K_USER; }