home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cs.utexas.edu!swrinde!mips!darwin.sura.net!haven.umd.edu!ni.umd.edu!zben-mac-ii.umd.edu!user
- From: zben@ni.umd.edu (Charles B. Cranston)
- Newsgroups: comp.sys.mac.programmer
- Subject: Re: byte alignment problem
- Message-ID: <zben-210892153814@zben-mac-ii.umd.edu>
- Date: 21 Aug 92 19:44:23 GMT
- References: <1992Aug17.233739.19308@athena.cs.uga.edu> <John_Shepardson.esh-210892102752@moose.slac.stanford.edu>
- Sender: usenet@ni.umd.edu (USENET News System)
- Followup-To: comp.sys.mac.programmer
- Organization: UM Home for the Terminally Analytical
- Lines: 49
- Nntp-Posting-Host: zben-mac-ii.umd.edu
-
- In article <1992Aug17.233739.19308@athena.cs.uga.edu>,
- kinsey@athena.cs.uga.edu (Kevin Kinsey) wrote:
- > a quick question:
- > if given a struct { char a; long b;} x;, what is the best method
- > to create a buffer that contains 'a' followed by 'b' WITHOUT the
- > implicit padding within the struct.
-
- In article <John_Shepardson.esh-210892102752@moose.slac.stanford.edu>,
- John_Shepardson.esh@qmail.slac.stanford.edu (John Shepardson) wrote:
- > Think C will not add the pad byte within a struct. I can't say about other
- > compilers.
-
- MPW C will not add pad bytes either. Guess why the comment in
- this data structure, from one of my programs that failed on 68000
- hardware:
-
- typedef struct {
- DialogRecord dlog;
- short wtype;
- Rect wrect;
- Point ipos;
- WindowPtr next;
-
- Handle rhand;
- int timer;
- int tcpst;
- int rhost;
- short rport;
- short reason;
- short dindex;
- char option;
- char workf;
- char openf;
- char filler; /* SE/68000 netbuf must be word aligned! */
-
- char buffer[BUFMAX];
- char netbuf[NBSIZE];
- struct hostInfo hinfo;
- } qwtype, *qwptr;
-
- Hint: netbuf is being passed to MacTCP as an 8096 byte connection
- buffer, and MacTCP is erecting a custom heap zone in this buffer,
- and the heap zone creation code in ROM does a long store into one
- of the zone header fields to initialize it.
-
- Actually, the only thing suprising is that it all worked fine on
- 680x0 x<0 processors even though it was odd-aligned!!!
-
- zben@ni.umd.edu -KA3ZDF
-