瀏覽代碼

Use newish atomics.

Rika Ichinose 2 周之前
父節點
當前提交
354b335b06
共有 1 個文件被更改,包括 3 次插入3 次删除
  1. 3 3
      rtl/inc/heap.inc

+ 3 - 3
rtl/inc/heap.inc

@@ -1603,14 +1603,14 @@ type
       next := toFree;
       next := toFree;
       p^.next := next;
       p^.next := next;
       WriteBarrier; { Write p after p^.next. }
       WriteBarrier; { Write p after p^.next. }
-    until InterlockedCompareExchange(toFree, p, next) = next;
+    until {$ifdef VER3_2} InterlockedCompareExchange {$else} AtomicCmpExchange {$endif} (toFree, p, next) = next;
   end;
   end;
 
 
   procedure HeapInc.ThreadState.FlushToFree;
   procedure HeapInc.ThreadState.FlushToFree;
   var
   var
     tf, nx: pFreeChunk;
     tf, nx: pFreeChunk;
   begin
   begin
-    tf := InterlockedExchange(toFree, nil);
+    tf := {$ifdef VER3_2} InterlockedExchange {$else} AtomicExchange {$endif} (toFree, nil);
     while Assigned(tf) do
     while Assigned(tf) do
     begin
     begin
       ReadDependencyBarrier; { Read toFree^.next after toFree. }
       ReadDependencyBarrier; { Read toFree^.next after toFree. }
@@ -1966,7 +1966,7 @@ begin
     exit;
     exit;
 {$if defined(FPC_HAS_FEATURE_THREADING)}
 {$if defined(FPC_HAS_FEATURE_THREADING)}
   HeapInc.thisTs.Orphan;
   HeapInc.thisTs.Orphan;
-  if (HeapInc.gs.lockUse > 0) and (InterlockedDecrement(HeapInc.gs.lockUse) = 0) then
+  if (HeapInc.gs.lockUse > 0) and ({$ifdef VER3_2} InterlockedDecrement {$else} AtomicDecrement {$endif} (HeapInc.gs.lockUse) = 0) then
     DoneCriticalSection(HeapInc.gs.lock);
     DoneCriticalSection(HeapInc.gs.lock);
 {$elseif defined(HAS_SYSOSFREE)}
 {$elseif defined(HAS_SYSOSFREE)}
   if Assigned(HeapInc.thisTs.freeOS1) then
   if Assigned(HeapInc.thisTs.freeOS1) then