Skip to content

Commit 16e848b

Browse files
tejlmandnashif
authored andcommitted
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 <[email protected]>
1 parent 36bb00d commit 16e848b

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

lib/libc/armstdc/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ zephyr_library()
44
zephyr_library_sources(src/errno.c)
55
zephyr_library_sources(src/string.c)
66
zephyr_library_sources(src/libc-hooks.c)
7+
zephyr_library_sources_ifndef(CONFIG_MULTITHREADING src/threading_weak.c)
78

89
zephyr_system_include_directories(include)
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
* Copyright (c) 2021 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/*
8+
* Weak stub implementation of threading related kernel functions.
9+
*
10+
* This file is needed for armlink.
11+
*
12+
* When linking with armlink the linker will resolve undefined symbols for all
13+
* undefined functions even if those functions the reference the undefined
14+
* symbol is never actually called.
15+
*
16+
* This file provides weak stub implementations that are compiled when
17+
* CONFIG_MULTITHREADING=n to ensure proper linking.
18+
*/
19+
20+
#include <kernel.h>
21+
22+
int __weak z_impl_k_mutex_init(struct k_mutex *mutex)
23+
{
24+
return 0;
25+
}
26+
27+
int __weak z_impl_k_mutex_lock(struct k_mutex *mutex, k_timeout_t timeout)
28+
{
29+
return 0;
30+
}
31+
32+
int __weak z_impl_k_mutex_unlock(struct k_mutex *mutex)
33+
{
34+
return 0;
35+
}
36+
37+
void __weak z_impl_k_sem_give(struct k_sem *sem)
38+
{
39+
}
40+
41+
int __weak z_impl_k_sem_init(struct k_sem *sem, unsigned int initial_count,
42+
unsigned int limit)
43+
{
44+
return 0;
45+
}
46+
47+
int __weak z_impl_k_sem_take(struct k_sem *sem, k_timeout_t timeout)
48+
{
49+
return 0;
50+
}
51+
52+
k_tid_t __weak z_impl_z_current_get(void)
53+
{
54+
return 0;
55+
}
56+
57+
int32_t __weak z_impl_k_usleep(int us)
58+
{
59+
return 0;
60+
}
61+
62+
void __weak z_thread_abort(struct k_thread *thread)
63+
{
64+
}
65+
66+
void __weak k_sched_lock(void)
67+
{
68+
}
69+
70+
void __weak k_sched_unlock(void)
71+
{
72+
}

0 commit comments

Comments
 (0)