123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243 |
- {
- This file is part of the Free Pascal run time library.
- Copyright (c) 2022 by Nikolay Nikolov,
- member of the Free Pascal development team.
- WASI threading support implementation
- See the file COPYING.FPC, included in this distribution,
- for details about the copyright.
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- **********************************************************************}
- {$ifndef FPC_WASM_THREADS}
- {$fatal This file shouldn't be included if thread support is disabled!}
- {$endif FPC_WASM_THREADS}
- var
- WasiThreadManager : TThreadManager;
- function WasiInitManager: Boolean;
- begin
- Result:=True;
- end;
- function WasiDoneManager: Boolean;
- begin
- Result:=True;
- end;
- function WasiBeginThread(sa : Pointer;stacksize : PtrUInt; ThreadFunction : tthreadfunc;p : pointer;creationFlags : dword; var ThreadId : TThreadID) : TThreadID;
- begin
- {todo:implement}
- end;
- procedure WasiEndThread(ExitCode : DWord);
- begin
- {todo:implement}
- end;
- function WasiSuspendThread(threadHandle : TThreadID) : dword;
- begin
- {todo:implement}
- end;
- function WasiResumeThread(threadHandle : TThreadID) : dword;
- begin
- {todo:implement}
- end;
- function WasiKillThread(threadHandle : TThreadID) : dword;
- begin
- {todo:implement}
- end;
- function WasiCloseThread(threadHandle : TThreadID) : dword;
- begin
- {todo:implement}
- end;
- procedure WasiThreadSwitch;
- begin
- {todo:implement}
- end;
- function WasiWaitForThreadTerminate(threadHandle : TThreadID; TimeoutMs : longint) : dword;
- begin
- {todo:implement}
- end;
- function WasiThreadSetPriority(threadHandle : TThreadID; Prio: longint): boolean;
- begin
- {todo:implement}
- end;
- function WasiThreadGetPriority(threadHandle : TThreadID): longint;
- begin
- {todo:implement}
- end;
- function WasiGetCurrentThreadId : TThreadID;
- begin
- {todo:implement}
- end;
- procedure WasiThreadSetThreadDebugNameA(threadHandle: TThreadID; const ThreadName: AnsiString);
- begin
- {todo:implement}
- end;
- {$ifdef FPC_HAS_FEATURE_UNICODESTRINGS}
- procedure WasiThreadSetThreadDebugNameU(threadHandle: TThreadID; const ThreadName: UnicodeString);
- begin
- {todo:implement}
- end;
- {$endif FPC_HAS_FEATURE_UNICODESTRINGS}
- procedure WasiInitCriticalSection(var cs);
- begin
- {todo:implement}
- end;
- procedure WasiDoneCriticalSection(var cs);
- begin
- {todo:implement}
- end;
- procedure WasiEnterCriticalSection(var cs);
- begin
- {todo:implement}
- end;
- function WasiCriticalSectionTryEnter(var cs):longint;
- begin
- {todo:implement}
- end;
- procedure WasiLeaveCriticalSection(var cs);
- begin
- {todo:implement}
- end;
- procedure WasiInitThreadVar(var offset : dword;size : dword);
- begin
- {todo:implement}
- end;
- function WasiRelocateThreadVar(offset : dword) : pointer;
- begin
- {todo:implement}
- end;
- procedure WasiAllocateThreadVars;
- begin
- {todo:implement}
- end;
- procedure WasiReleaseThreadVars;
- begin
- {todo:implement}
- end;
- function WasiBasicEventCreate(EventAttributes :Pointer; AManualReset,InitialState : Boolean;const Name:ansistring):pEventState;
- begin
- {todo:implement}
- end;
- procedure WasiBasicEventDestroy(state:peventstate);
- begin
- {todo:implement}
- end;
- procedure WasiBasicEventResetEvent(state:peventstate);
- begin
- {todo:implement}
- end;
- procedure WasiBasicEventSetEvent(state:peventstate);
- begin
- {todo:implement}
- end;
- function WasiBasicEventWaitFor(timeout:cardinal;state:peventstate;FUseComWait : Boolean=False):longint;
- begin
- {todo:implement}
- end;
- function WasiRTLCreateEvent:PRTLEvent;
- begin
- {todo:implement}
- end;
- procedure WasiRTLEventDestroy(AEvent:PRTLEvent);
- begin
- {todo:implement}
- end;
- procedure WasiRTLEventSetEvent(AEvent:PRTLEvent);
- begin
- {todo:implement}
- end;
- procedure WasiRTLEventResetEvent(AEvent:PRTLEvent);
- begin
- {todo:implement}
- end;
- procedure WasiRTLEventWaitFor(AEvent:PRTLEvent);
- begin
- {todo:implement}
- end;
- procedure WasiRTLEventWaitForTimeout(AEvent:PRTLEvent;timeout : longint);
- begin
- {todo:implement}
- end;
- procedure InitSystemThreads;public name '_FPC_InitSystemThreads';
- begin
- with WasiThreadManager do
- begin
- InitManager := @WasiInitManager;
- DoneManager := @WasiDoneManager;
- BeginThread := @WasiBeginThread;
- EndThread := @WasiEndThread;
- SuspendThread := @WasiSuspendThread;
- ResumeThread := @WasiResumeThread;
- KillThread := @WasiKillThread;
- CloseThread := @WasiCloseThread;
- ThreadSwitch := @WasiThreadSwitch;
- WaitForThreadTerminate := @WasiWaitForThreadTerminate;
- ThreadSetPriority := @WasiThreadSetPriority;
- ThreadGetPriority := @WasiThreadGetPriority;
- GetCurrentThreadId := @WasiGetCurrentThreadId;
- SetThreadDebugNameA := @WasiThreadSetThreadDebugNameA;
- {$ifdef FPC_HAS_FEATURE_UNICODESTRINGS}
- SetThreadDebugNameU := @WasiThreadSetThreadDebugNameU;
- {$endif FPC_HAS_FEATURE_UNICODESTRINGS}
- InitCriticalSection := @WasiInitCriticalSection;
- DoneCriticalSection := @WasiDoneCriticalSection;
- EnterCriticalSection := @WasiEnterCriticalSection;
- TryEnterCriticalSection:= @WasiCriticalSectionTryEnter;
- LeaveCriticalSection := @WasiLeaveCriticalSection;
- InitThreadVar := @WasiInitThreadVar;
- RelocateThreadVar := @WasiRelocateThreadVar;
- AllocateThreadVars := @WasiAllocateThreadVars;
- ReleaseThreadVars := @WasiReleaseThreadVars;
- BasicEventCreate := @WasiBasicEventCreate;
- BasicEventDestroy := @WasiBasicEventDestroy;
- BasicEventResetEvent := @WasiBasicEventResetEvent;
- BasicEventSetEvent := @WasiBasicEventSetEvent;
- BasiceventWaitFOr := @WasiBasicEventWaitFor;
- RTLEventCreate := @WasiRTLCreateEvent;
- RTLEventDestroy := @WasiRTLEventDestroy;
- RTLEventSetEvent := @WasiRTLEventSetEvent;
- RTLEventResetEvent := @WasiRTLEventResetEvent;
- RTLEventWaitFor := @WasiRTLEventWaitFor;
- RTLEventWaitForTimeout := @WasiRTLEventWaitForTimeout;
- end;
- SetThreadManager(WasiThreadManager);
- end;
|