From 8618716c681c6ae619b2cf81033df2bac681c1d9 Mon Sep 17 00:00:00 2001 From: Adithya Baglody Date: Wed, 28 Mar 2018 15:16:48 +0530 Subject: [PATCH] kernel: Cmake: Add __ZEPHYR_SUPERVISOR__ macro for kernel files. Normally a syscall would check the current privilege level and then decide to go to _impl_ directly or go through a _handler_. __ZEPHYR_SUPERVISOR__ is a compiler optimization flag which will make all the system calls from the kernel files directly link to the _impl_. Thereby reducing the overhead of checking the privileges. Signed-off-by: Adithya Baglody --- kernel/CMakeLists.txt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/kernel/CMakeLists.txt b/kernel/CMakeLists.txt index b5e1f6f3fe9..267cdd65068 100644 --- a/kernel/CMakeLists.txt +++ b/kernel/CMakeLists.txt @@ -23,7 +23,16 @@ add_library(kernel version.c work_q.c smp.c -) + ) + +# Kernel files has the macro __ZEPHYR_SUPERVISOR__ set so that it +# optimizes the code when userspace is enabled. +set_target_properties( + kernel + PROPERTIES + COMPILE_DEFINITIONS + __ZEPHYR_SUPERVISOR__ + ) target_sources_ifdef(CONFIG_INT_LATENCY_BENCHMARK kernel PRIVATE int_latency_bench.c) target_sources_ifdef(CONFIG_STACK_CANARIES kernel PRIVATE compiler_stack_protect.c) @@ -43,6 +52,7 @@ target_sources_ifdef( userspace.c ) + add_dependencies(kernel offsets_h) target_link_libraries(kernel zephyr_interface)