| 1 | /* |
|---|
| 2 | * mqueue.h - definitions and function prototypes for POSIX mqueue support. |
|---|
| 3 | */ |
|---|
| 4 | |
|---|
| 5 | #ifndef _MQUEUE_H |
|---|
| 6 | #define _MQUEUE_H |
|---|
| 7 | |
|---|
| 8 | #include <features.h> |
|---|
| 9 | #include <sys/types.h> |
|---|
| 10 | #include <fcntl.h> |
|---|
| 11 | #define __need_sigevent_t |
|---|
| 12 | #include <bits/siginfo.h> |
|---|
| 13 | #define __need_timespec |
|---|
| 14 | #include <time.h> |
|---|
| 15 | |
|---|
| 16 | typedef int mqd_t; |
|---|
| 17 | |
|---|
| 18 | struct mq_attr { |
|---|
| 19 | long int mq_flags; /* Message queue flags */ |
|---|
| 20 | long int mq_maxmsg; /* Maximum number of messages */ |
|---|
| 21 | long int mq_msgsize; /* Maximum message size */ |
|---|
| 22 | long int mq_curmsgs; /* Number of messages currently queued */ |
|---|
| 23 | long int __pad[4]; |
|---|
| 24 | }; |
|---|
| 25 | |
|---|
| 26 | __BEGIN_DECLS |
|---|
| 27 | |
|---|
| 28 | /* |
|---|
| 29 | * Establish connection between a process and a message queue __name and |
|---|
| 30 | * return message queue descriptor or (mqd_t) -1 on error. __oflag determines |
|---|
| 31 | * the type of access used. If O_CREAT is on __oflag, the third argument is |
|---|
| 32 | * taken as a `mode_t', the mode of the created message queue, and the fourth |
|---|
| 33 | * argument is taken as `struct mq_attr *', pointer to message queue |
|---|
| 34 | * attributes. If the fourth argument is NULL, default attributes are used. |
|---|
| 35 | */ |
|---|
| 36 | extern mqd_t mq_open(const char *__name, int __oflag, ...) __THROW; |
|---|
| 37 | |
|---|
| 38 | /* |
|---|
| 39 | * Remove the association between message queue descriptor __mqdes and its |
|---|
| 40 | * message queue. |
|---|
| 41 | */ |
|---|
| 42 | extern int mq_close(mqd_t __mqdes) __THROW; |
|---|
| 43 | |
|---|
| 44 | /* Query status and attributes of message queue __mqdes */ |
|---|
| 45 | extern int mq_getattr(mqd_t __mqdes, struct mq_attr *__mqstat) __THROW; |
|---|
| 46 | |
|---|
| 47 | /* |
|---|
| 48 | * Set attributes associated with message queue __mqdes and if __omqstat is |
|---|
| 49 | * not NULL also query its old attributes. |
|---|
| 50 | */ |
|---|
| 51 | extern int mq_setattr(mqd_t __mqdes, |
|---|
| 52 | const struct mq_attr *__restrict __mqstat, |
|---|
| 53 | struct mq_attr *__restrict __omqstat) __THROW; |
|---|
| 54 | |
|---|
| 55 | /* Remove message queue named __name */ |
|---|
| 56 | extern int mq_unlink(const char *__name) __THROW; |
|---|
| 57 | |
|---|
| 58 | /* |
|---|
| 59 | * Register notification upon message arrival to an empty message queue |
|---|
| 60 | * __mqdes |
|---|
| 61 | */ |
|---|
| 62 | extern int mq_notify(mqd_t __mqdes, const struct sigevent *__notification) |
|---|
| 63 | __THROW; |
|---|
| 64 | |
|---|
| 65 | /* |
|---|
| 66 | * Receive the oldest from highest priority messages in message queue |
|---|
| 67 | * __mqdes |
|---|
| 68 | */ |
|---|
| 69 | extern ssize_t mq_receive(mqd_t __mqdes, char *__msg_ptr, size_t __msg_len, |
|---|
| 70 | unsigned int *__msg_prio); |
|---|
| 71 | |
|---|
| 72 | /* Add message pointed by __msg_ptr to message queue __mqdes */ |
|---|
| 73 | extern int mq_send(mqd_t __mqdes, const char *__msg_ptr, size_t __msg_len, |
|---|
| 74 | unsigned int __msg_prio); |
|---|
| 75 | |
|---|
| 76 | #ifdef __USE_XOPEN2K |
|---|
| 77 | /* |
|---|
| 78 | * Receive the oldest from highest priority messages in message queue |
|---|
| 79 | * __mqdes, stop waiting if __abs_timeout expires. |
|---|
| 80 | */ |
|---|
| 81 | extern ssize_t mq_timedreceive(mqd_t __mqdes, char *__restrict __msg_ptr, |
|---|
| 82 | size_t __msg_len, |
|---|
| 83 | unsigned int *__restrict __msg_prio, |
|---|
| 84 | const struct timespec *__restrict __abs_timeout); |
|---|
| 85 | |
|---|
| 86 | /* |
|---|
| 87 | * Add message pointed by __msg_ptr to message queue __mqdes, stop blocking |
|---|
| 88 | * on full message queue if __abs_timeout expires. |
|---|
| 89 | */ |
|---|
| 90 | extern int mq_timedsend(mqd_t __mqdes, const char *__msg_ptr, |
|---|
| 91 | size_t __msg_len, unsigned int __msg_prio, |
|---|
| 92 | const struct timespec *__abs_timeout); |
|---|
| 93 | #endif |
|---|
| 94 | |
|---|
| 95 | __END_DECLS |
|---|
| 96 | |
|---|
| 97 | #endif |
|---|