[fpc-pascal] Cache-line alignment for records

Matias Ezequiel Vara Larsen matiasevara at gmail.com
Wed Mar 29 11:26:04 CEST 2023


On Wed, Mar 29, 2023 at 08:33:58AM +0200, Sven Barth via fpc-pascal wrote:
> Matias Ezequiel Vara Larsen via fpc-pascal <fpc-pascal at lists.freepascal.org>
> schrieb am Mi., 29. März 2023, 00:27:
> 
> > Hello,
> >
> > On Mon, Mar 27, 2023 at 09:35:38PM +0200, Jonas Maebe via fpc-pascal wrote:
> > > On 27/03/2023 21:25, denisgolovan via fpc-pascal wrote:
> > >
> > > > But it's still not possible to attach alignment to type itself instead
> > of variable, right?
> > >
> > > It is possible (
> > https://gitlab.com/freepascal.org/fpc/source/-/blob/main/tests/test/talignrec1.pp
> > ),
> > > but it is subject to the same limitations when declaring variables of
> > those
> > > types.
> > >
> >
> > Thanks, this is what I was looking for, however, when the type is
> > defined as an array, only the [0] element is aligned. I was expecting
> > that each element in the array would be aligned.
> >
> 
> No, array types are defined as never having padding between the elements.
> You need to make sure that the element is appropriately sized then.
> 
Thanks for the comment. I will pad those records used for per-cpu
variables so they fit in different cache-lines when defined as an array.

Matias


More information about the fpc-pascal mailing list