Browse Source

+ add intrinsic for 8-bit atomic cmpxchg for wasm32 (this way the fallback for cmxchg is no longer used for wasm32)

Sven/Sarah Barth 7 months ago
parent
commit
40725146cc
1 changed files with 14 additions and 0 deletions
  1. 14 0
      rtl/wasm32/wasm32.inc

+ 14 - 0
rtl/wasm32/wasm32.inc

@@ -258,3 +258,17 @@ function fpc_atomic_add_16 (var Target: smallint;Value : smallint) : smallint;
     inc(Target,{$ifdef VER3_2}Source{$else}Value{$endif});
     inc(Target,{$ifdef VER3_2}Source{$else}Value{$endif});
 {$endif FPC_WASM_THREADS}
 {$endif FPC_WASM_THREADS}
   end;
   end;
+
+{$ifndef VER3_2}
+{$define FPC_SYSTEM_HAS_ATOMIC_CMP_XCHG_8}
+function fpc_atomic_cmp_xchg_8 (var Target : shortint; NewValue : shortint; Comparand : shortint) : shortint;
+  begin
+{$ifdef FPC_WASM_THREADS}
+    Result:=ShortInt(fpc_wasm32_i32_atomic_rmw8_cmpxchg_u(@Target, Byte(Comparand), Byte(NewValue)));
+{$else FPC_WASM_THREADS}
+    Result:=Target;
+    if Target=Comparand then
+      Target:=NewValue;
+{$endif FPC_WASM_THREADS}
+  end;
+{$endif VER3_2}