msg type should be char * not void * in mq_send, mq_timedsend, mq_receive, and mq_timedreceive. Noted by Pierre-Noel Bouteville
This commit is contained in:
parent
0f7d152df2
commit
ad05793c0f
@ -69,33 +69,34 @@ struct mq_attr
|
||||
typedef FAR struct mq_des *mqd_t;
|
||||
|
||||
/********************************************************************************
|
||||
* Global Variables
|
||||
********************************************************************************/
|
||||
|
||||
/********************************************************************************
|
||||
* Global Function Prototypes
|
||||
* Public Data
|
||||
********************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN extern "C"
|
||||
extern "C" {
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
EXTERN mqd_t mq_open(const char *mq_name, int oflags, ...);
|
||||
EXTERN int mq_close(mqd_t mqdes );
|
||||
EXTERN int mq_unlink(const char *mq_name);
|
||||
EXTERN int mq_send(mqd_t mqdes, const void *msg, size_t msglen, int prio);
|
||||
EXTERN int mq_timedsend(mqd_t mqdes, const char *msg, size_t msglen, int prio,
|
||||
const struct timespec *abstime);
|
||||
EXTERN ssize_t mq_receive(mqd_t mqdes, void *msg, size_t msglen, int *prio);
|
||||
EXTERN ssize_t mq_timedreceive(mqd_t mqdes, void *msg, size_t msglen,
|
||||
int *prio, const struct timespec *abstime);
|
||||
EXTERN int mq_notify(mqd_t mqdes, const struct sigevent *notification);
|
||||
EXTERN int mq_setattr(mqd_t mqdes, const struct mq_attr *mq_stat,
|
||||
struct mq_attr *oldstat);
|
||||
EXTERN int mq_getattr(mqd_t mqdes, struct mq_attr *mq_stat);
|
||||
/********************************************************************************
|
||||
* Public Function Prototypes
|
||||
********************************************************************************/
|
||||
|
||||
mqd_t mq_open(FAR const char *mq_name, int oflags, ...);
|
||||
int mq_close(mqd_t mqdes );
|
||||
int mq_unlink(FAR const char *mq_name);
|
||||
int mq_send(mqd_t mqdes, FAR const char *msg, size_t msglen, int prio);
|
||||
int mq_timedsend(mqd_t mqdes, FAR const char *msg, size_t msglen, int prio,
|
||||
FAR const struct timespec *abstime);
|
||||
ssize_t mq_receive(mqd_t mqdes, FAR char *msg, size_t msglen, FAR int *prio);
|
||||
ssize_t mq_timedreceive(mqd_t mqdes, FAR char *msg, size_t msglen, FAR int *prio,
|
||||
FAR const struct timespec *abstime);
|
||||
int mq_notify(mqd_t mqdes, const struct sigevent *notification);
|
||||
int mq_setattr(mqd_t mqdes, FAR const struct mq_attr *mq_stat,
|
||||
FAR struct mq_attr *oldstat);
|
||||
int mq_getattr(mqd_t mqdes, FAR struct mq_attr *mq_stat);
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
|
@ -103,7 +103,7 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int mq_verifyreceive(mqd_t mqdes, void *msg, size_t msglen)
|
||||
int mq_verifyreceive(mqd_t mqdes, FAR char *msg, size_t msglen)
|
||||
{
|
||||
/* Verify the input parameters */
|
||||
|
||||
@ -246,7 +246,7 @@ FAR struct mqueue_msg_s *mq_waitreceive(mqd_t mqdes)
|
||||
****************************************************************************/
|
||||
|
||||
ssize_t mq_doreceive(mqd_t mqdes, FAR struct mqueue_msg_s *mqmsg,
|
||||
FAR void *ubuffer, int *prio)
|
||||
FAR char *ubuffer, int *prio)
|
||||
{
|
||||
FAR struct tcb_s *btcb;
|
||||
irqstate_t saved_state;
|
||||
|
@ -112,7 +112,8 @@
|
||||
*
|
||||
************************************************************************/
|
||||
|
||||
ssize_t mq_receive(mqd_t mqdes, void *msg, size_t msglen, int *prio)
|
||||
ssize_t mq_receive(mqd_t mqdes, FAR char *msg, size_t msglen,
|
||||
FAR int *prio)
|
||||
{
|
||||
FAR struct mqueue_msg_s *mqmsg;
|
||||
irqstate_t saved_state;
|
||||
@ -129,7 +130,7 @@ ssize_t mq_receive(mqd_t mqdes, void *msg, size_t msglen, int *prio)
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
/* Get the next mesage from the message queue. We will disable
|
||||
/* Get the next message from the message queue. We will disable
|
||||
* pre-emption until we have completed the message received. This
|
||||
* is not too bad because if the receipt takes a long time, it will
|
||||
* be because we are blocked waiting for a message and pre-emption
|
||||
|
@ -76,13 +76,13 @@
|
||||
* Name: mq_send
|
||||
*
|
||||
* Description:
|
||||
* This function adds the specificied message (msg) to the message queue
|
||||
* This function adds the specified message (msg) to the message queue
|
||||
* (mqdes). The "msglen" parameter specifies the length of the message
|
||||
* in bytes pointed to by "msg." This length must not exceed the maximum
|
||||
* message length from the mq_getattr().
|
||||
*
|
||||
* If the message queue is not full, mq_send() place the message in the
|
||||
* message queue at the position indicated by the "prio" argrument.
|
||||
* message queue at the position indicated by the "prio" argument.
|
||||
* Messages with higher priority will be inserted before lower priority
|
||||
* messages. The value of "prio" must not exceed MQ_PRIO_MAX.
|
||||
*
|
||||
@ -115,7 +115,7 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int mq_send(mqd_t mqdes, const void *msg, size_t msglen, int prio)
|
||||
int mq_send(mqd_t mqdes, FAR const char *msg, size_t msglen, int prio)
|
||||
{
|
||||
FAR struct mqueue_inode_s *msgq;
|
||||
FAR struct mqueue_msg_s *mqmsg = NULL;
|
||||
|
@ -108,7 +108,7 @@
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int mq_verifysend(mqd_t mqdes, const void *msg, size_t msglen, int prio)
|
||||
int mq_verifysend(mqd_t mqdes, FAR const char *msg, size_t msglen, int prio)
|
||||
{
|
||||
/* Verify the input parameters */
|
||||
|
||||
@ -324,7 +324,7 @@ int mq_waitsend(mqd_t mqdes)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int mq_dosend(mqd_t mqdes, FAR struct mqueue_msg_s *mqmsg, FAR const void *msg,
|
||||
int mq_dosend(mqd_t mqdes, FAR struct mqueue_msg_s *mqmsg, FAR const char *msg,
|
||||
size_t msglen, int prio)
|
||||
{
|
||||
FAR struct tcb_s *btcb;
|
||||
@ -345,7 +345,7 @@ int mq_dosend(mqd_t mqdes, FAR struct mqueue_msg_s *mqmsg, FAR const void *msg,
|
||||
|
||||
/* Copy the message data into the message */
|
||||
|
||||
memcpy((void*)mqmsg->mail, (const void*)msg, msglen);
|
||||
memcpy((void*)mqmsg->mail, (FAR const void*)msg, msglen);
|
||||
|
||||
/* Insert the new message in the message queue */
|
||||
|
||||
@ -438,4 +438,3 @@ int mq_dosend(mqd_t mqdes, FAR struct mqueue_msg_s *mqmsg, FAR const void *msg,
|
||||
sched_unlock();
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
@ -179,8 +179,8 @@ static void mq_rcvtimeout(int argc, uint32_t pid)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
ssize_t mq_timedreceive(mqd_t mqdes, void *msg, size_t msglen,
|
||||
int *prio, const struct timespec *abstime)
|
||||
ssize_t mq_timedreceive(mqd_t mqdes, FAR char *msg, size_t msglen,
|
||||
FAR int *prio, FAR const struct timespec *abstime)
|
||||
{
|
||||
FAR struct tcb_s *rtcb = (FAR struct tcb_s *)g_readytorun.head;
|
||||
FAR struct mqueue_msg_s *mqmsg;
|
||||
@ -216,7 +216,7 @@ ssize_t mq_timedreceive(mqd_t mqdes, void *msg, size_t msglen,
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
/* Get the next mesage from the message queue. We will disable
|
||||
/* Get the next message from the message queue. We will disable
|
||||
* pre-emption until we have completed the message received. This
|
||||
* is not too bad because if the receipt takes a long time, it will
|
||||
* be because we are blocked waiting for a message and pre-emption
|
||||
|
@ -180,8 +180,8 @@ static void mq_sndtimeout(int argc, uint32_t pid)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int mq_timedsend(mqd_t mqdes, const char *msg, size_t msglen, int prio,
|
||||
const struct timespec *abstime)
|
||||
int mq_timedsend(mqd_t mqdes, FAR const char *msg, size_t msglen, int prio,
|
||||
FAR const struct timespec *abstime)
|
||||
{
|
||||
FAR struct tcb_s *rtcb = (FAR struct tcb_s *)g_readytorun.head;
|
||||
FAR struct mqueue_inode_s *msgq;
|
||||
@ -318,4 +318,3 @@ int mq_timedsend(mqd_t mqdes, const char *msg, size_t msglen, int prio,
|
||||
rtcb->waitdog = NULL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -90,15 +90,15 @@ enum mqalloc_e
|
||||
|
||||
struct mqueue_msg_s
|
||||
{
|
||||
FAR struct mqueue_msg_s *next; /* Forward link to next message */
|
||||
uint8_t type; /* (Used to manage allocations) */
|
||||
uint8_t priority; /* priority of message */
|
||||
FAR struct mqueue_msg_s *next; /* Forward link to next message */
|
||||
uint8_t type; /* (Used to manage allocations) */
|
||||
uint8_t priority; /* priority of message */
|
||||
#if MQ_MAX_BYTES < 256
|
||||
uint8_t msglen; /* Message data length */
|
||||
uint8_t msglen; /* Message data length */
|
||||
#else
|
||||
uint16_t msglen; /* Message data length */
|
||||
uint16_t msglen; /* Message data length */
|
||||
#endif
|
||||
uint8_t mail[MQ_MAX_BYTES]; /* Message data */
|
||||
uint8_t mail[MQ_MAX_BYTES]; /* Message data */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
@ -150,18 +150,18 @@ void mq_waitirq(FAR struct tcb_s *wtcb, int errcode);
|
||||
|
||||
/* mq_rcvinternal.c ********************************************************/
|
||||
|
||||
int mq_verifyreceive(mqd_t mqdes, void *msg, size_t msglen);
|
||||
int mq_verifyreceive(mqd_t mqdes, FAR char *msg, size_t msglen);
|
||||
FAR struct mqueue_msg_s *mq_waitreceive(mqd_t mqdes);
|
||||
ssize_t mq_doreceive(mqd_t mqdes, FAR struct mqueue_msg_s *mqmsg,
|
||||
FAR void *ubuffer, FAR int *prio);
|
||||
FAR char *ubuffer, FAR int *prio);
|
||||
|
||||
/* mq_sndinternal.c ********************************************************/
|
||||
|
||||
int mq_verifysend(mqd_t mqdes, FAR const void *msg, size_t msglen, int prio);
|
||||
int mq_verifysend(mqd_t mqdes, FAR const char *msg, size_t msglen, int prio);
|
||||
FAR struct mqueue_msg_s *mq_msgalloc(void);
|
||||
int mq_waitsend(mqd_t mqdes);
|
||||
int mq_dosend(mqd_t mqdes, FAR struct mqueue_msg_s *mqmsg,
|
||||
FAR const void *msg, size_t msglen, int prio);
|
||||
FAR const char *msg, size_t msglen, int prio);
|
||||
|
||||
/* mq_release.c ************************************************************/
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user