posix-next API 0.1.0
Out-of-tree Zephyr POSIX module
Loading...
Searching...
No Matches
_POSIX_MESSAGE_PASSING

POSIX Message Passing option. More...

Files

file  mqueue.h
 POSIX message queues (<mqueue.h>)
 

Typedefs

typedef void * mqd_t
 Opaque message queue descriptor returned by mq_open().
 

Functions

mqd_t mq_open (const char *name, int oflags,...)
 Open or create a message queue.
 
int mq_close (mqd_t mqdes)
 Close a message queue descriptor.
 
int mq_unlink (const char *name)
 Remove a named message queue.
 
int mq_getattr (mqd_t mqdes, struct mq_attr *mqstat)
 Get the attributes of a message queue.
 
int mq_receive (mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned int *msg_prio)
 Receive the oldest highest-priority message from a queue.
 
int mq_send (mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned int msg_prio)
 Add a message to a queue.
 
int mq_setattr (mqd_t mqdes, const struct mq_attr *mqstat, struct mq_attr *omqstat)
 Set the attributes of a message queue.
 
int mq_timedreceive (mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned int *msg_prio, const struct timespec *abstime)
 Receive a message from a queue with an absolute timeout.
 
int mq_timedsend (mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned int msg_prio, const struct timespec *abstime)
 Send a message to a queue with an absolute timeout.
 
int mq_notify (mqd_t mqdes, const struct sigevent *notification)
 Register for notification when a message arrives on an empty queue.
 

Detailed Description

POSIX Message Passing option.

Typedef Documentation

◆ mqd_t

typedef void* mqd_t

Opaque message queue descriptor returned by mq_open().

Definition at line 31 of file mqueue.h.

Function Documentation

◆ mq_close()

int mq_close ( mqd_t  mqdes)

Close a message queue descriptor.

Parameters
mqdesMessage queue descriptor.
Returns
0 on success, or -1 with errno set on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/mq_close.html

◆ mq_getattr()

int mq_getattr ( mqd_t  mqdes,
struct mq_attr mqstat 
)

Get the attributes of a message queue.

Parameters
mqdesMessage queue descriptor.
mqstatOutput: current attributes.
Returns
0 on success, or -1 with errno set on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/mq_getattr.html

◆ mq_notify()

int mq_notify ( mqd_t  mqdes,
const struct sigevent notification 
)

Register for notification when a message arrives on an empty queue.

Parameters
mqdesMessage queue descriptor.
notificationNotification specification, or NULL to cancel.
Returns
0 on success, or -1 with errno set on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/mq_notify.html

◆ mq_open()

mqd_t mq_open ( const char *  name,
int  oflags,
  ... 
)

Open or create a message queue.

Parameters
nameQueue name (must start with '/').
oflagsOpen flags (O_RDONLY, O_WRONLY, O_RDWR, O_CREAT, O_EXCL, O_NONBLOCK).
...If O_CREAT: mode_t mode, struct mq_attr *attr.
Returns
Message queue descriptor on success, or (mqd_t)-1 on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/mq_open.html

◆ mq_receive()

int mq_receive ( mqd_t  mqdes,
char *  msg_ptr,
size_t  msg_len,
unsigned int *  msg_prio 
)

Receive the oldest highest-priority message from a queue.

Parameters
mqdesMessage queue descriptor (opened with O_RDONLY or O_RDWR).
msg_ptrBuffer to receive the message.
msg_lenSize of msg_ptr (must be >= mq_msgsize).
msg_prioOutput: priority of the received message, or NULL.
Returns
Number of bytes in the received message on success, or -1 on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/mq_receive.html

◆ mq_send()

int mq_send ( mqd_t  mqdes,
const char *  msg_ptr,
size_t  msg_len,
unsigned int  msg_prio 
)

Add a message to a queue.

Parameters
mqdesMessage queue descriptor (opened with O_WRONLY or O_RDWR).
msg_ptrMessage to send.
msg_lenSize of the message in bytes.
msg_prioPriority of the message (higher value = higher priority).
Returns
0 on success, or -1 with errno set on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/mq_send.html

◆ mq_setattr()

int mq_setattr ( mqd_t  mqdes,
const struct mq_attr mqstat,
struct mq_attr omqstat 
)

Set the attributes of a message queue.

Parameters
mqdesMessage queue descriptor.
mqstatNew attributes (only mq_flags is used).
omqstatOutput: previous attributes, or NULL.
Returns
0 on success, or -1 with errno set on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/mq_setattr.html

◆ mq_timedreceive()

int mq_timedreceive ( mqd_t  mqdes,
char *  msg_ptr,
size_t  msg_len,
unsigned int *  msg_prio,
const struct timespec abstime 
)

Receive a message from a queue with an absolute timeout.

Parameters
mqdesMessage queue descriptor.
msg_ptrBuffer to receive the message.
msg_lenSize of msg_ptr.
msg_prioOutput: message priority, or NULL.
abstimeAbsolute timeout (CLOCK_REALTIME).
Returns
Number of bytes in the message on success, or -1 on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/mq_timedreceive.html

◆ mq_timedsend()

int mq_timedsend ( mqd_t  mqdes,
const char *  msg_ptr,
size_t  msg_len,
unsigned int  msg_prio,
const struct timespec abstime 
)

Send a message to a queue with an absolute timeout.

Parameters
mqdesMessage queue descriptor.
msg_ptrMessage to send.
msg_lenSize of the message in bytes.
msg_prioPriority of the message.
abstimeAbsolute timeout (CLOCK_REALTIME).
Returns
0 on success, or -1 with errno set on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/mq_timedsend.html

◆ mq_unlink()

int mq_unlink ( const char *  name)

Remove a named message queue.

Parameters
nameQueue name.
Returns
0 on success, or -1 with errno set on failure.
See also
https://pubs.opengroup.org/onlinepubs/9699919799/functions/mq_unlink.html