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 /** Queue */
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_queue.h"
29
30
31 /**************************************************************************/
32 /* */
33 /* FUNCTION RELEASE */
34 /* */
35 /* _txe_queue_flush 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 queue flush function call. */
44 /* */
45 /* INPUT */
46 /* */
47 /* queue_ptr Pointer to queue control block */
48 /* */
49 /* OUTPUT */
50 /* */
51 /* TX_QUEUE_ERROR Invalid queue pointer */
52 /* TX_CALLER_ERROR Invalid caller of this function */
53 /* status Actual completion status */
54 /* */
55 /* CALLS */
56 /* */
57 /* _tx_queue_flush Actual queue flush 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_queue_flush(TX_QUEUE * queue_ptr)72 UINT _txe_queue_flush(TX_QUEUE *queue_ptr)
73 {
74
75 UINT status;
76
77
78 /* Check for an invalid queue pointer. */
79 if (queue_ptr == TX_NULL)
80 {
81
82 /* Queue pointer is invalid, return appropriate error code. */
83 status = TX_QUEUE_ERROR;
84 }
85
86 /* Now check for invalid queue ID. */
87 else if (queue_ptr -> tx_queue_id != TX_QUEUE_ID)
88 {
89
90 /* Queue pointer is invalid, return appropriate error code. */
91 status = TX_QUEUE_ERROR;
92 }
93 else
94 {
95
96 /* Call actual queue flush function. */
97 status = _tx_queue_flush(queue_ptr);
98 }
99
100 /* Return completion status. */
101 return(status);
102 }
103
104