1 /*-------------------------------------------------------------
3 message.h -- Thread subsystem II
6 Michael Wiedenbauer (shagkur)
7 Dave Murphy (WinterMute)
9 This software is provided 'as-is', without any express or implied
10 warranty. In no event will the authors be held liable for any
11 damages arising from the use of this software.
13 Permission is granted to anyone to use this software for any
14 purpose, including commercial applications, and to alter it and
15 redistribute it freely, subject to the following restrictions:
17 1. The origin of this software must not be misrepresented; you
18 must not claim that you wrote the original software. If you use
19 this software in a product, an acknowledgment in the product
20 documentation would be appreciated but is not required.
22 2. Altered source versions must be plainly marked as such, and
23 must not be misrepresented as being the original software.
25 3. This notice may not be removed or altered from any source
28 -------------------------------------------------------------*/
35 \brief Thread subsystem II
41 #define MQ_BOX_NULL 0xffffffff
43 #define MQ_ERROR_SUCCESSFUL 0
44 #define MQ_ERROR_TOOMANY -5
46 #define MQ_MSG_BLOCK 0
47 #define MQ_MSG_NOBLOCK 1
55 /*! \typedef u32 mqbox_t
56 \brief typedef for the message queue handle
61 /*! \typedef void* mqmsg_t
62 \brief typedef for the message pointer
64 typedef void* mqmsg_t
;
68 /*! \fn u32 MQ_Init(mqbox_t *mqbox,u32 count)
69 \brief Initializes a message queue
70 \param[out] mqbox pointer to the mqbox_t handle.
71 \param[in] count maximum number of messages the queue can hold
73 \return 0 on success, <0 on error
75 s32
MQ_Init(mqbox_t
*mqbox
,u32 count
);
78 /*! \fn void MQ_Close(mqbox_t mqbox)
79 \brief Closes the message queue and releases all memory.
80 \param[in] mqbox handle to the mqbox_t structure.
84 void MQ_Close(mqbox_t mqbox
);
87 /*! \fn BOOL MQ_Send(mqbox_t mqbox,mqmsg_t msg,u32 flags)
88 \brief Sends a message to the given message queue.
89 \param[in] mqbox mqbox_t handle to the message queue
90 \param[in] msg message to send
91 \param[in] flags message flags (MQ_MSG_BLOCK, MQ_MSG_NOBLOCK)
93 \return boolean result
95 BOOL
MQ_Send(mqbox_t mqbox
,mqmsg_t msg
,u32 flags
);
98 /*! \fn BOOL MQ_Jam(mqbox_t mqbox,mqmsg_t msg,u32 flags)
99 \brief Sends a message to the given message queue and jams it in front of the queue.
100 \param[in] mqbox mqbox_t handle to the message queue
101 \param[in] msg message to send
102 \param[in] flags message flags (MQ_MSG_BLOCK, MQ_MSG_NOBLOCK)
104 \return boolean result
106 BOOL
MQ_Jam(mqbox_t mqbox
,mqmsg_t msg
,u32 flags
);
109 /*! \fn BOOL MQ_Receive(mqbox_t mqbox,mqmsg_t *msg,u32 flags)
110 \brief Sends a message to the given message queue.
111 \param[in] mqbox mqbox_t handle to the message queue
112 \param[in] msg pointer to a mqmsg_t_t-type message to receive.
113 \param[in] flags message flags (MQ_MSG_BLOCK, MQ_MSG_NOBLOCK)
115 \return boolean result
117 BOOL
MQ_Receive(mqbox_t mqbox
,mqmsg_t
*msg
,u32 flags
);