Browse Source

* Fix compilation, probably also bug with mem size

Michaël Van Canneyt 3 months ago
parent
commit
d520f1df0b
1 changed files with 12 additions and 4 deletions
  1. 12 4
      rtl/wasm32/wasmmem.inc

+ 12 - 4
rtl/wasm32/wasmmem.inc

@@ -69,17 +69,23 @@ Var
   // Root block of linked list of TOSMemInfoBlock
   // Root block of linked list of TOSMemInfoBlock
   TLSInfoBlock : POSMemInfoBlock = nil;
   TLSInfoBlock : POSMemInfoBlock = nil;
 
 
+Function GetSingleTLSMemblockSize : PTrUint;
+
+begin
+  Result:=Align(fpc_wasm32_tls_size+SizeOf(Pointer),fpc_wasm32_tls_align);
+end;
+
 Function TLSMemblockSize : PTrUint;
 Function TLSMemblockSize : PTrUint;
 
 
 // Calculate the size of a TLS memory block.
 // Calculate the size of a TLS memory block.
 // This is the TLS size + Size of a pointer (cannot use TTLSMem for this)
 // This is the TLS size + Size of a pointer (cannot use TTLSMem for this)
 
 
 Var
 Var
-  BlockSize : PTrUint;
+  lBlockSize : PTrUint;
 
 
 begin
 begin
-  BlockSize:=Align(fpc_wasm32_tls_size+SizeOf(Pointer),fpc_wasm32_tls_align);
-  TLSMemblockSize:=BlockSize*MemBlockCount;
+  lBlockSize:=GetSingleTLSMemblockSize;
+  TLSMemblockSize:=lBlockSize*MemBlockCount;
 end;
 end;
 
 
 Function AllocateOSInfoBlock : POSMemInfoBlock;
 Function AllocateOSInfoBlock : POSMemInfoBlock;
@@ -89,6 +95,7 @@ Var
   POMB : POSMemBlock;
   POMB : POSMemBlock;
   POSBlock,POSMem : PTLSMem;
   POSBlock,POSMem : PTLSMem;
   I : Integer;
   I : Integer;
+  lBlockSize : PTrUint;
 
 
 begin
 begin
   // allocate block
   // allocate block
@@ -105,13 +112,14 @@ begin
   POSBlock:=PTLSMem(SysOSAlloc(TLSMemblockSize));
   POSBlock:=PTLSMem(SysOSAlloc(TLSMemblockSize));
   if POSBlock=Nil then
   if POSBlock=Nil then
     Halt(203);
     Halt(203);
+  lBlockSize:=GetSingleTLSMemblockSize;  
   POSMem:=POSBlock;
   POSMem:=POSBlock;
   For I:=0 to MemBlockCount-1 do
   For I:=0 to MemBlockCount-1 do
     begin
     begin
     PMIB^.Blocks[I].Data:=POSMem;
     PMIB^.Blocks[I].Data:=POSMem;
     POMB:=@(PMIB^.Blocks[I]);
     POMB:=@(PMIB^.Blocks[I]);
     PosMem^.OSMemBlock:=POMB;
     PosMem^.OSMemBlock:=POMB;
-    Inc(Pointer(POSMem),BlockSize);
+    Inc(Pointer(POSMem),lBlockSize);
     end;
     end;
   AllocateOSInfoBlock:=PMIB;
   AllocateOSInfoBlock:=PMIB;
 end;
 end;