Browse Source

+ InterlockedCompareExchange128, Linux implementation.

git-svn-id: trunk@17140 -
sergei 14 years ago
parent
commit
7fc2d86bb2
1 changed files with 24 additions and 0 deletions
  1. 24 0
      rtl/x86_64/cpu.pp

+ 24 - 0
rtl/x86_64/cpu.pp

@@ -50,6 +50,7 @@ unit cpu;
           r8  ... NewValue
           r9  ... Comperand
       }
+    {$ifdef win64}
       asm
         pushq %rbx
 
@@ -81,7 +82,30 @@ unit cpu;
 
         popq %rbx
       end;
+    {$else win64}
+    {
+      linux:
+        rdi       ... target
+        [rsi:rdx] ... NewValue
+        [rcx:r8]  ... Comperand
+        [rdx:rax] ... result
+    }
+      asm
+        pushq %rbx
+
+        movq %rsi,%rbx          // new value low
+        movq %rcx,%rax          // comperand low
+        movq %rdx,%rcx          // new value high
+        movq %r8,%rdx           // comperand high
+        {$ifdef oldbinutils}
+        .byte 0xF0,0x48,0x0F,0xC7,0x0F
+        {$else}
+        lock cmpxchg16b (%rdi)
+        {$endif}
 
+        popq %rbx
+      end;
+    {$endif win64}
 
     procedure SetupSupport;
       var