Deleted Added
full compact
sysv_msg.c (10653) sysv_msg.c (11626)
1/* $Id: sysv_msg.c,v 1.7 1995/08/30 00:33:00 bde Exp $ */
1/* $Id: sysv_msg.c,v 1.8 1995/09/09 18:10:06 davidg Exp $ */
2
3/*
4 * Implementation of SVID messages
5 *
6 * Author: Daniel Boulet
7 *
8 * Copyright 1993 Daniel Boulet and RTMX Inc.
9 *

--- 6 unchanged lines hidden (view full) ---

16 * Obviously, it would be nice if you gave credit where credit is due
17 * but requiring it would be too onerous.
18 *
19 * This software is provided ``AS IS'' without any warranties of any kind.
20 */
21
22#include <sys/param.h>
23#include <sys/systm.h>
2
3/*
4 * Implementation of SVID messages
5 *
6 * Author: Daniel Boulet
7 *
8 * Copyright 1993 Daniel Boulet and RTMX Inc.
9 *

--- 6 unchanged lines hidden (view full) ---

16 * Obviously, it would be nice if you gave credit where credit is due
17 * but requiring it would be too onerous.
18 *
19 * This software is provided ``AS IS'' without any warranties of any kind.
20 */
21
22#include <sys/param.h>
23#include <sys/systm.h>
24#include <sys/sysproto.h>
24#include <sys/kernel.h>
25#include <sys/proc.h>
26#include <sys/msg.h>
25#include <sys/kernel.h>
26#include <sys/proc.h>
27#include <sys/msg.h>
27#include <sys/malloc.h>
28#include <sys/sysent.h>
28
29static void msginit __P((void *));
30SYSINIT(sysv_msg, SI_SUB_SYSV_MSG, SI_ORDER_FIRST, msginit, NULL)
31
32#define MSG_DEBUG
33#undef MSG_DEBUG_OK
34
29
30static void msginit __P((void *));
31SYSINIT(sysv_msg, SI_SUB_SYSV_MSG, SI_ORDER_FIRST, msginit, NULL)
32
33#define MSG_DEBUG
34#undef MSG_DEBUG_OK
35
35static int msgctl(), msgget(), msgsnd(), msgrcv();
36struct msgctl_args;
37static int msgctl __P((struct proc *p, struct msgctl_args *uap, int *retval));
38struct msgget_args;
39static int msgget __P((struct proc *p, struct msgget_args *uap, int *retval));
40struct msgsnd_args;
41static int msgsnd __P((struct proc *p, struct msgsnd_args *uap, int *retval));
42struct msgrcv_args;
43static int msgrcv __P((struct proc *p, struct msgrcv_args *uap, int *retval));
44static void msg_freehdr __P((struct msg *msghdr));
36
45
37int (*msgcalls[])() = { msgctl, msgget, msgsnd, msgrcv };
46/* XXX casting to (sy_call_t *) is bogus, as usual. */
47sy_call_t *msgcalls[] = {
48 (sy_call_t *)msgctl, (sy_call_t *)msgget,
49 (sy_call_t *)msgsnd, (sy_call_t *)msgrcv
50};
38
39int nfree_msgmaps; /* # of free map entries */
40short free_msgmaps; /* head of linked list of free map entries */
41struct msg *free_msghdrs; /* list of free msg headers */
42char *msgpool; /* MSGMAX byte long msg buffer pool */
43struct msgmap *msgmaps; /* MSGSEG msgmap structures */
44struct msg *msghdrs; /* MSGTQL msg headers */
45struct msqid_ds *msqids; /* MSGMNI msqid_ds struct's */
46
47void
51
52int nfree_msgmaps; /* # of free map entries */
53short free_msgmaps; /* head of linked list of free map entries */
54struct msg *free_msghdrs; /* list of free msg headers */
55char *msgpool; /* MSGMAX byte long msg buffer pool */
56struct msgmap *msgmaps; /* MSGSEG msgmap structures */
57struct msg *msghdrs; /* MSGTQL msg headers */
58struct msqid_ds *msqids; /* MSGMNI msqid_ds struct's */
59
60void
48msginit(udata)
49 void *udata;
61msginit(dummy)
62 void *dummy;
50{
51 register int i;
52
53 /*
54 * msginfo.msgssz should be a power of two for efficiency reasons.
55 * It is also pretty silly if msginfo.msgssz is less than 8
56 * or greater than about 256 so ...
57 */

--- 41 unchanged lines hidden (view full) ---

99 msqids[i].msg_qbytes = 0; /* implies entry is available */
100 msqids[i].msg_perm.seq = 0; /* reset to a known value */
101 }
102}
103
104/*
105 * Entry point for all MSG calls
106 */
63{
64 register int i;
65
66 /*
67 * msginfo.msgssz should be a power of two for efficiency reasons.
68 * It is also pretty silly if msginfo.msgssz is less than 8
69 * or greater than about 256 so ...
70 */

--- 41 unchanged lines hidden (view full) ---

112 msqids[i].msg_qbytes = 0; /* implies entry is available */
113 msqids[i].msg_perm.seq = 0; /* reset to a known value */
114 }
115}
116
117/*
118 * Entry point for all MSG calls
119 */
107
108struct msgsys_args {
109 u_int which;
110};
111
112int
113msgsys(p, uap, retval)
120int
121msgsys(p, uap, retval)
114 struct caller *p;
115 struct msgsys_args *uap;
122 struct proc *p;
123 /* XXX actually varargs. */
124 struct msgsys_args /* {
125 u_int which;
126 int a2;
127 int a3;
128 int a4;
129 int a5;
130 int a6;
131 } */ *uap;
116 int *retval;
117{
118
119 if (uap->which >= sizeof(msgcalls)/sizeof(msgcalls[0]))
120 return (EINVAL);
132 int *retval;
133{
134
135 if (uap->which >= sizeof(msgcalls)/sizeof(msgcalls[0]))
136 return (EINVAL);
121 return ((*msgcalls[uap->which])(p, &uap[1], retval));
137 return ((*msgcalls[uap->which])(p, &uap->a2, retval));
122}
123
124static void
125msg_freehdr(msghdr)
126 struct msg *msghdr;
127{
128 while (msghdr->msg_ts > 0) {
129 short next;

--- 16 unchanged lines hidden (view full) ---

146}
147
148struct msgctl_args {
149 int msqid;
150 int cmd;
151 struct msqid_ds *user_msqptr;
152};
153
138}
139
140static void
141msg_freehdr(msghdr)
142 struct msg *msghdr;
143{
144 while (msghdr->msg_ts > 0) {
145 short next;

--- 16 unchanged lines hidden (view full) ---

162}
163
164struct msgctl_args {
165 int msqid;
166 int cmd;
167 struct msqid_ds *user_msqptr;
168};
169
154int
170static int
155msgctl(p, uap, retval)
156 struct proc *p;
157 register struct msgctl_args *uap;
158 int *retval;
159{
160 int msqid = uap->msqid;
161 int cmd = uap->cmd;
162 struct msqid_ds *user_msqptr = uap->user_msqptr;

--- 117 unchanged lines hidden (view full) ---

280 return(eval);
281}
282
283struct msgget_args {
284 key_t key;
285 int msgflg;
286};
287
171msgctl(p, uap, retval)
172 struct proc *p;
173 register struct msgctl_args *uap;
174 int *retval;
175{
176 int msqid = uap->msqid;
177 int cmd = uap->cmd;
178 struct msqid_ds *user_msqptr = uap->user_msqptr;

--- 117 unchanged lines hidden (view full) ---

296 return(eval);
297}
298
299struct msgget_args {
300 key_t key;
301 int msgflg;
302};
303
288int
304static int
289msgget(p, uap, retval)
290 struct proc *p;
291 register struct msgget_args *uap;
292 int *retval;
293{
294 int msqid, eval;
295 int key = uap->key;
296 int msgflg = uap->msgflg;

--- 90 unchanged lines hidden (view full) ---

387
388struct msgsnd_args {
389 int msqid;
390 void *user_msgp;
391 size_t msgsz;
392 int msgflg;
393};
394
305msgget(p, uap, retval)
306 struct proc *p;
307 register struct msgget_args *uap;
308 int *retval;
309{
310 int msqid, eval;
311 int key = uap->key;
312 int msgflg = uap->msgflg;

--- 90 unchanged lines hidden (view full) ---

403
404struct msgsnd_args {
405 int msqid;
406 void *user_msgp;
407 size_t msgsz;
408 int msgflg;
409};
410
395int
411static int
396msgsnd(p, uap, retval)
397 struct proc *p;
398 register struct msgsnd_args *uap;
399 int *retval;
400{
401 int msqid = uap->msqid;
402 void *user_msgp = uap->user_msgp;
403 size_t msgsz = uap->msgsz;

--- 318 unchanged lines hidden (view full) ---

722struct msgrcv_args {
723 int msqid;
724 void *msgp;
725 size_t msgsz;
726 long msgtyp;
727 int msgflg;
728};
729
412msgsnd(p, uap, retval)
413 struct proc *p;
414 register struct msgsnd_args *uap;
415 int *retval;
416{
417 int msqid = uap->msqid;
418 void *user_msgp = uap->user_msgp;
419 size_t msgsz = uap->msgsz;

--- 318 unchanged lines hidden (view full) ---

738struct msgrcv_args {
739 int msqid;
740 void *msgp;
741 size_t msgsz;
742 long msgtyp;
743 int msgflg;
744};
745
730int
746static int
731msgrcv(p, uap, retval)
732 struct proc *p;
733 register struct msgrcv_args *uap;
734 int *retval;
735{
736 int msqid = uap->msqid;
737 void *user_msgp = uap->msgp;
738 size_t msgsz = uap->msgsz;

--- 268 unchanged lines hidden ---
747msgrcv(p, uap, retval)
748 struct proc *p;
749 register struct msgrcv_args *uap;
750 int *retval;
751{
752 int msqid = uap->msqid;
753 void *user_msgp = uap->msgp;
754 size_t msgsz = uap->msgsz;

--- 268 unchanged lines hidden ---