150477Speter/* $FreeBSD: stable/11/sys/sys/msg.h 347995 2019-05-20 16:31:45Z kib $ */ 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> 28347995Skib#ifdef _WANT_SYSVMSG_INTERNALS 29347995Skib#define _WANT_SYSVIPC_INTERNALS 30347995Skib#endif 312729Sdfr#include <sys/ipc.h> 322729Sdfr 332729Sdfr/* 342729Sdfr * The MSG_NOERROR identifier value, the msqid_ds struct and the msg struct 352729Sdfr * are as defined by the SV API Intel 386 Processor Supplement. 362729Sdfr */ 372729Sdfr 382729Sdfr#define MSG_NOERROR 010000 /* don't complain about too long msgs */ 392729Sdfr 40108048Smiketypedef unsigned long msglen_t; 41108048Smiketypedef unsigned long msgqnum_t; 42108048Smike 43108048Smike#ifndef _PID_T_DECLARED 44108048Smiketypedef __pid_t pid_t; 45108048Smike#define _PID_T_DECLARED 46108048Smike#endif 47108048Smike 48108048Smike#ifndef _SIZE_T_DECLARED 49108048Smiketypedef __size_t size_t; 50108048Smike#define _SIZE_T_DECLARED 51108048Smike#endif 52108048Smike 53108048Smike#ifndef _SSIZE_T_DECLARED 54108048Smiketypedef __ssize_t ssize_t; 55108048Smike#define _SSIZE_T_DECLARED 56108048Smike#endif 57108048Smike 58108383Smike#ifndef _TIME_T_DECLARED 59108383Smiketypedef __time_t time_t; 60108383Smike#define _TIME_T_DECLARED 61108383Smike#endif 6259839Speter 63194910Sjhb#if defined(COMPAT_FREEBSD4) || defined(COMPAT_FREEBSD5) || \ 64194910Sjhb defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD7) 65194910Sjhbstruct msqid_ds_old { 66194910Sjhb struct ipc_perm_old msg_perm; /* msg queue permission bits */ 67194910Sjhb struct msg *msg_first; /* first message in the queue */ 68194910Sjhb struct msg *msg_last; /* last message in the queue */ 69194910Sjhb msglen_t msg_cbytes; /* number of bytes in use on the queue */ 70194910Sjhb msgqnum_t msg_qnum; /* number of msgs in the queue */ 71194910Sjhb msglen_t msg_qbytes; /* max # of bytes on the queue */ 72194910Sjhb pid_t msg_lspid; /* pid of last msgsnd() */ 73194910Sjhb pid_t msg_lrpid; /* pid of last msgrcv() */ 74194910Sjhb time_t msg_stime; /* time of last msgsnd() */ 75194910Sjhb long msg_pad1; 76194910Sjhb time_t msg_rtime; /* time of last msgrcv() */ 77194910Sjhb long msg_pad2; 78194910Sjhb time_t msg_ctime; /* time of last msgctl() */ 79194910Sjhb long msg_pad3; 80194910Sjhb long msg_pad4[4]; 81194910Sjhb}; 82194910Sjhb#endif 83194910Sjhb 84108383Smike/* 85108383Smike * XXX there seems to be no prefix reserved for this header, so the name 86108383Smike * "msg" in "struct msg" and the names of all of the nonstandard members 87108383Smike * (mainly "msg_pad*) are namespace pollution. 88108383Smike */ 89108383Smike 902729Sdfrstruct msqid_ds { 912729Sdfr struct ipc_perm msg_perm; /* msg queue permission bits */ 922729Sdfr struct msg *msg_first; /* first message in the queue */ 932729Sdfr struct msg *msg_last; /* last message in the queue */ 94108048Smike msglen_t msg_cbytes; /* number of bytes in use on the queue */ 95108048Smike msgqnum_t msg_qnum; /* number of msgs in the queue */ 96108048Smike msglen_t msg_qbytes; /* max # of bytes on the queue */ 972729Sdfr pid_t msg_lspid; /* pid of last msgsnd() */ 982729Sdfr pid_t msg_lrpid; /* pid of last msgrcv() */ 992729Sdfr time_t msg_stime; /* time of last msgsnd() */ 1002729Sdfr time_t msg_rtime; /* time of last msgrcv() */ 1012729Sdfr time_t msg_ctime; /* time of last msgctl() */ 1022729Sdfr}; 1032729Sdfr 104108048Smike#if __BSD_VISIBLE 1052729Sdfr/* 1062729Sdfr * Structure describing a message. The SVID doesn't suggest any 1072729Sdfr * particular name for this structure. There is a reference in the 1082729Sdfr * msgop man page that reads "The structure mymsg is an example of what 1092729Sdfr * this user defined buffer might look like, and includes the following 1102729Sdfr * members:". This sentence is followed by two lines equivalent 1112729Sdfr * to the mtype and mtext field declarations below. It isn't clear 112101971Salfred * if "mymsg" refers to the name of the structure type or the name of an 1132729Sdfr * instance of the structure... 1142729Sdfr */ 1152729Sdfrstruct mymsg { 1162729Sdfr long mtype; /* message type (+ve integer) */ 1172729Sdfr char mtext[1]; /* message body */ 1182729Sdfr}; 119108048Smike#endif 1202729Sdfr 12159839Speter#ifdef _KERNEL 122137613Srwatsonstruct msg { 123137613Srwatson struct msg *msg_next; /* next msg in the chain */ 124137613Srwatson long msg_type; /* type of this message */ 125137613Srwatson /* >0 -> type of this message */ 126137613Srwatson /* 0 -> free header */ 127137613Srwatson u_short msg_ts; /* size of this message */ 128137613Srwatson short msg_spot; /* location of start of msg in buffer */ 129137816Srwatson struct label *label; /* MAC Framework label */ 130137613Srwatson}; 131347995Skib#endif 132137613Srwatson 133347995Skib#if defined(_KERNEL) || defined(_WANT_SYSVMSG_INTERNALS) 1342729Sdfr/* 1352729Sdfr * Based on the configuration parameters described in an SVR2 (yes, two) 1362729Sdfr * config(1m) man page. 1372729Sdfr * 1382729Sdfr * Each message is broken up and stored in segments that are msgssz bytes 1392729Sdfr * long. For efficiency reasons, this should be a power of two. Also, 1402729Sdfr * it doesn't make sense if it is less than 8 or greater than about 256. 1412729Sdfr * Consequently, msginit in kern/sysv_msg.c checks that msgssz is a power of 1422729Sdfr * two between 8 and 1024 inclusive (and panic's if it isn't). 1432729Sdfr */ 1442729Sdfrstruct msginfo { 1452729Sdfr int msgmax, /* max chars in a message */ 1462729Sdfr msgmni, /* max message queue identifiers */ 1472729Sdfr msgmnb, /* max chars in a queue */ 1482729Sdfr msgtql, /* max messages in system */ 1492729Sdfr msgssz, /* size of a message segment (see notes above) */ 1502729Sdfr msgseg; /* number of message segments */ 1512729Sdfr}; 1522729Sdfr 153137611Srwatson/* 154137611Srwatson * Kernel wrapper for the user-level structure. 155137611Srwatson */ 156137611Srwatsonstruct msqid_kernel { 157137611Srwatson /* 158137611Srwatson * Data structure exposed to user space. 159137611Srwatson */ 160137611Srwatson struct msqid_ds u; 161137611Srwatson 162137611Srwatson /* 163137611Srwatson * Kernel-private components of the message queue. 164137611Srwatson */ 165137816Srwatson struct label *label; /* MAC label */ 166220388Strasz struct ucred *cred; /* creator's credentials */ 167137611Srwatson}; 168347995Skib#endif 169137611Srwatson 170347995Skib#ifdef _KERNEL 171347995Skibextern struct msginfo msginfo; 1722729Sdfr 173347995Skib#else /* _KERNEL */ 174347995Skib 1752729Sdfr__BEGIN_DECLS 17692719Salfredint msgctl(int, int, struct msqid_ds *); 17792719Salfredint msgget(key_t, int); 178108048Smike/* XXX return value should be ssize_t. */ 179108048Smikeint msgrcv(int, void *, size_t, long, int); 180109895Salfredint msgsnd(int, const void *, size_t, int); 181108048Smike#if __BSD_VISIBLE 182108048Smikeint msgsys(int, ...); 183108048Smike#endif 1842729Sdfr__END_DECLS 185347995Skib#endif /* !_KERNEL */ 186108048Smike 1872729Sdfr#endif /* !_SYS_MSG_H_ */ 188