Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.programming.threads > #4270
| Path | csiph.com!eternal-september.org!feeder.eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Sky89 <Sky89@sky68.com> |
| Newsgroups | comp.programming.threads |
| Subject | Re: Here is a Delphi and FreePascal unit |
| Date | Tue, 15 May 2018 17:38:30 -0400 |
| Organization | A noiseless patient Spider |
| Lines | 108 |
| Message-ID | <pdf5un$c8t$4@dont-email.me> (permalink) |
| References | <pdf3su$v8p$2@dont-email.me> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8; format=flowed |
| Content-Transfer-Encoding | 8bit |
| Injection-Date | Tue, 15 May 2018 17:38:31 -0000 (UTC) |
| Injection-Info | reader02.eternal-september.org; posting-host="67f3dcb82f068d4b1151df13202e7f04"; logging-data="12573"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/MVWgy+FBn0Y3VieP+vfgW" |
| User-Agent | Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 |
| Cancel-Lock | sha1:n4tk+jnFgafVU9TXY/S9JwrnvRU= |
| In-Reply-To | <pdf3su$v8p$2@dont-email.me> |
| Content-Language | en-US |
| Xref | csiph.com comp.programming.threads:4270 |
Show key headers only | View raw
On 5/15/2018 5:03 PM, Sky89 wrote:
> Hello..
>
>
> Here is a Delphi and FreePascal unit that i have just wrote that permits
I correct: we write in english: "that i have just written"
> to allocated an aligned memory, i have tested it and it works great, it
> is well suited for parallel programming:
>
>
> Here is first the define.inc file:
>
> ==
>
> {$DEFINE CPU64}
>
> ==
>
>
> And here is the Delphi and FreePascal unit:
>
> ===
>
> unit Getmem_aligned1;
>
>
> {$I defines.inc}
>
> interface
>
> type
>
> typecache1 = array[0..15] of longword;
>
> {$IFDEF CPU64}
> long = uint64;
> int = int64;
> {$ENDIF CPU64}
> {$IFDEF CPU32}
> long = longword;
> int = integer;
> {$ENDIF CPU32}
>
>
> type IntPtr=^Int;
>
> procedure getmem_aligned(alignment:cardinal;var ptr:pointer;size:cardinal);
> procedure freemem_aligned(ptr:pointer);
>
>
> implementation
>
>
> procedure getmem_aligned(alignment:cardinal;var ptr:pointer;size:cardinal);
>
> var ptr1,ptr2,ptr3:pointer;
>
> begin
>
> ptr := AllocMem(size + (2*alignment) + sizeof(pointer));
>
> ptr1:=pointer(int(ptr)+sizeof(pointer));
>
> ptr2 := Pointer((int(ptr1) + Alignment - 1) and not (Alignment - 1));
>
> ptr3:=pointer(int(ptr2)-sizeof(pointer));
>
> intptr(ptr3)^:=int(ptr);
>
> ptr:=ptr2;
>
>
> end;
>
>
> procedure freemem_aligned(ptr:pointer);
>
> var ptr1,ptr2:pointer;
>
> begin
>
> ptr1:=pointer(int(ptr)-sizeof(pointer));
>
> int(ptr2):=intptr(ptr1)^;
>
> freemem(ptr2);
>
> end;
>
>
> end.
>
> ==
>
>
>
>
> Thank you,
> Amine Moulay Ramdane.
>
>
>
>
Back to comp.programming.threads | Previous | Next — Previous in thread | Find similar | Unroll thread
Here is a Delphi and FreePascal unit Sky89 <Sky89@sky68.com> - 2018-05-15 17:03 -0400 Re: Here is a Delphi and FreePascal unit Sky89 <Sky89@sky68.com> - 2018-05-15 17:38 -0400
csiph-web