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/msg.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: msg.h,v 1.22 2008/04/28 20:24:11 martin Exp $  */
    2 
    3 /*-
    4  * Copyright (c) 1999, 2007 The NetBSD Foundation, Inc.
    5  * All rights reserved.
    6  *
    7  * This code is derived from software contributed to The NetBSD Foundation
    8  * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
    9  * NASA Ames Research Center, and by Andrew Doran.
   10  *
   11  * Redistribution and use in source and binary forms, with or without
   12  * modification, are permitted provided that the following conditions
   13  * are met:
   14  * 1. Redistributions of source code must retain the above copyright
   15  *    notice, this list of conditions and the following disclaimer.
   16  * 2. Redistributions in binary form must reproduce the above copyright
   17  *    notice, this list of conditions and the following disclaimer in the
   18  *    documentation and/or other materials provided with the distribution.
   19  *
   20  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
   21  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
   22  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   23  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
   24  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   25  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   26  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   27  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   28  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   29  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   30  * POSSIBILITY OF SUCH DAMAGE.
   31  */
   32 
   33 /*
   34  * SVID compatible msg.h file
   35  *
   36  * Author:  Daniel Boulet
   37  *
   38  * Copyright 1993 Daniel Boulet and RTMX Inc.
   39  *
   40  * This system call was implemented by Daniel Boulet under contract from RTMX.
   41  *
   42  * Redistribution and use in source forms, with and without modification,
   43  * are permitted provided that this entire comment appears intact.
   44  *
   45  * Redistribution in binary form may occur without any restrictions.
   46  * Obviously, it would be nice if you gave credit where credit is due
   47  * but requiring it would be too onerous.
   48  *
   49  * This software is provided ``AS IS'' without any warranties of any kind.
   50  */
   51 
   52 #ifndef _SYS_MSG_H_
   53 #define _SYS_MSG_H_
   54 
   55 #include <sys/featuretest.h>
   56 #include <sys/ipc.h>
   57 #ifdef _KERNEL
   58 #include <sys/condvar.h>
   59 #include <sys/mutex.h>
   60 #endif
   61 
   62 #ifdef _KERNEL
   63 struct __msg {
   64         struct  __msg *msg_next; /* next msg in the chain */
   65         long    msg_type;       /* type of this message */
   66                                 /* >0 -> type of this message */
   67                                 /* 0 -> free header */
   68         u_short msg_ts;         /* size of this message */
   69         short   msg_spot;       /* location of start of msg in buffer */
   70 };
   71 #endif /* _KERNEL */
   72 
   73 #define MSG_NOERROR     010000          /* don't complain about too long msgs */
   74 
   75 typedef unsigned long   msgqnum_t;
   76 typedef size_t          msglen_t;
   77 
   78 struct msqid_ds {
   79         struct ipc_perm msg_perm;       /* operation permission strucure */
   80         msgqnum_t       msg_qnum;       /* number of messages in the queue */
   81         msglen_t        msg_qbytes;     /* max # of bytes in the queue */
   82         pid_t           msg_lspid;      /* process ID of last msgsend() */
   83         pid_t           msg_lrpid;      /* process ID of last msgrcv() */
   84         time_t          msg_stime;      /* time of last msgsend() */
   85         time_t          msg_rtime;      /* time of last msgrcv() */
   86         time_t          msg_ctime;      /* time of last change */
   87 
   88         /*
   89          * These members are private and used only in the internal
   90          * implementation of this interface.
   91          */
   92         struct __msg    *_msg_first;    /* first message in the queue */
   93         struct __msg    *_msg_last;     /* last message in the queue */
   94         msglen_t        _msg_cbytes;    /* # of bytes currently in queue */
   95 };
   96 
   97 #if defined(_NETBSD_SOURCE)
   98 /*
   99  * Based on the configuration parameters described in an SVR2 (yes, two)
  100  * config(1m) man page.
  101  *
  102  * Each message is broken up and stored in segments that are msgssz bytes
  103  * long.  For efficiency reasons, this should be a power of two.  Also,
  104  * it doesn't make sense if it is less than 8 or greater than about 256.
  105  * Consequently, msginit in kern/sysv_msg.c checks that msgssz is a power of
  106  * two between 8 and 1024 inclusive (and panic's if it isn't).
  107  */
  108 struct msginfo {
  109         int32_t msgmax;         /* max chars in a message */
  110         int32_t msgmni;         /* max message queue identifiers */
  111         int32_t msgmnb;         /* max chars in a queue */
  112         int32_t msgtql;         /* max messages in system */
  113         int32_t msgssz;         /* size of a message segment
  114                                    (see notes above) */
  115         int32_t msgseg;         /* number of message segments */
  116 };
  117 
  118 /* Warning: 64-bit structure padding is needed here */
  119 struct msgid_ds_sysctl {
  120         struct          ipc_perm_sysctl msg_perm;
  121         uint64_t        msg_qnum;
  122         uint64_t        msg_qbytes;
  123         uint64_t        _msg_cbytes;
  124         pid_t           msg_lspid;
  125         pid_t           msg_lrpid;
  126         time_t          msg_stime;
  127         time_t          msg_rtime;
  128         time_t          msg_ctime;
  129         int32_t         pad;
  130 };
  131 struct msg_sysctl_info {
  132         struct  msginfo msginfo;
  133         struct  msgid_ds_sysctl msgids[1];
  134 };
  135 #endif /* !_POSIX_C_SOURCE && !_XOPEN_SOURCE */
  136 
  137 #ifdef _KERNEL
  138 
  139 #ifndef MSGSSZ
  140 #define MSGSSZ  8               /* Each segment must be 2^N long */
  141 #endif
  142 #ifndef MSGSEG
  143 #define MSGSEG  2048            /* must be less than 32767 */
  144 #endif
  145 #undef MSGMAX                   /* ALWAYS compute MGSMAX! */
  146 #define MSGMAX  (MSGSSZ*MSGSEG)
  147 #ifndef MSGMNB
  148 #define MSGMNB  2048            /* max # of bytes in a queue */
  149 #endif
  150 #ifndef MSGMNI
  151 #define MSGMNI  40
  152 #endif
  153 #ifndef MSGTQL
  154 #define MSGTQL  40
  155 #endif
  156 
  157 /*
  158  * macros to convert between msqid_ds's and msqid's.
  159  */
  160 #define MSQID(ix,ds)    ((ix) & 0xffff | (((ds).msg_perm._seq << 16) & 0xffff0000))
  161 #define MSQID_IX(id)    ((id) & 0xffff)
  162 #define MSQID_SEQ(id)   (((id) >> 16) & 0xffff)
  163 
  164 /*
  165  * Stuff allocated in machdep.h
  166  */
  167 struct msgmap {
  168         short   next;           /* next segment in buffer */
  169                                 /* -1 -> available */
  170                                 /* 0..(MSGSEG-1) -> index of next segment */
  171 };
  172 
  173 typedef struct kmsq {
  174         struct msqid_ds msq_u;
  175         kcondvar_t      msq_cv;
  176 } kmsq_t;
  177 
  178 extern struct msginfo msginfo;
  179 extern kmsq_t   *msqs;          /* MSGMNI queues */
  180 extern kmutex_t msgmutex;
  181 
  182 #define MSG_LOCKED      01000   /* Is this msqid_ds locked? */
  183 
  184 #endif /* _KERNEL */
  185 
  186 #ifndef _KERNEL
  187 #include <sys/cdefs.h>
  188 
  189 __BEGIN_DECLS
  190 int     msgctl(int, int, struct msqid_ds *) __RENAME(__msgctl13);
  191 int     msgget(key_t, int);
  192 int     msgsnd(int, const void *, size_t, int);
  193 ssize_t msgrcv(int, void *, size_t, long, int);
  194 __END_DECLS
  195 #else
  196 #include <sys/systm.h>
  197 
  198 struct proc;
  199 
  200 void    msginit(void);
  201 int     msgctl1(struct lwp *, int, int, struct msqid_ds *);
  202 int     msgsnd1(struct lwp *, int, const char *, size_t, int, size_t,
  203     copyin_t);
  204 int     msgrcv1(struct lwp *, int, char *, size_t, long, int, size_t,
  205     copyout_t, register_t *);
  206 #endif /* !_KERNEL */
  207 
  208 #endif /* !_SYS_MSG_H_ */

Cache object: d549b7e9844a0bd52563d6d898b4e27c


[ 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.