From owner-freebsd-hackers Tue Aug 13 17: 0:57 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 3F18F37B400 for ; Tue, 13 Aug 2002 17:00:51 -0700 (PDT) Received: from falcon.mail.pas.earthlink.net (falcon.mail.pas.earthlink.net [207.217.120.74]) by mx1.FreeBSD.org (Postfix) with ESMTP id DB71443E3B for ; Tue, 13 Aug 2002 17:00:50 -0700 (PDT) (envelope-from tlambert2@mindspring.com) Received: from pool0032.cvx40-bradley.dialup.earthlink.net ([216.244.42.32] helo=mindspring.com) by falcon.mail.pas.earthlink.net with esmtp (Exim 3.33 #1) id 17elag-0005uY-00; Tue, 13 Aug 2002 17:00:46 -0700 Message-ID: <3D599D77.C1657E75@mindspring.com> Date: Tue, 13 Aug 2002 16:59:51 -0700 From: Terry Lambert X-Mailer: Mozilla 4.79 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: hiten@uk.FreeBSD.org Cc: freebsd-hackers@FreeBSD.org Subject: Re: SysV IPC related question References: <20020813233459.25838.qmail@web21102.mail.yahoo.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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 Hiten Pandya wrote: > 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. I don't know why NetBSD doesn't have this. Perhaps they are unconcerned with the portability of code using SYSV message queues, when it comes to internal structure packing. I would think directly casting it to a long in the kernel would be a bad thing on Alpha, with certain source code in user space. I expect that they define it for the regression test so that they can actually do regression on these cases. > Also, if possible, could you outline some situations where this would be > used? Help will be very appreicated. It's because if you don't ask for a specific meswsage type (e.g. it is important for you to get messages in the order they were sent), then you can't control which message will be returned in your message buffer passed to msgrcv(2). Example: ---------- struct mymsg { long mtype; char mtest[1]; }; #define MTYPE_A 75 struct msg_a { long mtype; int id; char name[ 8]; }; #define MTYPE_B 76 struct msg_b { long mtype; char msg[ 16]; struct stat data; }; typedef union { struct mymsg mymsg; struct msg_a a; struct mdg_b b; } msg_t; msg_t msg; /* p3 = 0 :== receive any message */ if ( msgrcv(msqid, &msg, sizeof(msg), 0, 0) == -1) { perror("msgsnd"); exit( 3); } switch( msg.mymsg.mtype) { case MTYPE_A: printf( "name=%s, id = %d\n", msg.a.name, msg.a.id); break; case MTYPE_B: printf( "Result '%s', size= %d\n", msg.b.msg, msg.b.data.st_size); break; default: printf "Unrecognized message type: %d\n", msg.mymsg.mtype); break; } ---------- -- Terry To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message