Branch data Line data Source code
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 : : #ifdef CONFIG_THREAD_LOCAL_STORAGE 17 : : __thread k_tid_t z_tls_current; 18 : : #endif 19 : : 20 : : /* 21 : : * Common thread entry point function (used by all threads) 22 : : * 23 : : * This routine invokes the actual thread entry point function and passes 24 : : * it three arguments. It also handles graceful termination of the thread 25 : : * if the entry point function ever returns. 26 : : * 27 : : * This routine does not return, and is marked as such so the compiler won't 28 : : * generate preamble code that is only used by functions that actually return. 29 : : */ 30 : 2 : FUNC_NORETURN void z_thread_entry(k_thread_entry_t entry, 31 : : void *p1, void *p2, void *p3) 32 : : { 33 : : #ifdef CONFIG_THREAD_LOCAL_STORAGE 34 : : z_tls_current = z_current_get(); 35 : : #endif 36 : 2 : entry(p1, p2, p3); 37 : : 38 : 1 : k_thread_abort(k_current_get()); 39 : : 40 : : /* 41 : : * Compiler can't tell that k_thread_abort() won't return and issues a 42 : : * warning unless we tell it that control never gets this far. 43 : : */ 44 : : 45 : : CODE_UNREACHABLE; /* LCOV_EXCL_LINE */ 46 : : }