[fpc-devel] Where to set proper alignment default of const strings?

Sven Barth pascaldragon at googlemail.com
Wed Nov 28 20:45:14 CET 2018


Am 28.11.2018 um 19:51 schrieb Michael Ring:
>
> The more I dig the more I ask myself if not the rtl routine is to 
> blame for the issue in the first place because it only takes alignment 
> of the destination into account when doing it's job.
>
> Aligncount is calculated base on destination (which is RAM), for this 
> reason the last line always crashes because psrc can be unaligned.
>
> I most likely completely misunderstand the meaning of 
> FPC_REQUIRES_PROPER_ALIGNMENT but usually ram can be written byte 
> aligned but flash has often limitations on read access so alignment 
> should look for psrc as this can come from flash.
>
> Unless of course FPC_REQUIRES_PROPER_ALIGNMENT isĀ  primarily meant for 
> speed improovement only, then it would make sense to look at pdest to 
> try to optimize write performance by having as much aligned access as 
> possible.I only found an old discussion in lazarus list from 2011 on 
> this topic, where it looks like structs were manually aligned in 
> lazarus, but I did not look too deep into the patches.
>
The purpose of the FPC_REQUIRES_PROPER_ALIGNMENT is mainly for compiler 
generated data structures like the RTTI which uses packed records on 
targets where the define is not set (e.g. x86).

Regards,
Sven



More information about the fpc-devel mailing list