Skip to content

Commit 5133cf5

Browse files
AdithyaBaglodyAnas Nashif
authored and
Anas Nashif
committed
kernel: thread: Move out the function _thread_entry() to lib
The _thread_entry() is not really a part of the kernel but a part of the zephyr's C runtime support library. Hence moving just the function to lib/thread_entry.c Signed-off-by: Adithya Baglody <[email protected]>
1 parent d70196b commit 5133cf5

File tree

3 files changed

+46
-31
lines changed

3 files changed

+46
-31
lines changed

kernel/thread.c

-31
Original file line numberDiff line numberDiff line change
@@ -208,37 +208,6 @@ void _check_stack_sentinel(void)
208208
}
209209
#endif
210210

211-
/*
212-
* Common thread entry point function (used by all threads)
213-
*
214-
* This routine invokes the actual thread entry point function and passes
215-
* it three arguments. It also handles graceful termination of the thread
216-
* if the entry point function ever returns.
217-
*
218-
* This routine does not return, and is marked as such so the compiler won't
219-
* generate preamble code that is only used by functions that actually return.
220-
*/
221-
FUNC_NORETURN void _thread_entry(k_thread_entry_t entry,
222-
void *p1, void *p2, void *p3)
223-
{
224-
entry(p1, p2, p3);
225-
226-
#ifdef CONFIG_MULTITHREADING
227-
k_thread_abort(k_current_get());
228-
#else
229-
for (;;) {
230-
k_cpu_idle();
231-
}
232-
#endif
233-
234-
/*
235-
* Compiler can't tell that k_thread_abort() won't return and issues a
236-
* warning unless we tell it that control never gets this far.
237-
*/
238-
239-
CODE_UNREACHABLE;
240-
}
241-
242211
#ifdef CONFIG_MULTITHREADING
243212
void _impl_k_thread_start(struct k_thread *thread)
244213
{

lib/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
zephyr_sources(thread_entry.c)
12
add_subdirectory(crc)
23
add_subdirectory_ifdef(CONFIG_JSON_LIBRARY json)
34
if(NOT CONFIG_NATIVE_APPLICATION)

lib/thread_entry.c

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright (c) 2018 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/**
8+
* @file
9+
* @brief Thread entry
10+
*
11+
* This file provides the common thread entry function
12+
*/
13+
14+
#include <kernel.h>
15+
16+
/*
17+
* Common thread entry point function (used by all threads)
18+
*
19+
* This routine invokes the actual thread entry point function and passes
20+
* it three arguments. It also handles graceful termination of the thread
21+
* if the entry point function ever returns.
22+
*
23+
* This routine does not return, and is marked as such so the compiler won't
24+
* generate preamble code that is only used by functions that actually return.
25+
*/
26+
FUNC_NORETURN void _thread_entry(k_thread_entry_t entry,
27+
void *p1, void *p2, void *p3)
28+
{
29+
entry(p1, p2, p3);
30+
31+
#ifdef CONFIG_MULTITHREADING
32+
k_thread_abort(k_current_get());
33+
#else
34+
for (;;) {
35+
k_cpu_idle();
36+
}
37+
#endif
38+
39+
/*
40+
* Compiler can't tell that k_thread_abort() won't return and issues a
41+
* warning unless we tell it that control never gets this far.
42+
*/
43+
44+
CODE_UNREACHABLE;
45+
}

0 commit comments

Comments
 (0)