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 /** POSIX wrapper for THREADX                                             */
17 /**                                                                       */
18 /**                                                                       */
19 /**                                                                       */
20 /**************************************************************************/
21 /**************************************************************************/
22 
23 /* Include necessary system files.  */
24 
25 #include "tx_api.h"     /* Threadx API */
26 #include "pthread.h"    /* Posix API */
27 #include "px_int.h"     /* Posix helper functions */
28 
29 
30 /**************************************************************************/
31 /*                                                                        */
32 /*  FUNCTION                                               RELEASE        */
33 /*                                                                        */
34 /*    posix_reset_queue                                  PORTABLE C       */
35 /*                                                           6.1.7        */
36 /*  AUTHOR                                                                */
37 /*                                                                        */
38 /*    William E. Lamie, Microsoft Corporation                             */
39 /*                                                                        */
40 /*  DESCRIPTION                                                           */
41 /*                                                                        */
42 /*    This function resets a message queue structure                      */
43 /*                                                                        */
44 /*  INPUT                                                                 */
45 /*                                                                        */
46 /*    q_ptr                                 q_ptr                         */
47 /*                                                                        */
48 /*  OUTPUT                                                                */
49 /*                                                                        */
50 /*    None                                                                */
51 /*                                                                        */
52 /*  CALLS                                                                 */
53 /*                                                                        */
54 /*    tx_byte_pool_delete                   Deletes byte pool             */
55 /*    posix_internal_error                  Returns generic error         */
56 /*                                                                        */
57 /*  CALLED BY                                                             */
58 /*                                                                        */
59 /*    POSIX internal code                                                 */
60 /*                                                                        */
61 /*  RELEASE HISTORY                                                       */
62 /*                                                                        */
63 /*    DATE              NAME                      DESCRIPTION             */
64 /*                                                                        */
65 /*  06-02-2021     William E. Lamie         Initial Version 6.1.7         */
66 /*                                                                        */
67 /**************************************************************************/
posix_reset_queue(POSIX_MSG_QUEUE * q_ptr)68 VOID posix_reset_queue(POSIX_MSG_QUEUE * q_ptr)
69 {
70     /* Indicate this entry is not in use.  */
71     q_ptr->in_use = TX_FALSE;
72 
73     /* Reset thread name to NULL string.  */
74     q_ptr -> name = NULL;
75 
76     /* Reset open count.  */
77     q_ptr -> open_count = 0;
78 
79     /* Reset storage */
80     q_ptr -> storage = NULL;
81 
82     /* Delete message area.  */
83     if (tx_byte_pool_delete(&(q_ptr ->vq_message_area)))
84     {
85         /* Internal error.  */
86         posix_internal_error(444);
87     }
88     /* Reset queue id.  */
89     q_ptr -> px_queue_id = 0;
90 
91     /* Reset Unlink Flag  */
92     q_ptr -> unlink_flag = TX_FALSE;
93 }
94