The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/sys/mqueue.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*      $NetBSD: mqueue.h,v 1.17 2015/06/20 14:41:54 martin Exp $       */
    2 
    3 /*
    4  * Copyright (c) 2007-2009 Mindaugas Rasiukevicius <rmind at NetBSD org>
    5  * All rights reserved.
    6  * 
    7  * Redistribution and use in source and binary forms, with or without
    8  * modification, are permitted provided that the following conditions
    9  * are met:
   10  * 1. Redistributions of source code must retain the above copyright
   11  *    notice, this list of conditions and the following disclaimer.
   12  * 2. Redistributions in binary form must reproduce the above copyright
   13  *    notice, this list of conditions and the following disclaimer in the
   14  *    documentation and/or other materials provided with the distribution.
   15  *
   16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   26  * SUCH DAMAGE.
   27  */
   28 
   29 #ifndef _SYS_MQUEUE_H_
   30 #define _SYS_MQUEUE_H_
   31 
   32 /* Maximal number of mqueue descriptors, that process could open */
   33 #define MQ_OPEN_MAX             512
   34 
   35 /* Maximal priority of the message */
   36 #define MQ_PRIO_MAX             32
   37 
   38 struct mq_attr {
   39         long    mq_flags;       /* Flags of message queue */
   40         long    mq_maxmsg;      /* Maximum number of messages */
   41         long    mq_msgsize;     /* Maximum size of the message */
   42         long    mq_curmsgs;     /* Count of the queued messages */
   43 };
   44 
   45 /* Internal kernel data */
   46 #ifdef _KERNEL
   47 
   48 #include <sys/condvar.h>
   49 #include <sys/mutex.h>
   50 #include <sys/queue.h>
   51 #include <sys/selinfo.h>
   52 #include <sys/types.h>
   53 #include <sys/param.h>
   54 
   55 /*
   56  * Flags below are used in mq_flags for internal purposes.
   57  * This is permitted according to POSIX.
   58  */
   59 
   60 /* Message queue is unlinked */
   61 #define MQ_UNLINKED             0x10000000
   62 /* There are receive-waiters */
   63 #define MQ_RECEIVE              0x20000000
   64 
   65 /* Maximal length of mqueue name */
   66 #define MQ_NAMELEN              (KERNEL_NAME_MAX + 1)
   67 
   68 /* Default size of the message */
   69 #define MQ_DEF_MSGSIZE          1024
   70 
   71 /* Size/bits and index of reserved queue */
   72 #define MQ_PQSIZE               32
   73 #define MQ_PQRESQ               0
   74 
   75 /* Structure of the message queue. */
   76 typedef struct mqueue {
   77         char *                  mq_name;
   78         kmutex_t                mq_mtx;
   79         kcondvar_t              mq_send_cv;
   80         kcondvar_t              mq_recv_cv;
   81         struct mq_attr          mq_attrib;
   82         /* Notification */
   83         struct selinfo          mq_rsel;
   84         struct selinfo          mq_wsel;
   85         struct sigevent         mq_sig_notify;
   86         struct proc *           mq_notify_proc;
   87         /* Permissions */
   88         mode_t                  mq_mode;
   89         uid_t                   mq_euid;
   90         gid_t                   mq_egid;
   91         /* Reference counter, queue array and bitmap */
   92         u_int                   mq_refcnt;
   93         TAILQ_HEAD(, mq_msg)    mq_head[1 + MQ_PQSIZE];
   94         uint32_t                mq_bitmap;
   95         /* Entry of the global list */
   96         LIST_ENTRY(mqueue)      mq_list;
   97         /* Time stamps */
   98         struct timespec         mq_atime;
   99         struct timespec         mq_mtime;
  100         struct timespec         mq_btime;
  101 } mqueue_t;
  102 
  103 /* Structure of the message. */
  104 typedef struct mq_msg {
  105         TAILQ_ENTRY(mq_msg)     msg_queue;
  106         size_t                  msg_len;
  107         u_int                   msg_prio;
  108         uint8_t                 msg_ptr[1];
  109 } mq_msg_t;
  110 
  111 /* Prototypes */
  112 void    mqueue_print_list(void (*pr)(const char *, ...) __printflike(1, 2));
  113 int     mq_send1(mqd_t, const char *, size_t, u_int, struct timespec *);
  114 int     mq_recv1(mqd_t, void *, size_t, u_int *, struct timespec *, ssize_t *);
  115 int     mqueue_get(mqd_t mqd, int fflag, mqueue_t **mqret);
  116 int     mq_handle_open(struct lwp *l, const char *, int, mode_t,
  117             struct mq_attr*, register_t *retval);
  118 
  119 #endif  /* _KERNEL */
  120 
  121 #endif  /* _SYS_MQUEUE_H_ */

Cache object: 7462cc53e6050c57a07a8c142e52a4d4


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.