xref: /nrf52832-nimble/rt-thread/components/libc/pthreads/mqueue.h (revision 104654410c56c573564690304ae786df310c91fc)
1 /*
2  * Copyright (c) 2006-2018, RT-Thread Development Team
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  *
6  * Change Logs:
7  * Date           Author       Notes
8  */
9 
10 #ifndef __MQUEUE_H__
11 #define __MQUEUE_H__
12 
13 #include <rtthread.h>
14 #include <pthread.h>
15 
16 struct mqdes
17 {
18     /* reference count and unlinked */
19     rt_uint16_t refcount;
20     rt_uint16_t unlinked;
21 
22     /* RT-Thread message queue */
23     rt_mq_t mq;
24     /* next posix mqueue */
25     struct mqdes* next;
26 };
27 typedef struct mqdes* mqd_t;
28 
29 struct mq_attr
30 {
31     long mq_flags;      /* Message queue flags. */
32     long mq_maxmsg;     /* Maximum number of messages. */
33     long mq_msgsize;    /* Maximum message size. */
34     long mq_curmsgs;    /* Number of messages currently queued. */
35 };
36 
37 int     mq_close(mqd_t mqdes);
38 int     mq_getattr(mqd_t mqdes, struct mq_attr *mqstat);
39 int     mq_notify(mqd_t mqdes, const struct sigevent *notification);
40 mqd_t   mq_open(const char *name, int oflag, ...);
41 ssize_t mq_receive(mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned *msg_prio);
42 int     mq_send(mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned msg_prio);
43 int     mq_setattr(mqd_t                 mqdes,
44                    const struct mq_attr *mqstat,
45                    struct mq_attr       *omqstat);
46 ssize_t mq_timedreceive(mqd_t                  mqdes,
47                         char                  *msg_ptr,
48                         size_t                 msg_len,
49                         unsigned              *msg_prio,
50                         const struct timespec *abs_timeout);
51 int     mq_timedsend(mqd_t                  mqdes,
52                      const char            *msg_ptr,
53                      size_t                 msg_len,
54                      unsigned               msg_prio,
55                      const struct timespec *abs_timeout);
56 
57 int     mq_unlink(const char *name);
58 
59 #endif
60