epoc32/include/stdapis/sys/msg.h
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
equal deleted inserted replaced
1:666f914201fb 2:2fe1408b6811
     1 msg.h
     1 /* $FreeBSD: src/sys/sys/msg.h,v 1.20 2005/01/07 02:29:23 imp Exp $ */
       
     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  *© Portions copyright (c) 2006 Nokia Corporation.  All rights reserved.
       
    10  * Copyright 1993 Daniel Boulet and RTMX Inc.
       
    11  *
       
    12  * This system call was implemented by Daniel Boulet under contract from RTMX.
       
    13  *
       
    14  * Redistribution and use in source forms, with and without modification,
       
    15  * are permitted provided that this entire comment appears intact.
       
    16  *
       
    17  * Redistribution in binary form may occur without any restrictions.
       
    18  * Obviously, it would be nice if you gave credit where credit is due
       
    19  * but requiring it would be too onerous.
       
    20  *
       
    21  * This software is provided ``AS IS'' without any warranties of any kind.
       
    22  */
       
    23 
       
    24 #ifndef _SYS_MSG_H_
       
    25 #define _SYS_MSG_H_
       
    26 
       
    27 #include <sys/cdefs.h>
       
    28 #include <sys/_types.h>
       
    29 #include <sys/ipc.h>
       
    30 
       
    31 /*
       
    32  * The MSG_NOERROR identifier value, the msqid_ds struct and the msg struct
       
    33  * are as defined by the SV API Intel 386 Processor Supplement.
       
    34  */
       
    35 
       
    36 #define MSG_NOERROR	010000		/* don't complain about too long msgs */
       
    37 
       
    38 typedef	unsigned long	msglen_t;
       
    39 typedef	unsigned long	msgqnum_t;
       
    40 
       
    41 #ifndef _PID_T_DECLARED
       
    42 typedef	__pid_t		pid_t;
       
    43 #define	_PID_T_DECLARED
       
    44 #endif
       
    45 
       
    46 #ifndef _SIZE_T_DECLARED
       
    47 typedef	__size_t	size_t;
       
    48 #define	_SIZE_T_DECLARED
       
    49 #endif
       
    50 
       
    51 #ifndef _SSIZE_T_DECLARED
       
    52 typedef	__ssize_t	ssize_t;
       
    53 #define	_SSIZE_T_DECLARED
       
    54 #endif
       
    55 
       
    56 #ifndef _TIME_T_DECLARED
       
    57 typedef	__time_t	time_t;
       
    58 #define	_TIME_T_DECLARED
       
    59 #endif
       
    60 
       
    61 /*
       
    62  * XXX there seems to be no prefix reserved for this header, so the name
       
    63  * "msg" in "struct msg" and the names of all of the nonstandard members
       
    64  * (mainly "msg_pad*) are namespace pollution.
       
    65  */
       
    66 
       
    67 struct msqid_ds {
       
    68 	struct	ipc_perm msg_perm;	/* msg queue permission bits */
       
    69 	struct	msg *msg_first;	/* first message in the queue */
       
    70 	struct	msg *msg_last;	/* last message in the queue */
       
    71 	msglen_t msg_cbytes;	/* number of bytes in use on the queue */
       
    72 	msgqnum_t msg_qnum;	/* number of msgs in the queue */
       
    73 	msglen_t msg_qbytes;	/* max # of bytes on the queue */
       
    74 	pid_t	msg_lspid;	/* pid of last msgsnd() */
       
    75 	pid_t	msg_lrpid;	/* pid of last msgrcv() */
       
    76 	time_t	msg_stime;	/* time of last msgsnd() */
       
    77 	long	msg_pad1;
       
    78 	time_t	msg_rtime;	/* time of last msgrcv() */
       
    79 	long	msg_pad2;
       
    80 	time_t	msg_ctime;	/* time of last msgctl() */
       
    81 	long	msg_pad3;
       
    82 	long	msg_pad4[4];
       
    83 };
       
    84 
       
    85 #if __BSD_VISIBLE
       
    86 /*
       
    87  * Structure describing a message.  The SVID doesn't suggest any
       
    88  * particular name for this structure.  There is a reference in the
       
    89  * msgop man page that reads "The structure mymsg is an example of what
       
    90  * this user defined buffer might look like, and includes the following
       
    91  * members:".  This sentence is followed by two lines equivalent
       
    92  * to the mtype and mtext field declarations below.  It isn't clear
       
    93  * if "mymsg" refers to the name of the structure type or the name of an
       
    94  * instance of the structure...
       
    95  */
       
    96 struct mymsg {
       
    97 	long	mtype;		/* message type (+ve integer) */
       
    98 	char	mtext[1];	/* message body */
       
    99 };
       
   100 #endif
       
   101 
       
   102 #ifdef _KERNEL
       
   103 
       
   104 struct msg {
       
   105 	struct	msg *msg_next;  /* next msg in the chain */
       
   106 	long	msg_type; 	/* type of this message */
       
   107 				/* >0 -> type of this message */
       
   108 				/* 0 -> free header */
       
   109 	u_short	msg_ts;		/* size of this message */
       
   110 	short	msg_spot;	/* location of start of msg in buffer */
       
   111 	struct	label *label;	/* MAC Framework label */
       
   112 };
       
   113 
       
   114 /*
       
   115  * Based on the configuration parameters described in an SVR2 (yes, two)
       
   116  * config(1m) man page.
       
   117  *
       
   118  * Each message is broken up and stored in segments that are msgssz bytes
       
   119  * long.  For efficiency reasons, this should be a power of two.  Also,
       
   120  * it doesn't make sense if it is less than 8 or greater than about 256.
       
   121  * Consequently, msginit in kern/sysv_msg.c checks that msgssz is a power of
       
   122  * two between 8 and 1024 inclusive (and panic's if it isn't).
       
   123  */
       
   124 struct msginfo {
       
   125 	int	msgmax,		/* max chars in a message */
       
   126 		msgmni,		/* max message queue identifiers */
       
   127 		msgmnb,		/* max chars in a queue */
       
   128 		msgtql,		/* max messages in system */
       
   129 		msgssz,		/* size of a message segment (see notes above) */
       
   130 		msgseg;		/* number of message segments */
       
   131 };
       
   132 extern struct msginfo	msginfo;
       
   133 
       
   134 /*
       
   135  * Kernel wrapper for the user-level structure.
       
   136  */
       
   137 struct msqid_kernel {
       
   138 	/*
       
   139 	 * Data structure exposed to user space.
       
   140 	 */
       
   141 	struct	msqid_ds u;
       
   142 
       
   143 	/*
       
   144 	 * Kernel-private components of the message queue.
       
   145 	 */
       
   146 	struct	label *label;	/* MAC label */
       
   147 };
       
   148 
       
   149 #else /* !_KERNEL */
       
   150 
       
   151 /* Template for struct to be used as argument for `msgsnd' and `msgrcv'.  */
       
   152 struct msgbuf
       
   153   {
       
   154     long int mtype;     /* type of received/sent message */
       
   155     char mtext[1];      /* text of the message */
       
   156   };
       
   157 
       
   158 // FUNCTION PROTOTYPES
       
   159 
       
   160 
       
   161 // FORWARD DECLARATIONS
       
   162 
       
   163 
       
   164 // CLASS/STRUCT/FUNCTION DECLARATION
       
   165 __BEGIN_DECLS
       
   166 
       
   167 /*
       
   168 * Get the message queue identifier using the IPC key generated by ftok.
       
   169 */
       
   170 
       
   171 IMPORT_C int msgget(key_t key, int msgflg);
       
   172 
       
   173 /*
       
   174 * Used to send a message to the queue associated with the message identifier specified by msqid.
       
   175 */
       
   176 
       
   177 IMPORT_C int msgsnd(int msqid, const void *msgp, size_t msgsz, int msgflg);
       
   178 
       
   179 /*
       
   180 * Reads a message from the queue associated with the message queue identifier.
       
   181 */
       
   182 
       
   183 IMPORT_C ssize_t msgrcv(int msqid, void* msgp, size_t msgsz, long msgtyp, int msgflg);
       
   184 
       
   185 /*
       
   186 * Provides an interface to control message queue and control operations as specified by cmd.
       
   187 */
       
   188 
       
   189 IMPORT_C int msgctl(int msqid, int cmd, struct msqid_ds* buf);
       
   190 
       
   191 
       
   192 __END_DECLS
       
   193 
       
   194 #endif /* !_KERNEL */
       
   195 
       
   196 #endif // _SYS_MSG_H_
       
   197 
       
   198 //  End of File