1 /* 2 * Copyright (C) 2015-2021 Alibaba Group Holding Limited 3 */ 4 5 #ifndef _MQUEUE_H 6 #define _MQUEUE_H 7 8 #ifdef __cplusplus 9 extern "C" { 10 #endif 11 12 #include <sys/types.h> 13 #include <time.h> 14 15 #define DEFAULT_MQUEUE_SIZE 10240 16 #define DEFAULT_MAX_MSG_SIZE 1024 17 18 typedef void *mqd_t; 19 20 struct mq_attr { 21 long mq_flags; /* message queue flags */ 22 long mq_maxmsg; /* maximum number of messages */ 23 long mq_msgsize; /* maximum message size */ 24 long mq_curmsgs; /* number of messages currently queued */ 25 }; 26 27 mqd_t mq_open(const char *name, int oflag, ...); 28 int mq_close(mqd_t mqdes); 29 ssize_t mq_receive(mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned *msg_prio); 30 int mq_send(mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned msg_prio); 31 int mq_setattr(mqd_t mqdes, const struct mq_attr *mqstat, struct mq_attr *omqstat); 32 int mq_getattr(mqd_t mqdes, struct mq_attr *mqstat); 33 ssize_t mq_timedreceive(mqd_t mqdes, char *msg_ptr, size_t msg_len, unsigned *msg_prio, const struct timespec *abs_timeout); 34 int mq_timedsend(mqd_t mqdes, const char *msg_ptr, size_t msg_len, unsigned msg_prio, const struct timespec *abs_timeout); 35 int mq_unlink(const char *name); 36 37 #ifdef __cplusplus 38 } 39 #endif 40 41 #endif /* _MQUEUE_H */ 42