diff --git a/lib/libc/armstdc/CMakeLists.txt b/lib/libc/armstdc/CMakeLists.txt index b92f061b411..8a15fdf4ae4 100644 --- a/lib/libc/armstdc/CMakeLists.txt +++ b/lib/libc/armstdc/CMakeLists.txt @@ -4,5 +4,6 @@ zephyr_library() zephyr_library_sources(src/errno.c) zephyr_library_sources(src/string.c) zephyr_library_sources(src/libc-hooks.c) +zephyr_library_sources_ifndef(CONFIG_MULTITHREADING src/threading_weak.c) zephyr_system_include_directories(include) diff --git a/lib/libc/armstdc/src/threading_weak.c b/lib/libc/armstdc/src/threading_weak.c new file mode 100644 index 00000000000..0b01600255b --- /dev/null +++ b/lib/libc/armstdc/src/threading_weak.c @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/* + * Weak stub implementation of threading related kernel functions. + * + * This file is needed for armlink. + * + * When linking with armlink the linker will resolve undefined symbols for all + * undefined functions even if those functions the reference the undefined + * symbol is never actually called. + * + * This file provides weak stub implementations that are compiled when + * CONFIG_MULTITHREADING=n to ensure proper linking. + */ + +#include + +int __weak z_impl_k_mutex_init(struct k_mutex *mutex) +{ + return 0; +} + +int __weak z_impl_k_mutex_lock(struct k_mutex *mutex, k_timeout_t timeout) +{ + return 0; +} + +int __weak z_impl_k_mutex_unlock(struct k_mutex *mutex) +{ + return 0; +} + +void __weak z_impl_k_sem_give(struct k_sem *sem) +{ +} + +int __weak z_impl_k_sem_init(struct k_sem *sem, unsigned int initial_count, + unsigned int limit) +{ + return 0; +} + +int __weak z_impl_k_sem_take(struct k_sem *sem, k_timeout_t timeout) +{ + return 0; +} + +k_tid_t __weak z_impl_z_current_get(void) +{ + return 0; +} + +int32_t __weak z_impl_k_usleep(int us) +{ + return 0; +} + +void __weak z_thread_abort(struct k_thread *thread) +{ +} + +void __weak k_sched_lock(void) +{ +} + +void __weak k_sched_unlock(void) +{ +}