armclang: threading_weak.c source file added for armclang

The stub file threading_weak.c has been added containing weak stub
implementation of threading related kernel functions.

The 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.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit is contained in:
Torsten Rasmussen 2021-08-24 15:32:14 +02:00 committed by Anas Nashif
commit 16e848b57c
2 changed files with 73 additions and 0 deletions

View file

@ -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)

View file

@ -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 <kernel.h>
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)
{
}