SuperTinyKernel™ RTOS 1.08.x
Lightweight, high-performance, deterministic, bare-metal C++ RTOS for resource-constrained embedded systems. MIT Open Source License.
Loading...
Searching...
No Matches
mqueue.h
Go to the documentation of this file.
1/*
2 * SuperTinyKernel(TM) RTOS: Lightweight High-Performance Deterministic C++ RTOS for Embedded Systems.
3 *
4 * Source: https://github.com/SuperTinyKernel-RTOS
5 *
6 * Copyright (c) 2022-2026 Neutron Code Limited <stk@neutroncode.com>. All Rights Reserved.
7 * License: MIT License, see LICENSE for a full text.
8 */
9
10#ifndef STK_C_MQUEUE_H_
11#define STK_C_MQUEUE_H_
12
25
26/* Same newlib guard as in stk_c_pthread.h: <sys/types.h> must not define its own pthread types, the shim provides
27 them (needed here because this header may be included before stk_c_pthread.h). */
28#ifndef _SYS__PTHREADTYPES_H_
29 #define _SYS__PTHREADTYPES_H_
30 #define STK_C_PTHREADTYPES_GUARD
31#endif
32
33#include <stddef.h>
34#include <sys/types.h>
35#include <fcntl.h>
36#include <time.h>
37
38#ifdef __cplusplus
39extern "C" {
40#endif
41
42#ifndef STK_C_MQ_MAX_QUEUES
43 #define STK_C_MQ_MAX_QUEUES (4U)
44#endif
45#ifndef STK_C_MQ_MAX_DESCRIPTORS
46 #define STK_C_MQ_MAX_DESCRIPTORS (8U)
47#endif
48#ifndef STK_C_MQ_NAME_MAX
49 #define STK_C_MQ_NAME_MAX (32U)
50#endif
51#ifndef STK_C_MQ_DEFAULT_MAXMSG
52 #define STK_C_MQ_DEFAULT_MAXMSG (8)
53#endif
54#ifndef STK_C_MQ_DEFAULT_MSGSIZE
55 #define STK_C_MQ_DEFAULT_MSGSIZE (64)
56#endif
57
58#define MQ_PRIO_MAX (32U)
59
60typedef struct stk_mq_desc *mqd_t;
61
62struct mq_attr
63{
64 long mq_flags;
65 long mq_maxmsg;
68};
69
77mqd_t mq_open(const char *name, int oflag, ...);
78
81int mq_close(mqd_t mqdes);
82
86int mq_unlink(const char *name);
87
91int mq_send(mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned int msg_prio);
92
95int mq_timedsend(mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned int msg_prio,
96 const struct timespec *abstime);
97
102ssize_t mq_receive(mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned int *msg_prio);
103
106ssize_t mq_timedreceive(mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned int *msg_prio,
107 const struct timespec *abstime);
108
111int mq_getattr(mqd_t mqdes, struct mq_attr *mqstat);
112
116int mq_setattr(mqd_t mqdes, const struct mq_attr *mqstat, struct mq_attr *omqstat);
117
120int mq_notify(mqd_t mqdes, const struct sigevent *notification);
121
122#ifdef __cplusplus
123}
124#endif
125
126#endif /* STK_C_MQUEUE_H_ */
int mq_close(mqd_t mqdes)
Close a descriptor; an unlinked queue is destroyed with its last descriptor.
int mq_getattr(mqd_t mqdes, struct mq_attr *mqstat)
Get the attributes of the queue (mq_flags is that of this descriptor).
int mq_notify(mqd_t mqdes, const struct sigevent *notification)
Not supported (no signals): fails with ENOSYS.
int mq_setattr(mqd_t mqdes, const struct mq_attr *mqstat, struct mq_attr *omqstat)
Set the descriptor flags: only O_NONBLOCK of mq_flags is used.
struct stk_mq_desc * mqd_t
Definition mqueue.h:60
ssize_t mq_receive(mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned int *msg_prio)
Receive the oldest message of the highest priority.
int mq_timedsend(mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned int msg_prio, const struct timespec *abstime)
mq_send() with an absolute deadline (STK timeline). Additionally ETIMEDOUT.
int mq_unlink(const char *name)
Remove the name of a queue (existing descriptors keep working).
ssize_t mq_timedreceive(mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned int *msg_prio, const struct timespec *abstime)
mq_receive() with an absolute deadline (STK timeline). Additionally ETIMEDOUT.
int mq_send(mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned int msg_prio)
Send a message. Blocks while the queue is full unless O_NONBLOCK is set.
mqd_t mq_open(const char *name, int oflag,...)
Open (and optionally create) a named queue.
POSIX time extensions for STK: clock_gettime(), clock_getres(), nanosleep(), clock_nanosleep(),...
long mq_curmsgs
Definition mqueue.h:67
long mq_flags
Definition mqueue.h:64
long mq_maxmsg
Definition mqueue.h:65
long mq_msgsize
Definition mqueue.h:66