* Fix compilation, probably also bug with mem size

This commit is contained in:
Michaël Van Canneyt 2025-04-21 11:23:17 +02:00
parent 71bd5f56ef
commit d520f1df0b

View File

@ -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); lBlockSize:=GetSingleTLSMemblockSize;
TLSMemblockSize:=BlockSize*MemBlockCount; 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;