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_send_notify                              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 send notify            */
44 /*    callback function call.                                             */
45 /*                                                                        */
46 /*  INPUT                                                                 */
47 /*                                                                        */
48 /*    queue_ptr                             Pointer to queue control block*/
49 /*    queue_send_notify                     Application callback function */
50 /*                                            (TX_NULL disables notify)   */
51 /*                                                                        */
52 /*  OUTPUT                                                                */
53 /*                                                                        */
54 /*    status                                Completion status             */
55 /*                                                                        */
56 /*  CALLS                                                                 */
57 /*                                                                        */
58 /*    _tx_queue_send_notify                 Actual queue send notify call */
59 /*                                                                        */
60 /*  CALLED BY                                                             */
61 /*                                                                        */
62 /*    Application Code                                                    */
63 /*                                                                        */
64 /*  RELEASE HISTORY                                                       */
65 /*                                                                        */
66 /*    DATE              NAME                      DESCRIPTION             */
67 /*                                                                        */
68 /*  05-19-2020     William E. Lamie         Initial Version 6.0           */
69 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
70 /*                                            resulting in version 6.1    */
71 /*                                                                        */
72 /**************************************************************************/
_txe_queue_send_notify(TX_QUEUE * queue_ptr,VOID (* queue_send_notify)(TX_QUEUE * notify_queue_ptr))73 UINT  _txe_queue_send_notify(TX_QUEUE *queue_ptr, VOID (*queue_send_notify)(TX_QUEUE *notify_queue_ptr))
74 {
75 
76 UINT    status;
77 
78 
79     /* Check for an invalid queue pointer.  */
80     if (queue_ptr == TX_NULL)
81     {
82 
83         /* Queue pointer is invalid, return appropriate error code.  */
84         status =  TX_QUEUE_ERROR;
85     }
86 
87     /* Now check for a valid queue ID.  */
88     else if (queue_ptr -> tx_queue_id != TX_QUEUE_ID)
89     {
90 
91         /* Queue pointer is invalid, return appropriate error code.  */
92         status =  TX_QUEUE_ERROR;
93     }
94     else
95     {
96 
97         /* Call actual queue send notify function.  */
98         status =  _tx_queue_send_notify(queue_ptr, queue_send_notify);
99     }
100 
101     /* Return completion status.  */
102     return(status);
103 }
104 
105