msg.h revision 137816
150477Speter/* $FreeBSD: head/sys/sys/msg.h 137816 2004-11-17 13:12:06Z rwatson $ */ 22729Sdfr/* $NetBSD: msg.h,v 1.4 1994/06/29 06:44:43 cgd Exp $ */ 32729Sdfr 42729Sdfr/* 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 60108383Smike/* 61108383Smike * XXX there seems to be no prefix reserved for this header, so the name 62108383Smike * "msg" in "struct msg" and the names of all of the nonstandard members 63108383Smike * (mainly "msg_pad*) are namespace pollution. 64108383Smike */ 65108383Smike 662729Sdfrstruct msqid_ds { 672729Sdfr struct ipc_perm msg_perm; /* msg queue permission bits */ 682729Sdfr struct msg *msg_first; /* first message in the queue */ 692729Sdfr struct msg *msg_last; /* last message in the queue */ 70108048Smike msglen_t msg_cbytes; /* number of bytes in use on the queue */ 71108048Smike msgqnum_t msg_qnum; /* number of msgs in the queue */ 72108048Smike msglen_t msg_qbytes; /* max # of bytes on the queue */ 732729Sdfr pid_t msg_lspid; /* pid of last msgsnd() */ 742729Sdfr pid_t msg_lrpid; /* pid of last msgrcv() */ 752729Sdfr time_t msg_stime; /* time of last msgsnd() */ 762729Sdfr long msg_pad1; 772729Sdfr time_t msg_rtime; /* time of last msgrcv() */ 782729Sdfr long msg_pad2; 792729Sdfr time_t msg_ctime; /* time of last msgctl() */ 802729Sdfr long msg_pad3; 812729Sdfr long msg_pad4[4]; 822729Sdfr}; 832729Sdfr 84108048Smike#if __BSD_VISIBLE 852729Sdfr/* 862729Sdfr * Structure describing a message. The SVID doesn't suggest any 872729Sdfr * particular name for this structure. There is a reference in the 882729Sdfr * msgop man page that reads "The structure mymsg is an example of what 892729Sdfr * this user defined buffer might look like, and includes the following 902729Sdfr * members:". This sentence is followed by two lines equivalent 912729Sdfr * to the mtype and mtext field declarations below. It isn't clear 92101971Salfred * if "mymsg" refers to the name of the structure type or the name of an 932729Sdfr * instance of the structure... 942729Sdfr */ 952729Sdfrstruct mymsg { 962729Sdfr long mtype; /* message type (+ve integer) */ 972729Sdfr char mtext[1]; /* message body */ 982729Sdfr}; 99108048Smike#endif 1002729Sdfr 10159839Speter#ifdef _KERNEL 10259839Speter 103137613Srwatsonstruct msg { 104137613Srwatson struct msg *msg_next; /* next msg in the chain */ 105137613Srwatson long msg_type; /* type of this message */ 106137613Srwatson /* >0 -> type of this message */ 107137613Srwatson /* 0 -> free header */ 108137613Srwatson u_short msg_ts; /* size of this message */ 109137613Srwatson short msg_spot; /* location of start of msg in buffer */ 110137816Srwatson struct label *label; /* MAC Framework label */ 111137613Srwatson}; 112137613Srwatson 1132729Sdfr/* 1142729Sdfr * Based on the configuration parameters described in an SVR2 (yes, two) 1152729Sdfr * config(1m) man page. 1162729Sdfr * 1172729Sdfr * Each message is broken up and stored in segments that are msgssz bytes 1182729Sdfr * long. For efficiency reasons, this should be a power of two. Also, 1192729Sdfr * it doesn't make sense if it is less than 8 or greater than about 256. 1202729Sdfr * Consequently, msginit in kern/sysv_msg.c checks that msgssz is a power of 1212729Sdfr * two between 8 and 1024 inclusive (and panic's if it isn't). 1222729Sdfr */ 1232729Sdfrstruct msginfo { 1242729Sdfr int msgmax, /* max chars in a message */ 1252729Sdfr msgmni, /* max message queue identifiers */ 1262729Sdfr msgmnb, /* max chars in a queue */ 1272729Sdfr msgtql, /* max messages in system */ 1282729Sdfr msgssz, /* size of a message segment (see notes above) */ 1292729Sdfr msgseg; /* number of message segments */ 1302729Sdfr}; 1312836Sdgextern struct msginfo msginfo; 1322729Sdfr 133137611Srwatson/* 134137611Srwatson * Kernel wrapper for the user-level structure. 135137611Srwatson */ 136137611Srwatsonstruct msqid_kernel { 137137611Srwatson /* 138137611Srwatson * Data structure exposed to user space. 139137611Srwatson */ 140137611Srwatson struct msqid_ds u; 141137611Srwatson 142137611Srwatson /* 143137611Srwatson * Kernel-private components of the message queue. 144137611Srwatson */ 145137816Srwatson struct label *label; /* MAC label */ 146137611Srwatson}; 147137611Srwatson 148108383Smike#else /* !_KERNEL */ 1492729Sdfr 1502729Sdfr__BEGIN_DECLS 15192719Salfredint msgctl(int, int, struct msqid_ds *); 15292719Salfredint msgget(key_t, int); 153108048Smike/* XXX return value should be ssize_t. */ 154108048Smikeint msgrcv(int, void *, size_t, long, int); 155109895Salfredint msgsnd(int, const void *, size_t, int); 156108048Smike#if __BSD_VISIBLE 157108048Smikeint msgsys(int, ...); 158108048Smike#endif 1592729Sdfr__END_DECLS 160108048Smike 161108383Smike#endif /* _KERNEL */ 1622729Sdfr 1632729Sdfr#endif /* !_SYS_MSG_H_ */ 164