1 /**************************************************************************/
2 /*                                                                        */
3 /*       Copyright (c) Microsoft Corporation. All rights reserved.        */
4 /*                                                                        */
5 /*       This software is licensed under the Microsoft Software License   */
6 /*       Terms for Microsoft Azure RTOS. Full text of the license can be  */
7 /*       found in the LICENSE file at https://aka.ms/AzureRTOS_EULA       */
8 /*       and in the root directory of this software.                      */
9 /*                                                                        */
10 /**************************************************************************/
11 
12 
13 /**************************************************************************/
14 /**************************************************************************/
15 /**                                                                       */
16 /** ThreadX Component                                                     */
17 /**                                                                       */
18 /**   Semaphore                                                           */
19 /**                                                                       */
20 /**************************************************************************/
21 /**************************************************************************/
22 
23 #define TX_SOURCE_CODE
24 
25 
26 /* Include necessary system files.  */
27 
28 #include "tx_api.h"
29 #include "tx_semaphore.h"
30 
31 
32 /**************************************************************************/
33 /*                                                                        */
34 /*  FUNCTION                                               RELEASE        */
35 /*                                                                        */
36 /*    _txe_semaphore_put_notify                           PORTABLE C      */
37 /*                                                           6.1          */
38 /*  AUTHOR                                                                */
39 /*                                                                        */
40 /*    William E. Lamie, Microsoft Corporation                             */
41 /*                                                                        */
42 /*  DESCRIPTION                                                           */
43 /*                                                                        */
44 /*    This function checks for errors in the semaphore put notify         */
45 /*    callback function call.                                             */
46 /*                                                                        */
47 /*  INPUT                                                                 */
48 /*                                                                        */
49 /*    semaphore_ptr                         Pointer to semaphore          */
50 /*    semaphore_put_notify                  Application callback function */
51 /*                                            (TX_NULL disables notify)   */
52 /*                                                                        */
53 /*  OUTPUT                                                                */
54 /*                                                                        */
55 /*    status                                Service return status         */
56 /*                                                                        */
57 /*  CALLS                                                                 */
58 /*                                                                        */
59 /*    _tx_semaphore_put_notify              Actual semaphore put notify   */
60 /*                                            call                        */
61 /*                                                                        */
62 /*  CALLED BY                                                             */
63 /*                                                                        */
64 /*    Application Code                                                    */
65 /*                                                                        */
66 /*  RELEASE HISTORY                                                       */
67 /*                                                                        */
68 /*    DATE              NAME                      DESCRIPTION             */
69 /*                                                                        */
70 /*  05-19-2020     William E. Lamie         Initial Version 6.0           */
71 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
72 /*                                            resulting in version 6.1    */
73 /*                                                                        */
74 /**************************************************************************/
_txe_semaphore_put_notify(TX_SEMAPHORE * semaphore_ptr,VOID (* semaphore_put_notify)(TX_SEMAPHORE * notify_semaphore_ptr))75 UINT  _txe_semaphore_put_notify(TX_SEMAPHORE *semaphore_ptr, VOID (*semaphore_put_notify)(TX_SEMAPHORE *notify_semaphore_ptr))
76 {
77 
78 UINT    status;
79 
80 
81     /* Check for an invalid semaphore pointer.  */
82     if (semaphore_ptr == TX_NULL)
83     {
84 
85         /* Semaphore pointer is invalid, return appropriate error code.  */
86         status =  TX_SEMAPHORE_ERROR;
87     }
88 
89     /* Now check for invalid semaphore ID.  */
90     else if (semaphore_ptr -> tx_semaphore_id != TX_SEMAPHORE_ID)
91     {
92 
93         /* Semaphore pointer is invalid, return appropriate error code.  */
94         status =  TX_SEMAPHORE_ERROR;
95     }
96     else
97     {
98 
99         /* Call actual semaphore put notify function.  */
100         status =  _tx_semaphore_put_notify(semaphore_ptr, semaphore_put_notify);
101     }
102 
103     /* Return completion status.  */
104     return(status);
105 }
106 
107