[fpc-pascal] Cache-line alignment for records
Ched
charles.edouard.des.vastes.vignes at gmail.com
Wed Mar 29 23:38:58 CEST 2023
Hello,
Ok for the records for internal calculations. But sometimes, records are used for reading/writing
structured files. Does "packed" in "packed array" and "packed record" always forbid the compiler to play
with alignments ?
Kindest regards, Ched'
Le 29.03.23 à 21:07, Jonas Maebe via fpc-pascal a écrit :
> On 29/03/2023 16:00, Matias Ezequiel Vara Larsen via fpc-pascal wrote:
>> So if I have a type like:
>>
>> test = record
>> r: DWord;
>> s: Word;
>> end;
>>
>> Then, I define the variable `nada` as an array of `test` type:
>>
>> var
>> nada: array[0..2] of test;
>>
>> Is the `@nada[1].r` element aligned to 4-bytes?
>
> Records always get padded to a multiple of their internal alignment requirement. Unless you're on a
> system where the default packrecords value is 2 (msdos-i8086 has that probably), the above record's
> internal field alignment is 4 and hence its size will also be padded to a multiple of 4.
>
>
> Jonas
More information about the fpc-pascal
mailing list