2013-06-26 23:18:30 +08:00
|
|
|
/*
|
2021-03-08 18:19:04 +08:00
|
|
|
* Copyright (c) 2006-2021, RT-Thread Development Team
|
2013-06-26 23:18:30 +08:00
|
|
|
*
|
2018-10-14 19:28:18 +08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2013-06-26 23:18:30 +08:00
|
|
|
*
|
|
|
|
* Change Logs:
|
|
|
|
* Date Author Notes
|
|
|
|
*/
|
|
|
|
|
2013-01-08 22:40:58 +08:00
|
|
|
#ifndef __MQUEUE_H__
|
|
|
|
#define __MQUEUE_H__
|
|
|
|
|
2021-12-17 15:34:17 +08:00
|
|
|
#include <sys/signal.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <rtdef.h>
|
2013-01-08 22:40:58 +08:00
|
|
|
|
|
|
|
struct mqdes
|
|
|
|
{
|
2013-06-26 23:18:30 +08:00
|
|
|
/* reference count and unlinked */
|
|
|
|
rt_uint16_t refcount;
|
|
|
|
rt_uint16_t unlinked;
|
|
|
|
|
|
|
|
/* RT-Thread message queue */
|
|
|
|
rt_mq_t mq;
|
2023-05-05 18:14:07 +08:00
|
|
|
|
|
|
|
int mq_id;
|
2013-06-26 23:18:30 +08:00
|
|
|
/* next posix mqueue */
|
|
|
|
struct mqdes* next;
|
2013-01-08 22:40:58 +08:00
|
|
|
};
|
2023-05-05 18:14:07 +08:00
|
|
|
typedef struct mqdes* mqdes_t;
|
|
|
|
|
|
|
|
typedef int mqd_t;
|
2013-01-08 22:40:58 +08:00
|
|
|
|
|
|
|
struct mq_attr
|
|
|
|
{
|
2013-06-26 23:18:30 +08:00
|
|
|
long mq_flags; /* Message queue flags. */
|
|
|
|
long mq_maxmsg; /* Maximum number of messages. */
|
|
|
|
long mq_msgsize; /* Maximum message size. */
|
|
|
|
long mq_curmsgs; /* Number of messages currently queued. */
|
2013-01-08 22:40:58 +08:00
|
|
|
};
|
|
|
|
|
2013-06-26 23:18:30 +08:00
|
|
|
int mq_close(mqd_t mqdes);
|
|
|
|
int mq_getattr(mqd_t mqdes, struct mq_attr *mqstat);
|
|
|
|
int mq_notify(mqd_t mqdes, const struct sigevent *notification);
|
|
|
|
mqd_t mq_open(const char *name, int oflag, ...);
|
|
|
|
ssize_t mq_receive(mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned *msg_prio);
|
|
|
|
int mq_send(mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned msg_prio);
|
|
|
|
int mq_setattr(mqd_t mqdes,
|
|
|
|
const struct mq_attr *mqstat,
|
|
|
|
struct mq_attr *omqstat);
|
|
|
|
ssize_t mq_timedreceive(mqd_t mqdes,
|
|
|
|
char *msg_ptr,
|
|
|
|
size_t msg_len,
|
|
|
|
unsigned *msg_prio,
|
|
|
|
const struct timespec *abs_timeout);
|
|
|
|
int mq_timedsend(mqd_t mqdes,
|
|
|
|
const char *msg_ptr,
|
|
|
|
size_t msg_len,
|
|
|
|
unsigned msg_prio,
|
|
|
|
const struct timespec *abs_timeout);
|
|
|
|
|
|
|
|
int mq_unlink(const char *name);
|
2013-01-08 22:40:58 +08:00
|
|
|
|
|
|
|
#endif
|