Date: Tue, 13 Aug 2002 16:34:59 -0700 (PDT) From: Hiten Pandya <hitmaster2k@yahoo.com> To: Terry Lambert <tlambert2@mindspring.com> Cc: freebsd-hackers@FreeBSD.org Subject: Re: SysV IPC related question Message-ID: <20020813233459.25838.qmail@web21102.mail.yahoo.com> In-Reply-To: <3D5994D7.E047294C@mindspring.com>
next in thread | previous in thread | raw e-mail | index | archive | help
--- Terry Lambert <tlambert2@mindspring.com> wrote: > Hiten Pandya wrote: > > I was wondering why we have a struct mymsg in <sys/msg.h>, when many > > utilities defined their own version of it. I am curious about this > > because our stock version of struct mymsg: > > > > struct mymsg { > > long mtype; /* message type */ > > char mtext[1]; /* message body */ > > }; > > > > Why do we have a value of [1] in the mtext array? Are we meant to > > define a struct mymsg at all!? > > This is the message contents. It is an overlay structure. The > [1] is the same thing that, in the current ANSI C standard, you > would define in terms of [0]. > > The point is that you have a structure that sonsists of a long > followed by an indeterminate number of bytes. You cast the > combination to a pointer to a structure of this type, and you > can reference the long as mymsgp->mtype, and the contents as > mymsgp->mtype. > > Please leave it alone. 8-). OK. One more question; so, is there any particular reason why our cousin NetBSD doesnt use this "overlay" structure? Also, the NetBSD SysV Msg regression tool defines its own struct mymsg; and doesnt have one standard in the <sys/msg.h> header file. Also, if possible, could you outline some situations where this would be used? Help will be very appreicated. Thanks. -- Hiten __________________________________________________ Do You Yahoo!? HotJobs - Search Thousands of New Jobs http://www.hotjobs.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020813233459.25838.qmail>