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

Cache object: c184e853117b7d94cb3fbd328eb415bf


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