From 78eb718396a9eabc03c825fe84281bf9a023a783 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Zi=C4=99cik?= Date: Thu, 22 Aug 2019 11:03:34 +0200 Subject: [PATCH] syscalls: Export _is_user_context() regardless of CONFIG_USERSPACE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit exports the _is_user_context() function regardless of the CONFIG_USERSPACE setting. If userspace is enabled, the value returned depends on the execution context. If userspace is disabled, the _is_user_context() always returns false. Signed-off-by: Piotr Zięcik --- include/syscall.h | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/include/syscall.h b/include/syscall.h index 724b18e066d..cd27a833540 100644 --- a/include/syscall.h +++ b/include/syscall.h @@ -115,23 +115,6 @@ typedef u32_t (*_k_syscall_handler_t)(u32_t arg1, u32_t arg2, u32_t arg3, void *ssf); #ifdef CONFIG_USERSPACE -/** - * Indicate whether we are currently running in user mode - * - * @return true if the CPU is currently running with user permissions - */ -static inline bool z_arch_is_user_context(void); - -/** - * Indicate whether the CPU is currently in user mode - * - * @return true if the CPU is currently running with user permissions - */ -static inline bool _is_user_context(void) -{ - return z_arch_is_user_context(); -} - /* * Helper data structures for system calls with large argument lists */ @@ -271,8 +254,29 @@ static inline u64_t z_syscall_ret64_invoke2(u32_t arg1, u32_t arg2, return ret; } +/** + * Indicate whether we are currently running in user mode + * + * @return true if the CPU is currently running with user permissions + */ +static inline bool z_arch_is_user_context(void); + #endif /* CONFIG_USERSPACE */ +/** + * Indicate whether the CPU is currently in user mode + * + * @return true if the CPU is currently running with user permissions + */ +static inline bool _is_user_context(void) +{ +#ifdef CONFIG_USERSPACE + return z_arch_is_user_context(); +#else + return false; +#endif +} + #ifdef __cplusplus } #endif