Path: utzoo!utgpu!water!watmath!clyde!rutgers!husc6!bbn!uwmcsd1!ig!agate!ucbvax!hplabs!decwrl!labrea!rocky!rokicki From: rokicki@rocky.STANFORD.EDU (Tomas Rokicki) Newsgroups: comp.sys.amiga Subject: Re: Structure alignment in Manx C Message-ID: <1047@rocky.STANFORD.EDU> Date: 14 Feb 88 20:23:47 GMT References: <8802141808.AA27862@cory.Berkeley.EDU> Reply-To: rokicki@rocky.UUCP (Tomas Rokicki) Organization: Stanford University Computer Science Department Lines: 32 > You might want a more compact structure. > > C-A sure did, and... > > If you were to make longword alignment the default, your C compiler > would suddenly become totally incompatible with almost every Amiga structure > in existance. > > For example: struct Menu, &menu.MenuName relative to &menu.NextMenu > is on a word boundry. struct MenuItem, Node, Message, and thus IORequest, > IOStdReq, etc..... > > -Matt Oh my, I didn't realize the problem was quite so deep seated! Even the Amiga software wasn't really designed with the 68020 in mind, then! I always order my structures so longwords stay on longword boundaries. You should lose at most three bytes per structure. And the structures are ingrained enough so they will not change . . . You are absolutely correct, though, about Amiga structures not being organized around a 32-bit word, even at the lowest level (struct Node{struct Node *ln_Succ,*ln_Pred; UBYTE ln_type;BYTE ln_Pri;char *ln_Name;};). Ouch, ouch, double ouch. Putting in a SHORT ln_Pad would have added 2 bytes to this 14-byte structure; I think that would have been a worthwhile tradeoff. No use crying over spilt milk, I guess. But if some new, later Amiga does have such changes that most code needs recompiling to run (for instance, MEMF_PUBLIC enforced due to an MMU or some such) then it might be worthwhile to investigate the cost of making this change. -tom