Browse Source

Merged revisions 6798-6799 via svnmerge from
http://svn.freepascal.org/svn/fpc/trunk

r6798 (florian)
* fixed InterlockedCompareExchange(64) of x86_64.inc for win64 too


r6799 (florian)
* pretty basic InterlockedCompareExchange test

git-svn-id: branches/fixes_2_2@6800 -

florian 18 years ago
parent
commit
5a3b639e55
3 changed files with 15 additions and 4 deletions
  1. 1 0
      .gitattributes
  2. 4 4
      rtl/x86_64/x86_64.inc
  3. 10 0
      tests/test/units/system/interlocked1.pp

+ 1 - 0
.gitattributes

@@ -6897,6 +6897,7 @@ tests/test/units/sharemem/test1.pp svneol=native#text/plain
 tests/test/units/softfpu/sfttst.pp svneol=native#text/plain
 tests/test/units/strings/tstrcopy.pp svneol=native#text/plain
 tests/test/units/strings/tstrings1.pp svneol=native#text/plain
+tests/test/units/system/interlocked1.pp svneol=native#text/plain
 tests/test/units/system/tabs.pp svneol=native#text/plain
 tests/test/units/system/targs.pp svneol=native#text/plain
 tests/test/units/system/tassert1.pp svneol=native#text/plain

+ 4 - 4
rtl/x86_64/x86_64.inc

@@ -482,9 +482,9 @@ end;
 function InterLockedCompareExchange(var Target: longint; NewValue, Comperand : longint): longint; assembler;
 asm
 {$ifdef win64}
-        movl            %edx,%eax
+        movl            %r8d,%eax
         lock
-        cmpxchgl        %r8d,(%rcx)
+        cmpxchgl        %edx,(%rcx)
 {$else win64}
         movl            %edx,%eax
         lock
@@ -554,9 +554,9 @@ end;
 function InterLockedCompareExchange64(var Target: int64; NewValue, Comperand : int64): int64; assembler;
 asm
 {$ifdef win64}
-        movq            %rdx,%rax
+        movq            %r8,%rax
         lock
-        cmpxchgq        %r8d,(%rcx)
+        cmpxchgq        %rdx,(%rcx)
 {$else win64}
         movq            %rdx,%rax
         lock

+ 10 - 0
tests/test/units/system/interlocked1.pp

@@ -0,0 +1,10 @@
+var
+  target : longint;
+
+begin
+  target:=1234;
+  InterLockedCompareExchange(target,4321,1234);
+  if target<>4321 then
+    halt(1);
+  writeln('ok');
+end.