Re: [fpc-devel] Aligned dynamic arrays

2019-03-28 Thread Anthony Walter
Here is the full implementation of aligned arrays, let me know if it works for you. https://www.getlazarus.org/arrays/ Here is another example: uses AlignArrays; procedure Test; var VertexData: TAlignedArray; V: PVec3; I: Integer; begin VertexData.Length := 100; // page sized and

Re: [fpc-devel] Aligned dynamic arrays

2019-03-28 Thread J. Gareth Moreton
Just to add a minor thing... while usually you don't have to align memory any more coarsely than 16 bytes for XMM, 32 bytes for YMM and 64 bytes for ZMM, the 4 kB granularity is useful for paging, especially if you're reading or writing to a swap file.  An entire library of functions for such

Re: [fpc-devel] Aligned dynamic arrays

2019-03-28 Thread Anthony Walter
Here is a brief follow up. I am working on other projects at the moment, but I am confident this a simple solution. Please tell me if this somehow will not fit you needs. Create a new type that is compatible with Array where Array = type array of T. Define implcit conversions between the to types

Re: [fpc-devel] Aligned dynamic arrays

2019-03-28 Thread Sven Barth via fpc-devel
Am 28.03.2019 um 15:17 schrieb Ryan Joseph: Also I don't think that a simple "do alignment or not" will be sufficient. What kind of alignment do you pick? What if the user needs more alignment? So it would probably be best to add a new SetLengthAligned of which the second argument is the

Re: [fpc-devel] Aligned dynamic arrays

2019-03-28 Thread Sven Barth via fpc-devel
Am 28.03.2019 um 18:41 schrieb Ryan Joseph: Now I’m using “cd /rtl; make all FPC=/path/to/compiler” to build the RTL but this is obviously slow and unnecessary. Is there a quicker way to build just the unit which contains dynarr.inc and have all the objects files to be put in the correct

Re: [fpc-devel] Packed record integers and x86_86

2019-03-28 Thread Marco van de Voort
Op 2019-03-28 om 15:31 schreef Karoly Balogh (Charlie/SGR): (Unless it also has to compile with say, Delphi.) Everybody has {$pointermath on} is the include file included in every unit nowadays. Or at least I hope :-) ___ fpc-devel maillist -

Re: [fpc-devel] Aligned dynamic arrays

2019-03-28 Thread Anthony Walter
Ryan, this is just a thought. Do you need the flat memory address to start on an even 4 KB boundary or are you okay with the memory address starting at any DWORD address and spanning an even 4 KB after that address? In the latter case I have an easy solution for you. If the former I am unsure how

Re: [fpc-devel] Aligned dynamic arrays

2019-03-28 Thread Christo Crause
On Thu, 28 Mar 2019, 20:34 Ryan Joseph, wrote: > Now I’m using “cd /rtl; make all FPC=/path/to/compiler” to build the RTL > but this is obviously slow and unnecessary. Is there a quicker way to build > just the unit which contains dynarr.inc and have all the objects files to > be put in the

Re: [fpc-devel] Aligned dynamic arrays

2019-03-28 Thread Ryan Joseph
Now I’m using “cd /rtl; make all FPC=/path/to/compiler” to build the RTL but this is obviously slow and unnecessary. Is there a quicker way to build just the unit which contains dynarr.inc and have all the objects files to be put in the correct location? Regards, Ryan Joseph

Re: [fpc-devel] Packed record integers and x86_86

2019-03-28 Thread J. Gareth Moreton
Heh, much better - thank you! On Thu 28/03/19 14:31 , "Karoly Balogh (Charlie/SGR)" char...@scenergy.dfmk.hu sent: Hi, On Thu, 28 Mar 2019, J. Gareth Moreton wrote: > I think the official unsigned 32-bit integer type in Pascal is > "LongWord". As others have said, be aware that

Re: [fpc-devel] Packed record integers and x86_86

2019-03-28 Thread Karoly Balogh (Charlie/SGR)
Hi, On Thu, 28 Mar 2019, J. Gareth Moreton wrote: > I think the official unsigned 32-bit integer type in Pascal is > "LongWord". As others have said, be aware that pointers are 64-bit under > x64... that's kind of why it's called x64!  If you absolutely must have > a packed record with 32-bit

Re: [fpc-devel] Aligned dynamic arrays

2019-03-28 Thread Ryan Joseph
> On Mar 28, 2019, at 4:17 AM, Sven Barth via fpc-devel > wrote: > > The order should be > > [padding] [header] [data] > > with the offset being part of the header. This way you reduce the changes > needed to only those that allocate/free an array. Yeah that’s probably the better idea

Re: [fpc-devel] Aligned dynamic arrays

2019-03-28 Thread Sven Barth via fpc-devel
Ryan Joseph schrieb am Do., 28. März 2019, 03:01: > Here’s the basic structure: > > [header][padding][offset][head] > > [head] being the start of the elements (the pointer to the first element > of the array) and aligned to the requested amount. Keep in mind the head is > the pointer which is