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