From owner-freebsd-hackers Tue Aug 13 16:35: 4 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A0BD237B400 for ; Tue, 13 Aug 2002 16:34:59 -0700 (PDT) Received: from web21102.mail.yahoo.com (web21102.mail.yahoo.com [216.136.227.104]) by mx1.FreeBSD.org (Postfix) with SMTP id 52EDB43E42 for ; Tue, 13 Aug 2002 16:34:59 -0700 (PDT) (envelope-from hitmaster2k@yahoo.com) Message-ID: <20020813233459.25838.qmail@web21102.mail.yahoo.com> Received: from [62.254.0.5] by web21102.mail.yahoo.com via HTTP; Tue, 13 Aug 2002 16:34:59 PDT Date: Tue, 13 Aug 2002 16:34:59 -0700 (PDT) From: Hiten Pandya Reply-To: hiten@uk.FreeBSD.org Subject: Re: SysV IPC related question To: Terry Lambert Cc: freebsd-hackers@FreeBSD.org In-Reply-To: <3D5994D7.E047294C@mindspring.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --- Terry Lambert wrote: > Hiten Pandya wrote: > > I was wondering why we have a struct mymsg in , 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 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