diff --git a/rtl/wasicommon/systhrd.inc b/rtl/wasicommon/systhrd.inc index b969a0e25f..946ad943e5 100644 --- a/rtl/wasicommon/systhrd.inc +++ b/rtl/wasicommon/systhrd.inc @@ -399,12 +399,14 @@ procedure WasiAllocateThreadVars; forward; {$push}{$S-} // no stack checking for this procedure procedure FPCWasmThreadStartPascal(tid: longint; start_arg: PWasmThread); begin - {$IFDEF DEBUGWASMTHREADS}DebugWriteln('FPCWasmThreadStartPascal(...)');{$ENDIF} + {$IFDEF DEBUGWASMTHREADS}DebugWriteln('FPCWasmThreadStartPascal('+IntToStr(tid)+','+IntToStr(ptrint(start_arg))+')');{$ENDIF} start_arg^.ID:=tid; - GlobalCurrentThread:=@start_arg; + GlobalCurrentThread:=start_arg; GlobalIsMainThread:=0; GlobalIsWorkerThread:=1; + {$IFDEF DEBUGWASMTHREADS}DebugWriteln('Check : TID='+IntToStr(tid)+', start_arg_id='+IntToStr(start_arg^.ID)+', currentthread= '+IntTostr(ptrint(GetCurrentThreadID))+')');{$ENDIF} + {$IFDEF FPC_WASM_WORKER_THREADS_CAN_WAIT} GlobalIsThreadBlockable:=1; {$ELSE FPC_WASM_WORKER_THREADS_CAN_WAIT} @@ -610,6 +612,7 @@ begin Result:=0; end; + function WasiGetCurrentThreadId : TThreadID; begin Result:=GetSelfThread;