Back to index

glibc  2.9
mqueue.h
Go to the documentation of this file.
00001 /* Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003 
00004    The GNU C Library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Lesser General Public
00006    License as published by the Free Software Foundation; either
00007    version 2.1 of the License, or (at your option) any later version.
00008 
00009    The GNU C Library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Lesser General Public License for more details.
00013 
00014    You should have received a copy of the GNU Lesser General Public
00015    License along with the GNU C Library; if not, write to the Free
00016    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00017    02111-1307 USA.  */
00018 
00019 #ifndef _MQUEUE_H
00020 #define _MQUEUE_H    1
00021 
00022 #include <features.h>
00023 #include <sys/types.h>
00024 #include <fcntl.h>
00025 #define __need_sigevent_t
00026 #include <bits/siginfo.h>
00027 #define __need_timespec
00028 #include <time.h>
00029 /* Get the definition of mqd_t and struct mq_attr.  */
00030 #include <bits/mqueue.h>
00031 
00032 __BEGIN_DECLS
00033 
00034 /* Establish connection between a process and a message queue NAME and
00035    return message queue descriptor or (mqd_t) -1 on error.  OFLAG determines
00036    the type of access used.  If O_CREAT is on OFLAG, the third argument is
00037    taken as a `mode_t', the mode of the created message queue, and the fourth
00038    argument is taken as `struct mq_attr *', pointer to message queue
00039    attributes.  If the fourth argument is NULL, default attributes are
00040    used.  */
00041 extern mqd_t mq_open (__const char *__name, int __oflag, ...)
00042   __THROW __nonnull ((1));
00043 
00044 /* Removes the association between message queue descriptor MQDES and its
00045    message queue.  */
00046 extern int mq_close (mqd_t __mqdes) __THROW;
00047 
00048 /* Query status and attributes of message queue MQDES.  */
00049 extern int mq_getattr (mqd_t __mqdes, struct mq_attr *__mqstat)
00050   __THROW __nonnull ((2));
00051 
00052 /* Set attributes associated with message queue MQDES and if OMQSTAT is
00053    not NULL also query its old attributes.  */
00054 extern int mq_setattr (mqd_t __mqdes,
00055                      __const struct mq_attr *__restrict __mqstat,
00056                      struct mq_attr *__restrict __omqstat)
00057   __THROW __nonnull ((2));
00058 
00059 /* Remove message queue named NAME.  */
00060 extern int mq_unlink (__const char *__name) __THROW __nonnull ((1));
00061 
00062 /* Register notification issued upon message arrival to an empty
00063    message queue MQDES.  */
00064 extern int mq_notify (mqd_t __mqdes, __const struct sigevent *__notification)
00065      __THROW;
00066 
00067 /* Receive the oldest from highest priority messages in message queue
00068    MQDES.  */
00069 extern ssize_t mq_receive (mqd_t __mqdes, char *__msg_ptr, size_t __msg_len,
00070                         unsigned int *__msg_prio) __nonnull ((2));
00071 
00072 /* Add message pointed by MSG_PTR to message queue MQDES.  */
00073 extern int mq_send (mqd_t __mqdes, __const char *__msg_ptr, size_t __msg_len,
00074                   unsigned int __msg_prio) __nonnull ((2));
00075 
00076 #ifdef __USE_XOPEN2K
00077 /* Receive the oldest from highest priority messages in message queue
00078    MQDES, stop waiting if ABS_TIMEOUT expires.  */
00079 extern ssize_t mq_timedreceive (mqd_t __mqdes, char *__restrict __msg_ptr,
00080                             size_t __msg_len,
00081                             unsigned int *__restrict __msg_prio,
00082                             __const struct timespec *__restrict __abs_timeout)
00083   __nonnull ((2, 5));
00084 
00085 /* Add message pointed by MSG_PTR to message queue MQDES, stop blocking
00086    on full message queue if ABS_TIMEOUT expires.  */
00087 extern int mq_timedsend (mqd_t __mqdes, __const char *__msg_ptr,
00088                       size_t __msg_len, unsigned int __msg_prio,
00089                       __const struct timespec *__abs_timeout)
00090   __nonnull ((2, 5));
00091 #endif
00092 
00093 /* Define some inlines helping to catch common problems.  */
00094 #if __USE_FORTIFY_LEVEL > 0 && defined __extern_always_inline \
00095     && defined __va_arg_pack_len
00096 # include <bits/mqueue2.h>
00097 #endif
00098 
00099 __END_DECLS
00100 
00101 #endif /* mqueue.h */