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_get_queue_desc PORTABLE C */
35 /* 6.1.7 */
36 /* AUTHOR */
37 /* */
38 /* William E. Lamie, Microsoft Corporation */
39 /* */
40 /* DESCRIPTION */
41 /* */
42 /* This function returns a message queue descriptor pointer of valid */
43 /* message queue */
44 /* */
45 /* INPUT */
46 /* */
47 /* q_ptr message queue pointer */
48 /* */
49 /* OUTPUT */
50 /* */
51 /* q_des message queue descriptor */
52 /* */
53 /* CALLS */
54 /* */
55 /* posix_internal_error Returns a Generic error */
56 /* tx_byte_allocate Allocates bytes */
57 /* */
58 /* CALLED BY */
59 /* */
60 /* POSIX internal Code */
61 /* */
62 /* RELEASE HISTORY */
63 /* */
64 /* DATE NAME DESCRIPTION */
65 /* */
66 /* 06-02-2021 William E. Lamie Initial Version 6.1.7 */
67 /* */
68 /**************************************************************************/
posix_get_queue_des(POSIX_MSG_QUEUE * q_ptr)69 struct mq_des * posix_get_queue_des(POSIX_MSG_QUEUE * q_ptr)
70 {
71
72 struct mq_des *q_des = NULL;
73 VOID *bp;
74
75 /* allocate the system resource allocated by open call. */
76 if( tx_byte_allocate((TX_BYTE_POOL *)&posix_heap_byte_pool, &bp,
77 sizeof(struct mq_des), TX_NO_WAIT))
78 {
79 /* return generic error. */
80 posix_internal_error(100);
81 /* Return error. */
82 return((struct mq_des *)ERROR);
83 }
84 q_des = (struct mq_des *)bp;
85 /* Get message queue data to mq_des structure. */
86 q_des->f_data = q_ptr;
87 return(q_des);
88 }
89