msg.h revision 101971
150477Speter/* $FreeBSD: head/sys/sys/msg.h 101971 2002-08-16 07:42:18Z alfred $ */
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
262729Sdfr#include <sys/ipc.h>
272729Sdfr
282729Sdfr/*
292729Sdfr * The MSG_NOERROR identifier value, the msqid_ds struct and the msg struct
302729Sdfr * are as defined by the SV API Intel 386 Processor Supplement.
312729Sdfr */
322729Sdfr
332729Sdfr#define MSG_NOERROR	010000		/* don't complain about too long msgs */
342729Sdfr
3559839Speterstruct msg;
3659839Speter
372729Sdfrstruct msqid_ds {
382729Sdfr	struct	ipc_perm msg_perm;	/* msg queue permission bits */
392729Sdfr	struct	msg *msg_first;	/* first message in the queue */
402729Sdfr	struct	msg *msg_last;	/* last message in the queue */
412729Sdfr	u_long	msg_cbytes;	/* number of bytes in use on the queue */
422729Sdfr	u_long	msg_qnum;	/* number of msgs in the queue */
432729Sdfr	u_long	msg_qbytes;	/* max # of bytes on the queue */
442729Sdfr	pid_t	msg_lspid;	/* pid of last msgsnd() */
452729Sdfr	pid_t	msg_lrpid;	/* pid of last msgrcv() */
462729Sdfr	time_t	msg_stime;	/* time of last msgsnd() */
472729Sdfr	long	msg_pad1;
482729Sdfr	time_t	msg_rtime;	/* time of last msgrcv() */
492729Sdfr	long	msg_pad2;
502729Sdfr	time_t	msg_ctime;	/* time of last msgctl() */
512729Sdfr	long	msg_pad3;
522729Sdfr	long	msg_pad4[4];
532729Sdfr};
542729Sdfr
552729Sdfr/*
562729Sdfr * Structure describing a message.  The SVID doesn't suggest any
572729Sdfr * particular name for this structure.  There is a reference in the
582729Sdfr * msgop man page that reads "The structure mymsg is an example of what
592729Sdfr * this user defined buffer might look like, and includes the following
602729Sdfr * members:".  This sentence is followed by two lines equivalent
612729Sdfr * to the mtype and mtext field declarations below.  It isn't clear
62101971Salfred * if "mymsg" refers to the name of the structure type or the name of an
632729Sdfr * instance of the structure...
642729Sdfr */
652729Sdfrstruct mymsg {
662729Sdfr	long	mtype;		/* message type (+ve integer) */
672729Sdfr	char	mtext[1];	/* message body */
682729Sdfr};
692729Sdfr
7059839Speter#ifdef _KERNEL
7159839Speter
722729Sdfr/*
732729Sdfr * Based on the configuration parameters described in an SVR2 (yes, two)
742729Sdfr * config(1m) man page.
752729Sdfr *
762729Sdfr * Each message is broken up and stored in segments that are msgssz bytes
772729Sdfr * long.  For efficiency reasons, this should be a power of two.  Also,
782729Sdfr * it doesn't make sense if it is less than 8 or greater than about 256.
792729Sdfr * Consequently, msginit in kern/sysv_msg.c checks that msgssz is a power of
802729Sdfr * two between 8 and 1024 inclusive (and panic's if it isn't).
812729Sdfr */
822729Sdfrstruct msginfo {
832729Sdfr	int	msgmax,		/* max chars in a message */
842729Sdfr		msgmni,		/* max message queue identifiers */
852729Sdfr		msgmnb,		/* max chars in a queue */
862729Sdfr		msgtql,		/* max messages in system */
872729Sdfr		msgssz,		/* size of a message segment (see notes above) */
882729Sdfr		msgseg;		/* number of message segments */
892729Sdfr};
902836Sdgextern struct msginfo	msginfo;
912729Sdfr#endif
922729Sdfr
9359839Speter#ifndef _KERNEL
942729Sdfr
952729Sdfr#include <sys/cdefs.h>
962729Sdfr
972729Sdfr__BEGIN_DECLS
9892719Salfredint msgsys(int, ...);
9992719Salfredint msgctl(int, int, struct msqid_ds *);
10092719Salfredint msgget(key_t, int);
10192719Salfredint msgsnd(int, void *, size_t, int);
10292719Salfredint msgrcv(int, void*, size_t, long, int);
1032729Sdfr__END_DECLS
10455205Speter#endif
1052729Sdfr
1062729Sdfr#endif /* !_SYS_MSG_H_ */
107