1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/genericopenlibs/openenvcore/include/sys/msg.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,198 @@
1.4 +/* $FreeBSD: src/sys/sys/msg.h,v 1.20 2005/01/07 02:29:23 imp Exp $ */
1.5 +/* $NetBSD: msg.h,v 1.4 1994/06/29 06:44:43 cgd Exp $ */
1.6 +
1.7 +/*-
1.8 + * SVID compatible msg.h file
1.9 + *
1.10 + * Author: Daniel Boulet
1.11 + *
1.12 + *© Portions copyright (c) 2006 Nokia Corporation. All rights reserved.
1.13 + * Copyright 1993 Daniel Boulet and RTMX Inc.
1.14 + *
1.15 + * This system call was implemented by Daniel Boulet under contract from RTMX.
1.16 + *
1.17 + * Redistribution and use in source forms, with and without modification,
1.18 + * are permitted provided that this entire comment appears intact.
1.19 + *
1.20 + * Redistribution in binary form may occur without any restrictions.
1.21 + * Obviously, it would be nice if you gave credit where credit is due
1.22 + * but requiring it would be too onerous.
1.23 + *
1.24 + * This software is provided ``AS IS'' without any warranties of any kind.
1.25 + */
1.26 +
1.27 +#ifndef _SYS_MSG_H_
1.28 +#define _SYS_MSG_H_
1.29 +
1.30 +#include <sys/cdefs.h>
1.31 +#include <sys/_types.h>
1.32 +#include <sys/ipc.h>
1.33 +
1.34 +/*
1.35 + * The MSG_NOERROR identifier value, the msqid_ds struct and the msg struct
1.36 + * are as defined by the SV API Intel 386 Processor Supplement.
1.37 + */
1.38 +
1.39 +#define MSG_NOERROR 010000 /* don't complain about too long msgs */
1.40 +
1.41 +typedef unsigned long msglen_t;
1.42 +typedef unsigned long msgqnum_t;
1.43 +
1.44 +#ifndef _PID_T_DECLARED
1.45 +typedef __pid_t pid_t;
1.46 +#define _PID_T_DECLARED
1.47 +#endif
1.48 +
1.49 +#ifndef _SIZE_T_DECLARED
1.50 +typedef __size_t size_t;
1.51 +#define _SIZE_T_DECLARED
1.52 +#endif
1.53 +
1.54 +#ifndef _SSIZE_T_DECLARED
1.55 +typedef __ssize_t ssize_t;
1.56 +#define _SSIZE_T_DECLARED
1.57 +#endif
1.58 +
1.59 +#ifndef _TIME_T_DECLARED
1.60 +typedef __time_t time_t;
1.61 +#define _TIME_T_DECLARED
1.62 +#endif
1.63 +
1.64 +/*
1.65 + * XXX there seems to be no prefix reserved for this header, so the name
1.66 + * "msg" in "struct msg" and the names of all of the nonstandard members
1.67 + * (mainly "msg_pad*) are namespace pollution.
1.68 + */
1.69 +
1.70 +struct msqid_ds {
1.71 + struct ipc_perm msg_perm; /* msg queue permission bits */
1.72 + struct msg *msg_first; /* first message in the queue */
1.73 + struct msg *msg_last; /* last message in the queue */
1.74 + msglen_t msg_cbytes; /* number of bytes in use on the queue */
1.75 + msgqnum_t msg_qnum; /* number of msgs in the queue */
1.76 + msglen_t msg_qbytes; /* max # of bytes on the queue */
1.77 + pid_t msg_lspid; /* pid of last msgsnd() */
1.78 + pid_t msg_lrpid; /* pid of last msgrcv() */
1.79 + time_t msg_stime; /* time of last msgsnd() */
1.80 + long msg_pad1;
1.81 + time_t msg_rtime; /* time of last msgrcv() */
1.82 + long msg_pad2;
1.83 + time_t msg_ctime; /* time of last msgctl() */
1.84 + long msg_pad3;
1.85 + long msg_pad4[4];
1.86 +};
1.87 +
1.88 +#if __BSD_VISIBLE
1.89 +/*
1.90 + * Structure describing a message. The SVID doesn't suggest any
1.91 + * particular name for this structure. There is a reference in the
1.92 + * msgop man page that reads "The structure mymsg is an example of what
1.93 + * this user defined buffer might look like, and includes the following
1.94 + * members:". This sentence is followed by two lines equivalent
1.95 + * to the mtype and mtext field declarations below. It isn't clear
1.96 + * if "mymsg" refers to the name of the structure type or the name of an
1.97 + * instance of the structure...
1.98 + */
1.99 +struct mymsg {
1.100 + long mtype; /* message type (+ve integer) */
1.101 + char mtext[1]; /* message body */
1.102 +};
1.103 +#endif
1.104 +
1.105 +#ifdef _KERNEL
1.106 +
1.107 +struct msg {
1.108 + struct msg *msg_next; /* next msg in the chain */
1.109 + long msg_type; /* type of this message */
1.110 + /* >0 -> type of this message */
1.111 + /* 0 -> free header */
1.112 + u_short msg_ts; /* size of this message */
1.113 + short msg_spot; /* location of start of msg in buffer */
1.114 + struct label *label; /* MAC Framework label */
1.115 +};
1.116 +
1.117 +/*
1.118 + * Based on the configuration parameters described in an SVR2 (yes, two)
1.119 + * config(1m) man page.
1.120 + *
1.121 + * Each message is broken up and stored in segments that are msgssz bytes
1.122 + * long. For efficiency reasons, this should be a power of two. Also,
1.123 + * it doesn't make sense if it is less than 8 or greater than about 256.
1.124 + * Consequently, msginit in kern/sysv_msg.c checks that msgssz is a power of
1.125 + * two between 8 and 1024 inclusive (and panic's if it isn't).
1.126 + */
1.127 +struct msginfo {
1.128 + int msgmax, /* max chars in a message */
1.129 + msgmni, /* max message queue identifiers */
1.130 + msgmnb, /* max chars in a queue */
1.131 + msgtql, /* max messages in system */
1.132 + msgssz, /* size of a message segment (see notes above) */
1.133 + msgseg; /* number of message segments */
1.134 +};
1.135 +extern struct msginfo msginfo;
1.136 +
1.137 +/*
1.138 + * Kernel wrapper for the user-level structure.
1.139 + */
1.140 +struct msqid_kernel {
1.141 + /*
1.142 + * Data structure exposed to user space.
1.143 + */
1.144 + struct msqid_ds u;
1.145 +
1.146 + /*
1.147 + * Kernel-private components of the message queue.
1.148 + */
1.149 + struct label *label; /* MAC label */
1.150 +};
1.151 +
1.152 +#else /* !_KERNEL */
1.153 +
1.154 +/* Template for struct to be used as argument for `msgsnd' and `msgrcv'. */
1.155 +struct msgbuf
1.156 + {
1.157 + long int mtype; /* type of received/sent message */
1.158 + char mtext[1]; /* text of the message */
1.159 + };
1.160 +
1.161 +// FUNCTION PROTOTYPES
1.162 +
1.163 +
1.164 +// FORWARD DECLARATIONS
1.165 +
1.166 +
1.167 +// CLASS/STRUCT/FUNCTION DECLARATION
1.168 +__BEGIN_DECLS
1.169 +
1.170 +/*
1.171 +* Get the message queue identifier using the IPC key generated by ftok.
1.172 +*/
1.173 +
1.174 +IMPORT_C int msgget(key_t key, int msgflg);
1.175 +
1.176 +/*
1.177 +* Used to send a message to the queue associated with the message identifier specified by msqid.
1.178 +*/
1.179 +
1.180 +IMPORT_C int msgsnd(int msqid, const void *msgp, size_t msgsz, int msgflg);
1.181 +
1.182 +/*
1.183 +* Reads a message from the queue associated with the message queue identifier.
1.184 +*/
1.185 +
1.186 +IMPORT_C ssize_t msgrcv(int msqid, void* msgp, size_t msgsz, long msgtyp, int msgflg);
1.187 +
1.188 +/*
1.189 +* Provides an interface to control message queue and control operations as specified by cmd.
1.190 +*/
1.191 +
1.192 +IMPORT_C int msgctl(int msqid, int cmd, struct msqid_ds* buf);
1.193 +
1.194 +
1.195 +__END_DECLS
1.196 +
1.197 +#endif /* !_KERNEL */
1.198 +
1.199 +#endif // _SYS_MSG_H_
1.200 +
1.201 +// End of File