2
0
Эх сурвалжийг харах

cpuNbitalu is not the correct type for fpc_atomic_cmp_xchg_alu on webassembly

Michaël Van Canneyt 7 сар өмнө
parent
commit
5d100fd2c6

+ 1 - 1
compiler/fpcdefs.inc

@@ -439,7 +439,7 @@
 {$ifdef wasm32}
   {$define wasm}
   {$define cpu32bit}
-  {$define cpu32bitalu}
+  {$define cpu64bitalu}
   {$define cpu32bitaddr}
   {$define cpuhighleveltarget}
   {$define cpurox}

+ 1 - 1
compiler/ncginl.pas

@@ -632,7 +632,7 @@ implementation
 
           location_reset(location,LOC_VOID,OS_NO);
 
-{$if not defined(cpu64bitalu) and not defined(cpuhighleveltarget)}
+{$if not defined(cpu64bitalu) } // and not defined(cpuhighleveltarget)}
           if (def_cgsize(left.resultdef) in [OS_64,OS_S64]) and (left.location.loc in [LOC_REGISTER,LOC_CREGISTER,LOC_REFERENCE,LOC_CREFERENCE]) then
             cg64.a_op64_loc(current_asmdata.CurrAsmList,negnotop[inlinenumber],def_cgsize(left.resultdef),left.location)
           else

+ 14 - 7
rtl/inc/generic.inc

@@ -3532,17 +3532,24 @@ end;
 {$endif FPC_SYSTEM_HAS_ATOMIC_CMP_XCHG_64}
 
 {$if defined(FPC_SYSTEM_NEEDS_ATOMIC_FALLBACK)}
+Type
+{$IFDEF CPUWASM32}
+  TAtomicLockType = longint;
+{$ELSE}  
+  TAtomicLockType = ALUSInt;
+{$ENDIF}
 var
-  gAtomicLock: ALUSInt = 0;
 
-function fpc_atomic_cmp_xchg_alu(var Target: ALUSInt; NewValue: ALUSInt; Comparand: ALUSint): ALUSint; external name
-{$if defined(CPU8)}
+  gAtomicLock: TAtomicLockType = 0;
+
+function fpc_atomic_cmp_xchg_alu(var Target: TAtomicLockType; NewValue: TAtomicLockType; Comparand: TAtomicLockType): TAtomicLockType; external name
+{$if SIZEOF(TAtomicLockType)=1}
   'FPC_ATOMIC_CMP_XCHG_8'
-{$elseif defined(CPU16)}
+{$elseif SIZEOF(TAtomicLockType)=2}
   'FPC_ATOMIC_CMP_XCHG_16'
-{$elseif defined(CPU32)}
+{$elseif SIZEOF(TAtomicLockType)=4}
   'FPC_ATOMIC_CMP_XCHG_32'
-{$elseif defined(CPU64)}
+{$elseif SIZEOF(TAtomicLockType)=8}
   'FPC_ATOMIC_CMP_XCHG_64'
 {$else}
   'FPC_ATOMIC_CMP_XCHG_UNKNOWN'
@@ -3551,7 +3558,7 @@ function fpc_atomic_cmp_xchg_alu(var Target: ALUSInt; NewValue: ALUSInt; Compara
 
 procedure AtomicEnterLock;
 var
-  r: ALUSint;
+  r: TAtomicLockType;
 begin
   { spin until we get the lock }
   repeat