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/bsd/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 /*
    2  * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
    3  *
    4  * @APPLE_LICENSE_HEADER_START@
    5  * 
    6  * Copyright (c) 1999-2003 Apple Computer, Inc.  All Rights Reserved.
    7  * 
    8  * This file contains Original Code and/or Modifications of Original Code
    9  * as defined in and that are subject to the Apple Public Source License
   10  * Version 2.0 (the 'License'). You may not use this file except in
   11  * compliance with the License. Please obtain a copy of the License at
   12  * http://www.opensource.apple.com/apsl/ and read it before using this
   13  * file.
   14  * 
   15  * The Original Code and all software distributed under the License are
   16  * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
   17  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
   18  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
   19  * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
   20  * Please see the License for the specific language governing rights and
   21  * limitations under the License.
   22  * 
   23  * @APPLE_LICENSE_HEADER_END@
   24  */
   25 /*      $NetBSD: msg.h,v 1.4 1994/06/29 06:44:43 cgd Exp $      */
   26 
   27 /*
   28  * SVID compatible msg.h file
   29  *
   30  * Author:  Daniel Boulet
   31  *
   32  * Copyright 1993 Daniel Boulet and RTMX Inc.
   33  *
   34  * This system call was implemented by Daniel Boulet under contract from RTMX.
   35  *
   36  * Redistribution and use in source forms, with and without modification,
   37  * are permitted provided that this entire comment appears intact.
   38  *
   39  * Redistribution in binary form may occur without any restrictions.
   40  * Obviously, it would be nice if you gave credit where credit is due
   41  * but requiring it would be too onerous.
   42  *
   43  * This software is provided ``AS IS'' without any warranties of any kind.
   44  */
   45 
   46 #ifndef _SYS_MSG_H_
   47 #define _SYS_MSG_H_
   48 
   49 #include <sys/appleapiopts.h>
   50 
   51 #ifdef __APPLE_API_UNSTABLE
   52 #include <sys/ipc.h>
   53 
   54 
   55 /*
   56  * The MSG_NOERROR identifier value, the msqid_ds struct and the msg struct
   57  * are as defined by the SV API Intel 386 Processor Supplement.
   58  */
   59 
   60 #define MSG_NOERROR     010000          /* don't complain about too long msgs */
   61 
   62 struct msqid_ds {
   63         struct  ipc_perm msg_perm;      /* msg queue permission bits */
   64         struct  msg *msg_first; /* first message in the queue */
   65         struct  msg *msg_last;  /* last message in the queue */
   66         u_long  msg_cbytes;     /* number of bytes in use on the queue */
   67         u_long  msg_qnum;       /* number of msgs in the queue */
   68         u_long  msg_qbytes;     /* max # of bytes on the queue */
   69         pid_t   msg_lspid;      /* pid of last msgsnd() */
   70         pid_t   msg_lrpid;      /* pid of last msgrcv() */
   71         time_t  msg_stime;      /* time of last msgsnd() */
   72         long    msg_pad1;
   73         time_t  msg_rtime;      /* time of last msgrcv() */
   74         long    msg_pad2;
   75         time_t  msg_ctime;      /* time of last msgctl() */
   76         long    msg_pad3;
   77         long    msg_pad4[4];
   78 };
   79 
   80 struct msg {
   81         struct  msg *msg_next;  /* next msg in the chain */
   82         long    msg_type;       /* type of this message */
   83                                 /* >0 -> type of this message */
   84                                 /* 0 -> free header */
   85         u_short msg_ts;         /* size of this message */
   86         short   msg_spot;       /* location of start of msg in buffer */
   87 };
   88 
   89 /*
   90  * Structure describing a message.  The SVID doesn't suggest any
   91  * particular name for this structure.  There is a reference in the
   92  * msgop man page that reads "The structure mymsg is an example of what
   93  * this user defined buffer might look like, and includes the following
   94  * members:".  This sentence is followed by two lines equivalent
   95  * to the mtype and mtext field declarations below.  It isn't clear
   96  * if "mymsg" refers to the naem of the structure type or the name of an
   97  * instance of the structure...
   98  */
   99 struct mymsg {
  100         long    mtype;          /* message type (+ve integer) */
  101         char    mtext[1];       /* message body */
  102 };
  103 
  104 /*
  105  * Based on the configuration parameters described in an SVR2 (yes, two)
  106  * config(1m) man page.
  107  *
  108  * Each message is broken up and stored in segments that are msgssz bytes
  109  * long.  For efficiency reasons, this should be a power of two.  Also,
  110  * it doesn't make sense if it is less than 8 or greater than about 256.
  111  * Consequently, msginit in kern/sysv_msg.c checks that msgssz is a power of
  112  * two between 8 and 1024 inclusive (and panic's if it isn't).
  113  */
  114 struct msginfo {
  115         int     msgmax,         /* max chars in a message */
  116                 msgmni,         /* max message queue identifiers */
  117                 msgmnb,         /* max chars in a queue */
  118                 msgtql,         /* max messages in system */
  119                 msgssz,         /* size of a message segment (see notes above) */
  120                 msgseg;         /* number of message segments */
  121 };
  122 #ifdef KERNEL
  123 extern struct msginfo   msginfo;
  124 
  125 #ifndef MSGSSZ
  126 #define MSGSSZ  8               /* Each segment must be 2^N long */
  127 #endif
  128 #ifndef MSGSEG
  129 #define MSGSEG  2048            /* must be less than 32767 */
  130 #endif
  131 #define MSGMAX  (MSGSSZ*MSGSEG)
  132 #ifndef MSGMNB
  133 #define MSGMNB  2048            /* max # of bytes in a queue */
  134 #endif
  135 #ifndef MSGMNI
  136 #define MSGMNI  40
  137 #endif
  138 #ifndef MSGTQL
  139 #define MSGTQL  40
  140 #endif
  141 
  142 /*
  143  * macros to convert between msqid_ds's and msqid's.
  144  * (specific to this implementation)
  145  */
  146 #define MSQID(ix,ds)    ((ix) & 0xffff | (((ds).msg_perm.seq << 16) & 0xffff0000))
  147 #define MSQID_IX(id)    ((id) & 0xffff)
  148 #define MSQID_SEQ(id)   (((id) >> 16) & 0xffff)
  149 
  150 /*
  151  * The rest of this file is specific to this particular implementation.
  152  */
  153 
  154 
  155 /*
  156  * Stuff allocated in machdep.h
  157  */
  158 struct msgmap {
  159         short   next;           /* next segment in buffer */
  160                                 /* -1 -> available */
  161                                 /* 0..(MSGSEG-1) -> index of next segment */
  162 };
  163 
  164 extern char *msgpool;           /* MSGMAX byte long msg buffer pool */
  165 extern struct msgmap *msgmaps;  /* MSGSEG msgmap structures */
  166 extern struct msg *msghdrs;     /* MSGTQL msg headers */
  167 extern struct msqid_ds *msqids; /* MSGMNI msqid_ds struct's */
  168 
  169 #define MSG_LOCKED      01000   /* Is this msqid_ds locked? */
  170 
  171 #endif /* KERNEL */
  172 
  173 #ifndef KERNEL
  174 #include <sys/cdefs.h>
  175 
  176 __BEGIN_DECLS
  177 int msgsys __P((int, ...));
  178 int msgctl __P((int, int, struct msqid_ds *));
  179 int msgget __P((key_t, int));
  180 int msgsnd __P((int, void *, size_t, int));
  181 int msgrcv __P((int, void*, size_t, long, int));
  182 __END_DECLS
  183 #endif /* !KERNEL */
  184 
  185 #endif /* __APPLE_API_UNSTABLE */
  186 #endif /* !_SYS_MSG_H_ */

Cache object: 9ca96c7d71c09eb0cdd63bfa6221fda4


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