kernel: dynamic: declare dynamic stubs when disabled
With some of the recent work to disable unnecessary system calls, there is a scenario where `z_impl_k_thread_stack_free()` is not defined and an undefined symbol error occurs. Safety was very concerned that dynamic thread stack code might touch other code that does not malloc, so add a separate file for the stack alloc and free stubs. Signed-off-by: Christopher Friedt <cfriedt@meta.com>
This commit is contained in:
parent
dcdebb616a
commit
d7119b889f
|
@ -289,6 +289,7 @@ __syscall k_thread_stack_t *k_thread_stack_alloc(size_t size, int flags);
|
|||
* @retval 0 on success.
|
||||
* @retval -EBUSY if the thread stack is in use.
|
||||
* @retval -EINVAL if @p stack is invalid.
|
||||
* @retval -ENOSYS if dynamic thread stack allocation is disabled
|
||||
*
|
||||
* @see CONFIG_DYNAMIC_THREAD
|
||||
*/
|
||||
|
|
|
@ -123,11 +123,11 @@ target_sources_ifdef(
|
|||
userspace.c
|
||||
)
|
||||
|
||||
target_sources_ifdef(
|
||||
CONFIG_DYNAMIC_THREAD
|
||||
kernel PRIVATE
|
||||
dynamic.c
|
||||
)
|
||||
if(${CONFIG_DYNAMIC_THREAD})
|
||||
target_sources(kernel PRIVATE dynamic.c)
|
||||
else()
|
||||
target_sources(kernel PRIVATE dynamic_disabled.c)
|
||||
endif()
|
||||
|
||||
target_include_directories(kernel PRIVATE
|
||||
${ZEPHYR_BASE}/kernel/include
|
||||
|
|
25
kernel/dynamic_disabled.c
Normal file
25
kernel/dynamic_disabled.c
Normal file
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Meta
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
#include <zephyr/kernel.h>
|
||||
#include <zephyr/kernel/thread_stack.h>
|
||||
|
||||
k_thread_stack_t *z_impl_k_thread_stack_alloc(size_t size, int flags)
|
||||
{
|
||||
ARG_UNUSED(size);
|
||||
ARG_UNUSED(flags);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int z_impl_k_thread_stack_free(k_thread_stack_t *stack)
|
||||
{
|
||||
ARG_UNUSED(stack);
|
||||
|
||||
return -ENOSYS;
|
||||
}
|
Loading…
Reference in a new issue