Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2010-11

InterLockedExchange vs InterLockedExchange64 using pointers on cpu64

4 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Andrew Brunner

On a 64bit fpc compile, and 64bit system with pointers, which interlocked exchange is best used? Aren't pointers on x64 64bit pointers? Shouldn't we be using InterlockedExhange64 code to access specific x64 swaps?

Thanks.

Reply by email

Michael Schnell
to Andrew Brunner
Andrew Brunner wrote
On a 64bit fpc compile, and 64bit system with pointers, which interlocked exchange is best used? Aren't pointers on x64 64bit pointers? Shouldn't we be using InterlockedExhange64 code to access specific x64 swaps?

Obviously a specific InterlockedExhangePtr() function would be appropriate.

-Michael

Reply by email

Jeppe Johansen
to Andrew Brunner: On a 64bit fpc compile, and 64bit system with pointers, which interlocked exchange is…
Andrew Brunner wrote 9 lines
On a 64bit fpc compile, and 64bit system with pointers, which interlocked exchange is best used? Aren't pointers on x64 64bit pointers? Shouldn't we be using InterlockedExhange64 code to access specific x64 swaps? Thanks. _______________________________________________ fpc-devel maillist - http://lists.freepascal.org/mailman/listinfo/fpc-devel
function InterLockedExchange (var Target: Pointer;Source : Pointer) :
Pointer;

always maps directly to InterLockedExchange64 on 64bit and InterLockedExchange on 32bit. See line 988 and 994 in systemh.inc

So you're fine using InterlockedExchange on pointers. The other version with longint is always 32bit no matter the platform

Reply by email

Jonas Maebe
Andrew Brunner wrote
On a 64bit fpc compile, and 64bit system with pointers, which interlocked exchange is best used?

The one that matches the size of the data you are changing. The compiler will give an error if you try to use the wrong one.

Aren't pointers on x64 64bit pointers?

Yes.

Shouldn't we be using InterlockedExhange64 code to access specific x64 swaps?

If you mean "to swap pointers" with "specific x64 swaps", then no, that is not necessary. The overloaded pointer variant is automatically mapped to either the longint or int64 version depending on the target platform.

Jonas

Reply by email