Hi, dear All. I have made exhaustive (at least, hope so) search in the documentation and mail list archives but found only that "GPC will align variables according to maximum performance", but how exactly? On what boundary will be aligned Integer, Boolean, Longint, Word, etc. On what boundary will be aligned string, record, array, their elements and are there any differences between default alignment of variable without record and variable as record field? And, if possible, I need information for the other platforms. I understand that I can make experiments to find it out but it seems to me it should appear in one or in other place (GPS manuals or mailing lists).
Thanx, dear All. Best regards, Ingvar mailto:marny@rambler.ru
On Wed, May 28, 2003 at 08:39:55PM +0400, Ingvar Marny wrote:
On what boundary will be aligned Integer, Boolean, Longint, Word, etc.
Well, GPC is based on GCC and GCC cares about the alignment, AFAIK. If so, gcc/varasm.c could be the right place to look into. But I'm not sure.
Eike
Eike Lange wrote:
On Wed, May 28, 2003 at 08:39:55PM +0400, Ingvar Marny wrote:
On what boundary will be aligned Integer, Boolean, Longint, Word, etc.
Well, GPC is based on GCC and GCC cares about the alignment, AFAIK. If so, gcc/varasm.c could be the right place to look into. But I'm not sure.
It will also vary with the platform. In general I would expect that allowing for 8 byte alignment (when the C bytesize is 8 bits) would function. Just because something is byte addressable does not mean that a byte address is most suitable. Such addressing may require a wider load, a shift, and a mask. Writing is more complex. Things get especially bad if an entity spreads over more than one external memory access.
At 20:39 +0400 28/5/03, Ingvar Marny wrote:
Hi, dear All. I have made exhaustive (at least, hope so) search in the documentation and mail list archives but found only that "GPC will align variables according to maximum performance", but how exactly? On what boundary will be aligned Integer, Boolean, Longint, Word, etc. On what boundary will be aligned string, record, array, their elements and are there any differences between default alignment of variable without record and variable as record field? And, if possible, I need information for the other platforms. I understand that I can make experiments to find it out but it seems to me it should appear in one or in other place (GPS manuals or mailing lists).
I do not think anyone can really give you a definitive answer on this. It depends on the platform as to what the alignment will be, not to mention whether the record is packed or not, and what the $maximum-field-alignment compiler directive is set to, and probably the version of gpc and/or gcc as well.
Typically in GPC, everything is byte aligned unless it has to not be because of the architecture. If you set $maximum-field-alignment to 16 as we do for Mac OS, then everything two bytes or bigger is aligned to two bytes.
The only way to be reasonably reliable is to use a packed record and ensure that the sum of all the sizes of items before any given entry is a multiple of the size of that entry.
GPC doesn't even guarantee what the size of Integer or LongInt or Word is a far as I know, unless you use the size attribute.
Why do you need to know this?
Enjoy, Peter.
Peter N Lewis wrote:
Typically in GPC, everything is byte aligned unless it has to not be because of the architecture.
No, generally it aligns wider if it's not required, but gains performance.
Frank