msg.h revision 108048
1/* $FreeBSD: head/sys/sys/msg.h 108048 2002-12-18 18:22:06Z mike $ */ 2/* $NetBSD: msg.h,v 1.4 1994/06/29 06:44:43 cgd Exp $ */ 3 4/* 5 * SVID compatible msg.h file 6 * 7 * Author: Daniel Boulet 8 * 9 * Copyright 1993 Daniel Boulet and RTMX Inc. 10 * 11 * This system call was implemented by Daniel Boulet under contract from RTMX. 12 * 13 * Redistribution and use in source forms, with and without modification, 14 * are permitted provided that this entire comment appears intact. 15 * 16 * Redistribution in binary form may occur without any restrictions. 17 * Obviously, it would be nice if you gave credit where credit is due 18 * but requiring it would be too onerous. 19 * 20 * This software is provided ``AS IS'' without any warranties of any kind. 21 */ 22 23#ifndef _SYS_MSG_H_ 24#define _SYS_MSG_H_ 25 26#include <sys/cdefs.h> 27#include <sys/_types.h> 28#include <sys/ipc.h> 29 30/* 31 * The MSG_NOERROR identifier value, the msqid_ds struct and the msg struct 32 * are as defined by the SV API Intel 386 Processor Supplement. 33 */ 34 35#define MSG_NOERROR 010000 /* don't complain about too long msgs */ 36 37typedef unsigned long msglen_t; 38typedef unsigned long msgqnum_t; 39 40#ifndef _PID_T_DECLARED 41typedef __pid_t pid_t; 42#define _PID_T_DECLARED 43#endif 44 45#ifndef _TIME_T_DECLARED 46typedef __time_t time_t; 47#define _TIME_T_DECLARED 48#endif 49 50#ifndef _SIZE_T_DECLARED 51typedef __size_t size_t; 52#define _SIZE_T_DECLARED 53#endif 54 55#ifndef _SSIZE_T_DECLARED 56typedef __ssize_t ssize_t; 57#define _SSIZE_T_DECLARED 58#endif 59 60/* XXX namespace pollution. */ 61struct msg; 62 63struct msqid_ds { 64 struct ipc_perm msg_perm; /* msg queue permission bits */ 65 struct msg *msg_first; /* first message in the queue */ 66 struct msg *msg_last; /* last message in the queue */ 67 msglen_t msg_cbytes; /* number of bytes in use on the queue */ 68 msgqnum_t msg_qnum; /* number of msgs in the queue */ 69 msglen_t msg_qbytes; /* max # of bytes on the queue */ 70 pid_t msg_lspid; /* pid of last msgsnd() */ 71 pid_t msg_lrpid; /* pid of last msgrcv() */ 72 time_t msg_stime; /* time of last msgsnd() */ 73 long msg_pad1; 74 time_t msg_rtime; /* time of last msgrcv() */ 75 long msg_pad2; 76 time_t msg_ctime; /* time of last msgctl() */ 77 long msg_pad3; 78 long msg_pad4[4]; 79}; 80 81#if __BSD_VISIBLE 82/* 83 * Structure describing a message. The SVID doesn't suggest any 84 * particular name for this structure. There is a reference in the 85 * msgop man page that reads "The structure mymsg is an example of what 86 * this user defined buffer might look like, and includes the following 87 * members:". This sentence is followed by two lines equivalent 88 * to the mtype and mtext field declarations below. It isn't clear 89 * if "mymsg" refers to the name of the structure type or the name of an 90 * instance of the structure... 91 */ 92struct mymsg { 93 long mtype; /* message type (+ve integer) */ 94 char mtext[1]; /* message body */ 95}; 96#endif 97 98#ifdef _KERNEL 99 100/* 101 * Based on the configuration parameters described in an SVR2 (yes, two) 102 * config(1m) man page. 103 * 104 * Each message is broken up and stored in segments that are msgssz bytes 105 * long. For efficiency reasons, this should be a power of two. Also, 106 * it doesn't make sense if it is less than 8 or greater than about 256. 107 * Consequently, msginit in kern/sysv_msg.c checks that msgssz is a power of 108 * two between 8 and 1024 inclusive (and panic's if it isn't). 109 */ 110struct msginfo { 111 int msgmax, /* max chars in a message */ 112 msgmni, /* max message queue identifiers */ 113 msgmnb, /* max chars in a queue */ 114 msgtql, /* max messages in system */ 115 msgssz, /* size of a message segment (see notes above) */ 116 msgseg; /* number of message segments */ 117}; 118extern struct msginfo msginfo; 119#endif 120 121#ifndef _KERNEL 122 123__BEGIN_DECLS 124int msgctl(int, int, struct msqid_ds *); 125int msgget(key_t, int); 126/* XXX return value should be ssize_t. */ 127int msgrcv(int, void *, size_t, long, int); 128/* XXX second parameter missing const type-qualifier. */ 129int msgsnd(int, void *, size_t, int); 130#if __BSD_VISIBLE 131int msgsys(int, ...); 132#endif 133__END_DECLS 134 135#endif 136 137#endif /* !_SYS_MSG_H_ */ 138