fpc/rtl/x86_64/sysutilp.inc
florian 1c896d4d4c * fixed routines for win64
git-svn-id: trunk@3354 -
2006-04-29 13:04:28 +00:00

76 lines
1.8 KiB
PHP

{
This file is part of the Free Pascal run time library.
Copyright (c) 2004 by Florian Klaempfl
member of the Free Pascal development team
See the file COPYING.FPC, included in this distribution,
for details about the copyright.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
**********************************************************************}
{ ---------------------------------------------------------------------
This include contains cpu-specific routines
---------------------------------------------------------------------}
function InterLockedDecrement (var Target: longint) : longint; assembler;
asm
{$ifdef win64}
movq %rcx,%rax
{$else win64}
movq %rdi,%rax
{$endif win64}
movl $-1,%edx
xchgq %rdx,%rax
lock
xaddl %eax, (%rdx)
decl %eax
end;
function InterLockedIncrement (var Target: longint) : longint; assembler;
asm
{$ifdef win64}
movq %rcx,%rax
{$else win64}
movq %rdi,%rax
{$endif win64}
movl $1,%edx
xchgq %rdx,%rax
lock
xaddl %eax, (%rdx)
incl %eax
end;
function InterLockedExchange (var Target: longint;Source : longint) : longint; assembler;
asm
{$ifdef win64}
xchgl (%rcx),%edx
movl %edx,%eax
{$else win64}
xchgl (%rdi),%esi
movl %esi,%eax
{$endif win64}
end;
function InterLockedExchangeAdd (var Target: longint;Source : longint) : longint; assembler;
asm
{$ifdef win64}
xchgq %rcx,%rdx
lock
xaddl %ecx, (%rdx)
movl %ecx,%eax
{$else win64}
xchgq %rdi,%rsi
lock
xaddl %edi, (%rsi)
movl %edi,%eax
{$endif win64}
end;