1*53ee8cc1Swenshuai.xi /* Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc. 2*53ee8cc1Swenshuai.xi This file is part of the GNU C Library. 3*53ee8cc1Swenshuai.xi 4*53ee8cc1Swenshuai.xi The GNU C Library is free software; you can redistribute it and/or 5*53ee8cc1Swenshuai.xi modify it under the terms of the GNU Lesser General Public 6*53ee8cc1Swenshuai.xi License as published by the Free Software Foundation; either 7*53ee8cc1Swenshuai.xi version 2.1 of the License, or (at your option) any later version. 8*53ee8cc1Swenshuai.xi 9*53ee8cc1Swenshuai.xi The GNU C Library is distributed in the hope that it will be useful, 10*53ee8cc1Swenshuai.xi but WITHOUT ANY WARRANTY; without even the implied warranty of 11*53ee8cc1Swenshuai.xi MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12*53ee8cc1Swenshuai.xi Lesser General Public License for more details. 13*53ee8cc1Swenshuai.xi 14*53ee8cc1Swenshuai.xi You should have received a copy of the GNU Lesser General Public 15*53ee8cc1Swenshuai.xi License along with the GNU C Library; if not, write to the Free 16*53ee8cc1Swenshuai.xi Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 17*53ee8cc1Swenshuai.xi 02111-1307 USA. */ 18*53ee8cc1Swenshuai.xi 19*53ee8cc1Swenshuai.xi #ifndef _MQUEUE_H 20*53ee8cc1Swenshuai.xi #define _MQUEUE_H 1 21*53ee8cc1Swenshuai.xi 22*53ee8cc1Swenshuai.xi #include <features.h> 23*53ee8cc1Swenshuai.xi #include <sys/types.h> 24*53ee8cc1Swenshuai.xi #include <fcntl.h> 25*53ee8cc1Swenshuai.xi #define __need_sigevent_t 26*53ee8cc1Swenshuai.xi #include <bits/siginfo.h> 27*53ee8cc1Swenshuai.xi #define __need_timespec 28*53ee8cc1Swenshuai.xi #include <time.h> 29*53ee8cc1Swenshuai.xi /* Get the definition of mqd_t and struct mq_attr. */ 30*53ee8cc1Swenshuai.xi #include <bits/mqueue.h> 31*53ee8cc1Swenshuai.xi 32*53ee8cc1Swenshuai.xi __BEGIN_DECLS 33*53ee8cc1Swenshuai.xi 34*53ee8cc1Swenshuai.xi /* Establish connection between a process and a message queue NAME and 35*53ee8cc1Swenshuai.xi return message queue descriptor or (mqd_t) -1 on error. OFLAG determines 36*53ee8cc1Swenshuai.xi the type of access used. If O_CREAT is on OFLAG, the third argument is 37*53ee8cc1Swenshuai.xi taken as a `mode_t', the mode of the created message queue, and the fourth 38*53ee8cc1Swenshuai.xi argument is taken as `struct mq_attr *', pointer to message queue 39*53ee8cc1Swenshuai.xi attributes. If the fourth argument is NULL, default attributes are 40*53ee8cc1Swenshuai.xi used. */ 41*53ee8cc1Swenshuai.xi extern mqd_t mq_open (__const char *__name, int __oflag, ...) 42*53ee8cc1Swenshuai.xi __THROW __nonnull ((1)); 43*53ee8cc1Swenshuai.xi 44*53ee8cc1Swenshuai.xi /* Removes the association between message queue descriptor MQDES and its 45*53ee8cc1Swenshuai.xi message queue. */ 46*53ee8cc1Swenshuai.xi extern int mq_close (mqd_t __mqdes) __THROW; 47*53ee8cc1Swenshuai.xi 48*53ee8cc1Swenshuai.xi /* Query status and attributes of message queue MQDES. */ 49*53ee8cc1Swenshuai.xi extern int mq_getattr (mqd_t __mqdes, struct mq_attr *__mqstat) 50*53ee8cc1Swenshuai.xi __THROW __nonnull ((2)); 51*53ee8cc1Swenshuai.xi 52*53ee8cc1Swenshuai.xi /* Set attributes associated with message queue MQDES and if OMQSTAT is 53*53ee8cc1Swenshuai.xi not NULL also query its old attributes. */ 54*53ee8cc1Swenshuai.xi extern int mq_setattr (mqd_t __mqdes, 55*53ee8cc1Swenshuai.xi __const struct mq_attr *__restrict __mqstat, 56*53ee8cc1Swenshuai.xi struct mq_attr *__restrict __omqstat) 57*53ee8cc1Swenshuai.xi __THROW __nonnull ((2)); 58*53ee8cc1Swenshuai.xi 59*53ee8cc1Swenshuai.xi /* Remove message queue named NAME. */ 60*53ee8cc1Swenshuai.xi extern int mq_unlink (__const char *__name) __THROW __nonnull ((1)); 61*53ee8cc1Swenshuai.xi 62*53ee8cc1Swenshuai.xi /* Register notification issued upon message arrival to an empty 63*53ee8cc1Swenshuai.xi message queue MQDES. */ 64*53ee8cc1Swenshuai.xi extern int mq_notify (mqd_t __mqdes, __const struct sigevent *__notification) 65*53ee8cc1Swenshuai.xi __THROW; 66*53ee8cc1Swenshuai.xi 67*53ee8cc1Swenshuai.xi /* Receive the oldest from highest priority messages in message queue 68*53ee8cc1Swenshuai.xi MQDES. */ 69*53ee8cc1Swenshuai.xi extern ssize_t mq_receive (mqd_t __mqdes, char *__msg_ptr, size_t __msg_len, 70*53ee8cc1Swenshuai.xi unsigned int *__msg_prio) __nonnull ((2)); 71*53ee8cc1Swenshuai.xi 72*53ee8cc1Swenshuai.xi /* Add message pointed by MSG_PTR to message queue MQDES. */ 73*53ee8cc1Swenshuai.xi extern int mq_send (mqd_t __mqdes, __const char *__msg_ptr, size_t __msg_len, 74*53ee8cc1Swenshuai.xi unsigned int __msg_prio) __nonnull ((2)); 75*53ee8cc1Swenshuai.xi 76*53ee8cc1Swenshuai.xi #ifdef __USE_XOPEN2K 77*53ee8cc1Swenshuai.xi /* Receive the oldest from highest priority messages in message queue 78*53ee8cc1Swenshuai.xi MQDES, stop waiting if ABS_TIMEOUT expires. */ 79*53ee8cc1Swenshuai.xi extern ssize_t mq_timedreceive (mqd_t __mqdes, char *__restrict __msg_ptr, 80*53ee8cc1Swenshuai.xi size_t __msg_len, 81*53ee8cc1Swenshuai.xi unsigned int *__restrict __msg_prio, 82*53ee8cc1Swenshuai.xi __const struct timespec *__restrict __abs_timeout) 83*53ee8cc1Swenshuai.xi __nonnull ((2, 5)); 84*53ee8cc1Swenshuai.xi 85*53ee8cc1Swenshuai.xi /* Add message pointed by MSG_PTR to message queue MQDES, stop blocking 86*53ee8cc1Swenshuai.xi on full message queue if ABS_TIMEOUT expires. */ 87*53ee8cc1Swenshuai.xi extern int mq_timedsend (mqd_t __mqdes, __const char *__msg_ptr, 88*53ee8cc1Swenshuai.xi size_t __msg_len, unsigned int __msg_prio, 89*53ee8cc1Swenshuai.xi __const struct timespec *__abs_timeout) 90*53ee8cc1Swenshuai.xi __nonnull ((2, 5)); 91*53ee8cc1Swenshuai.xi #endif 92*53ee8cc1Swenshuai.xi 93*53ee8cc1Swenshuai.xi /* Define some inlines helping to catch common problems. */ 94*53ee8cc1Swenshuai.xi #if __USE_FORTIFY_LEVEL > 0 && defined __extern_always_inline \ 95*53ee8cc1Swenshuai.xi && defined __va_arg_pack_len 96*53ee8cc1Swenshuai.xi # include <bits/mqueue2.h> 97*53ee8cc1Swenshuai.xi #endif 98*53ee8cc1Swenshuai.xi 99*53ee8cc1Swenshuai.xi __END_DECLS 100*53ee8cc1Swenshuai.xi 101*53ee8cc1Swenshuai.xi #endif /* mqueue.h */ 102