150477Speter/* $FreeBSD: releng/10.3/sys/sys/msg.h 220388 2011-04-06 16:59:54Z trasz $ */ 22729Sdfr/* $NetBSD: msg.h,v 1.4 1994/06/29 06:44:43 cgd Exp $ */ 32729Sdfr 4139825Simp/*- 52729Sdfr * SVID compatible msg.h file 62729Sdfr * 72729Sdfr * Author: Daniel Boulet 82729Sdfr * 92729Sdfr * Copyright 1993 Daniel Boulet and RTMX Inc. 102729Sdfr * 112729Sdfr * This system call was implemented by Daniel Boulet under contract from RTMX. 122729Sdfr * 132729Sdfr * Redistribution and use in source forms, with and without modification, 142729Sdfr * are permitted provided that this entire comment appears intact. 152729Sdfr * 162729Sdfr * Redistribution in binary form may occur without any restrictions. 172729Sdfr * Obviously, it would be nice if you gave credit where credit is due 182729Sdfr * but requiring it would be too onerous. 192729Sdfr * 202729Sdfr * This software is provided ``AS IS'' without any warranties of any kind. 212729Sdfr */ 222729Sdfr 232729Sdfr#ifndef _SYS_MSG_H_ 242729Sdfr#define _SYS_MSG_H_ 252729Sdfr 26108048Smike#include <sys/cdefs.h> 27108048Smike#include <sys/_types.h> 282729Sdfr#include <sys/ipc.h> 292729Sdfr 302729Sdfr/* 312729Sdfr * The MSG_NOERROR identifier value, the msqid_ds struct and the msg struct 322729Sdfr * are as defined by the SV API Intel 386 Processor Supplement. 332729Sdfr */ 342729Sdfr 352729Sdfr#define MSG_NOERROR 010000 /* don't complain about too long msgs */ 362729Sdfr 37108048Smiketypedef unsigned long msglen_t; 38108048Smiketypedef unsigned long msgqnum_t; 39108048Smike 40108048Smike#ifndef _PID_T_DECLARED 41108048Smiketypedef __pid_t pid_t; 42108048Smike#define _PID_T_DECLARED 43108048Smike#endif 44108048Smike 45108048Smike#ifndef _SIZE_T_DECLARED 46108048Smiketypedef __size_t size_t; 47108048Smike#define _SIZE_T_DECLARED 48108048Smike#endif 49108048Smike 50108048Smike#ifndef _SSIZE_T_DECLARED 51108048Smiketypedef __ssize_t ssize_t; 52108048Smike#define _SSIZE_T_DECLARED 53108048Smike#endif 54108048Smike 55108383Smike#ifndef _TIME_T_DECLARED 56108383Smiketypedef __time_t time_t; 57108383Smike#define _TIME_T_DECLARED 58108383Smike#endif 5959839Speter 60194910Sjhb#if defined(COMPAT_FREEBSD4) || defined(COMPAT_FREEBSD5) || \ 61194910Sjhb defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD7) 62194910Sjhbstruct msqid_ds_old { 63194910Sjhb struct ipc_perm_old msg_perm; /* msg queue permission bits */ 64194910Sjhb struct msg *msg_first; /* first message in the queue */ 65194910Sjhb struct msg *msg_last; /* last message in the queue */ 66194910Sjhb msglen_t msg_cbytes; /* number of bytes in use on the queue */ 67194910Sjhb msgqnum_t msg_qnum; /* number of msgs in the queue */ 68194910Sjhb msglen_t msg_qbytes; /* max # of bytes on the queue */ 69194910Sjhb pid_t msg_lspid; /* pid of last msgsnd() */ 70194910Sjhb pid_t msg_lrpid; /* pid of last msgrcv() */ 71194910Sjhb time_t msg_stime; /* time of last msgsnd() */ 72194910Sjhb long msg_pad1; 73194910Sjhb time_t msg_rtime; /* time of last msgrcv() */ 74194910Sjhb long msg_pad2; 75194910Sjhb time_t msg_ctime; /* time of last msgctl() */ 76194910Sjhb long msg_pad3; 77194910Sjhb long msg_pad4[4]; 78194910Sjhb}; 79194910Sjhb#endif 80194910Sjhb 81108383Smike/* 82108383Smike * XXX there seems to be no prefix reserved for this header, so the name 83108383Smike * "msg" in "struct msg" and the names of all of the nonstandard members 84108383Smike * (mainly "msg_pad*) are namespace pollution. 85108383Smike */ 86108383Smike 872729Sdfrstruct msqid_ds { 882729Sdfr struct ipc_perm msg_perm; /* msg queue permission bits */ 892729Sdfr struct msg *msg_first; /* first message in the queue */ 902729Sdfr struct msg *msg_last; /* last message in the queue */ 91108048Smike msglen_t msg_cbytes; /* number of bytes in use on the queue */ 92108048Smike msgqnum_t msg_qnum; /* number of msgs in the queue */ 93108048Smike msglen_t msg_qbytes; /* max # of bytes on the queue */ 942729Sdfr pid_t msg_lspid; /* pid of last msgsnd() */ 952729Sdfr pid_t msg_lrpid; /* pid of last msgrcv() */ 962729Sdfr time_t msg_stime; /* time of last msgsnd() */ 972729Sdfr time_t msg_rtime; /* time of last msgrcv() */ 982729Sdfr time_t msg_ctime; /* time of last msgctl() */ 992729Sdfr}; 1002729Sdfr 101108048Smike#if __BSD_VISIBLE 1022729Sdfr/* 1032729Sdfr * Structure describing a message. The SVID doesn't suggest any 1042729Sdfr * particular name for this structure. There is a reference in the 1052729Sdfr * msgop man page that reads "The structure mymsg is an example of what 1062729Sdfr * this user defined buffer might look like, and includes the following 1072729Sdfr * members:". This sentence is followed by two lines equivalent 1082729Sdfr * to the mtype and mtext field declarations below. It isn't clear 109101971Salfred * if "mymsg" refers to the name of the structure type or the name of an 1102729Sdfr * instance of the structure... 1112729Sdfr */ 1122729Sdfrstruct mymsg { 1132729Sdfr long mtype; /* message type (+ve integer) */ 1142729Sdfr char mtext[1]; /* message body */ 1152729Sdfr}; 116108048Smike#endif 1172729Sdfr 11859839Speter#ifdef _KERNEL 11959839Speter 120137613Srwatsonstruct msg { 121137613Srwatson struct msg *msg_next; /* next msg in the chain */ 122137613Srwatson long msg_type; /* type of this message */ 123137613Srwatson /* >0 -> type of this message */ 124137613Srwatson /* 0 -> free header */ 125137613Srwatson u_short msg_ts; /* size of this message */ 126137613Srwatson short msg_spot; /* location of start of msg in buffer */ 127137816Srwatson struct label *label; /* MAC Framework label */ 128137613Srwatson}; 129137613Srwatson 1302729Sdfr/* 1312729Sdfr * Based on the configuration parameters described in an SVR2 (yes, two) 1322729Sdfr * config(1m) man page. 1332729Sdfr * 1342729Sdfr * Each message is broken up and stored in segments that are msgssz bytes 1352729Sdfr * long. For efficiency reasons, this should be a power of two. Also, 1362729Sdfr * it doesn't make sense if it is less than 8 or greater than about 256. 1372729Sdfr * Consequently, msginit in kern/sysv_msg.c checks that msgssz is a power of 1382729Sdfr * two between 8 and 1024 inclusive (and panic's if it isn't). 1392729Sdfr */ 1402729Sdfrstruct msginfo { 1412729Sdfr int msgmax, /* max chars in a message */ 1422729Sdfr msgmni, /* max message queue identifiers */ 1432729Sdfr msgmnb, /* max chars in a queue */ 1442729Sdfr msgtql, /* max messages in system */ 1452729Sdfr msgssz, /* size of a message segment (see notes above) */ 1462729Sdfr msgseg; /* number of message segments */ 1472729Sdfr}; 1482836Sdgextern struct msginfo msginfo; 1492729Sdfr 150137611Srwatson/* 151137611Srwatson * Kernel wrapper for the user-level structure. 152137611Srwatson */ 153137611Srwatsonstruct msqid_kernel { 154137611Srwatson /* 155137611Srwatson * Data structure exposed to user space. 156137611Srwatson */ 157137611Srwatson struct msqid_ds u; 158137611Srwatson 159137611Srwatson /* 160137611Srwatson * Kernel-private components of the message queue. 161137611Srwatson */ 162137816Srwatson struct label *label; /* MAC label */ 163220388Strasz struct ucred *cred; /* creator's credentials */ 164137611Srwatson}; 165137611Srwatson 166108383Smike#else /* !_KERNEL */ 1672729Sdfr 1682729Sdfr__BEGIN_DECLS 16992719Salfredint msgctl(int, int, struct msqid_ds *); 17092719Salfredint msgget(key_t, int); 171108048Smike/* XXX return value should be ssize_t. */ 172108048Smikeint msgrcv(int, void *, size_t, long, int); 173109895Salfredint msgsnd(int, const void *, size_t, int); 174108048Smike#if __BSD_VISIBLE 175108048Smikeint msgsys(int, ...); 176108048Smike#endif 1772729Sdfr__END_DECLS 178108048Smike 179108383Smike#endif /* _KERNEL */ 1802729Sdfr 1812729Sdfr#endif /* !_SYS_MSG_H_ */ 182