Browse Source

* fixed tinterlockedmt*.pp for architectures with weak memory consistency
models

git-svn-id: trunk@41164 -

Jonas Maebe 6 years ago
parent
commit
56fd8e1208
2 changed files with 13 additions and 0 deletions
  1. 6 0
      tests/test/tinterlocked64mt.pp
  2. 7 0
      tests/test/tinterlockedmt.pp

+ 6 - 0
tests/test/tinterlocked64mt.pp

@@ -208,6 +208,8 @@ begin
       end;
       end;
   end;
   end;
 
 
+  { ensure the writes to Counter and Counter2 are ordered vs the writes to FinishedCount }
+  WriteBarrier;
   InterLockedIncrement64(FinishedCount);
   InterLockedIncrement64(FinishedCount);
 end;
 end;
 
 
@@ -293,6 +295,10 @@ begin
   if t = 0 then
   if t = 0 then
     t:=1/MSecsPerDay;
     t:=1/MSecsPerDay;
 
 
+  { ensure the read from FinishedCount above is ordered relative to the reads from
+    Counter and Counter2 (counterpart to WriteBarrier in the thread function) }
+  ReadBarrier();
+
   CheckResult(Counter, 0, 20, 'Counter error:');
   CheckResult(Counter, 0, 20, 'Counter error:');
 
 
   CheckResult(Counter2, (LastCompareVal - 2)*CmpCount, 21, 'Counter2 error:');
   CheckResult(Counter2, (LastCompareVal - 2)*CmpCount, 21, 'Counter2 error:');

+ 7 - 0
tests/test/tinterlockedmt.pp

@@ -204,6 +204,9 @@ begin
       end;
       end;
   end;
   end;
 
 
+  { ensure the writes to Counter and Counter2 are ordered vs the writes to FinishedCount }
+  WriteBarrier;
+
   InterLockedIncrement(FinishedCount);
   InterLockedIncrement(FinishedCount);
 end;
 end;
 
 
@@ -288,6 +291,10 @@ begin
   if t = 0 then
   if t = 0 then
     t:=1/MSecsPerDay;
     t:=1/MSecsPerDay;
 
 
+  { ensure the read from FinishedCount above is ordered relative to the reads from
+    Counter and Counter2 (counterpart to WriteBarrier in the thread function) }
+  ReadBarrier();
+
   CheckResult(Counter, 0, 20, 'Counter error:');
   CheckResult(Counter, 0, 20, 'Counter error:');
 
 
   CheckResult(Counter2, (LastCompareVal - 2)*CmpCount, 21, 'Counter2 error:');
   CheckResult(Counter2, (LastCompareVal - 2)*CmpCount, 21, 'Counter2 error:');