Path: utzoo!utgpu!water!watmath!clyde!rutgers!husc6!hao!ames!ptsfa!well!manx From: manx@well.UUCP (Jim Goodnow II) Newsgroups: comp.sys.amiga Subject: Re: Structure alignment in Manx C Summary: Whoaaa!! It's not as bad as you think. Keywords: Alignment Manx Aztec C Message-ID: <5245@well.UUCP> Date: 15 Feb 88 02:51:05 GMT References: <1042@rocky.STANFORD.EDU> Reply-To: manx@well.UUCP (Jim Goodnow II) Organization: Whole Earth 'Lectronic Link, Sausalito, CA Lines: 39 In article <1042@rocky.STANFORD.EDU> rokicki@rocky.STANFORD.EDU (Tomas Rokicki) writes: >..... Specifically, Manx C does not long-word align structures >containing long words! (It also doesn't apparently long-word align >long words.) The ramifications of this are two-fold: > >- Programs compiled with Manx C and then run on a 68020 system will >run slower, as some (probably half) of their long word accesses will >need two memory accesses instead of one. > >- You cannot statically allocate anything that needs to be on a long >word boundary; for instance, packets. (Not that you should anyway, as >they should be MEMF_PUBLIC, but with the current release that doesn't >matter anyway.) Anything that will be converted to a BPTR and back >will have problems. > ...... >-tom First off, there is a definite penalty with long-word aligning data unless all your data consists of longs. Worst case would be that every char or short would generate an extra two bytes of filler to align the next item. This would be true regardless of whether int is 32 bits. Second, the number of programs running on 68020 systems is pretty much a minority at present. There will be an option for alignment in a future version of the compiler to rectify this. Third, data items allocated on the stack cannot be guaranteed to be allocated on long word boundaries when passing some arguments as shorts without making the function preamble more complicated. Fourth, you can use malloc() or AllocMem() which both are guaranteed to be aligned to a long word boundary. Finally, I can find nothing in the dpANSI standard about alignment requirements of static data objects. I might have missed it, I've only been working with it for a couple of weeks. To say it's a bug is a little strong, maybe a desired feature??? :-) Jim Goodnow II Disclaimer: I work for Manx, so I don't gotta give none...