[fpc-pascal] Memory alignment with FPC

Jonas Maebe jonas.maebe at elis.ugent.be
Thu Oct 11 15:33:24 CEST 2012


On 11 Oct 2012, at 15:23, dhkblaszyk at zeelandnet.nl wrote:

> Thanks, I think everything is clear now. My plan now is to
> respect default padding and write records in one go to disk. The  
> padding
> value will be written to the file header so the records can be read  
> back
> one variable at a time when padding differs, otherwise they will be  
> read
> back in one go again. This will sure come at a cost, but only if the
> file is shared between different ABI's (as is the case when sharing
> between different endianess). The result will be that the data
> structures will be at default padding internally allways making  
> optimal
> use of the CPU.
>
> So is there a way to get the padding value at runtime?

No. You really should write the fields one by one. Yes, it's slower.  
That's the cost of portability. You can always optimize by first  
writing them to a buffer and then writing the buffer in one go.


Jonas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20121011/0421117a/attachment.html>


More information about the fpc-pascal mailing list