1 /***************************************************************************
2 * Copyright (c) 2024 Microsoft Corporation
3 *
4 * This program and the accompanying materials are made available under the
5 * terms of the MIT License which is available at
6 * https://opensource.org/licenses/MIT.
7 *
8 * SPDX-License-Identifier: MIT
9 **************************************************************************/
10
11
12 /**************************************************************************/
13 /**************************************************************************/
14 /** */
15 /** ThreadX Component */
16 /** */
17 /** Thread */
18 /** */
19 /**************************************************************************/
20 /**************************************************************************/
21
22 #define TX_SOURCE_CODE
23
24
25 /* Include necessary system files. */
26
27 #include "tx_api.h"
28 #include "tx_thread.h"
29
30
31 /**************************************************************************/
32 /* */
33 /* FUNCTION RELEASE */
34 /* */
35 /* _txe_thread_delete PORTABLE C */
36 /* 6.1 */
37 /* AUTHOR */
38 /* */
39 /* William E. Lamie, Microsoft Corporation */
40 /* */
41 /* DESCRIPTION */
42 /* */
43 /* This function checks for errors in the thread delete function call. */
44 /* */
45 /* INPUT */
46 /* */
47 /* thread_ptr Pointer to thread to suspend */
48 /* */
49 /* OUTPUT */
50 /* */
51 /* TX_THREAD_ERROR Invalid thread pointer */
52 /* TX_CALLER_ERROR Invalid caller of function */
53 /* status Actual completion status */
54 /* */
55 /* CALLS */
56 /* */
57 /* _tx_thread_delete Actual thread delete function */
58 /* */
59 /* CALLED BY */
60 /* */
61 /* Application code */
62 /* */
63 /* RELEASE HISTORY */
64 /* */
65 /* DATE NAME DESCRIPTION */
66 /* */
67 /* 05-19-2020 William E. Lamie Initial Version 6.0 */
68 /* 09-30-2020 Yuxin Zhou Modified comment(s), */
69 /* resulting in version 6.1 */
70 /* */
71 /**************************************************************************/
_txe_thread_delete(TX_THREAD * thread_ptr)72 UINT _txe_thread_delete(TX_THREAD *thread_ptr)
73 {
74
75 UINT status;
76
77
78 /* Check for invalid caller of this function. */
79 if (TX_THREAD_GET_SYSTEM_STATE() != ((ULONG) 0))
80 {
81
82 /* Invalid caller of this function, return appropriate error code. */
83 status = TX_CALLER_ERROR;
84 }
85
86 /* Check for an invalid thread pointer. */
87 else if (thread_ptr == TX_NULL)
88 {
89
90 /* Thread pointer is invalid, return appropriate error code. */
91 status = TX_THREAD_ERROR;
92 }
93
94 /* Now check for invalid thread ID. */
95 else if (thread_ptr -> tx_thread_id != TX_THREAD_ID)
96 {
97
98 /* Thread pointer is invalid, return appropriate error code. */
99 status = TX_THREAD_ERROR;
100 }
101 else
102 {
103
104 /* Call actual thread delete function. */
105 status = _tx_thread_delete(thread_ptr);
106 }
107
108 /* Return completion status. */
109 return(status);
110 }
111
112