[fpc-pascal] Memory alignment with FPC

dhkblaszyk at zeelandnet.nl dhkblaszyk at zeelandnet.nl
Thu Oct 11 16:11:38 CEST 2012


On 11 okt '12, Jonas Maebe wrote: 

> On 11 Oct 2012, at 15:23,
dhkblaszyk at zeelandnet.nl [1] 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
> 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. 

Sorry I keep asking questions, but why write them one by one? If
I would store the offset each variable has at the time of writing (only
need to do one time per record type), I could easily make the loading
work (even if the ABI changes when the file is read back). What makes
you prefer writing the variables one by one over once at a time?



[1] mailto:dhkblaszyk at zeelandnet.nl
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20121011/2d838df2/attachment.html>

More information about the fpc-pascal mailing list