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_queue_delete PORTABLE C */
35 /* 6.1.7 */
36 /* AUTHOR */
37 /* */
38 /* William E. Lamie, Microsoft Corporation */
39 /* */
40 /* DESCRIPTION */
41 /* */
42 /* deletes a message queue */
43 /* */
44 /* INPUT */
45 /* */
46 /* q_ptr message queue pointer */
47 /* */
48 /* OUTPUT */
49 /* */
50 /* ERROR If fails */
51 /* OK If successful */
52 /* */
53 /* CALLS */
54 /* */
55 /* tx_queue_delete Detectes a Queue */
56 /* posix_internal_error Generic error */
57 /* posix_reset queue Resets queue structure */
58 /* */
59 /* CALLED BY */
60 /* */
61 /* POSIX internal Code */
62 /* */
63 /* RELEASE HISTORY */
64 /* */
65 /* DATE NAME DESCRIPTION */
66 /* */
67 /* 06-02-2021 William E. Lamie Initial Version 6.1.7 */
68 /* */
69 /**************************************************************************/
posix_queue_delete(POSIX_MSG_QUEUE * q_ptr)70 INT posix_queue_delete(POSIX_MSG_QUEUE * q_ptr)
71 {
72
73 TX_QUEUE *queue;
74
75 queue = &(q_ptr->queue);
76
77 /* Delete the Threadx queue. */
78 if(tx_queue_delete(queue))
79 {
80 /* return generic error. */
81 posix_internal_error(444);
82 /* return error. */
83 return(ERROR);
84 }
85
86 /* Release the queue back to the pool. */
87 posix_reset_queue(q_ptr);
88 q_ptr = NULL;
89 return(OK);
90 }
91