systhrd.inc 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2022 by Nikolay Nikolov,
  4. member of the Free Pascal development team.
  5. WASI threading support implementation
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. {$ifndef FPC_WASM_THREADS}
  13. {$fatal This file shouldn't be included if thread support is disabled!}
  14. {$endif FPC_WASM_THREADS}
  15. var
  16. WasiThreadManager : TThreadManager;
  17. function WasiInitManager: Boolean;
  18. begin
  19. Result:=True;
  20. end;
  21. function WasiDoneManager: Boolean;
  22. begin
  23. Result:=True;
  24. end;
  25. function WasiBeginThread(sa : Pointer;stacksize : PtrUInt; ThreadFunction : tthreadfunc;p : pointer;creationFlags : dword; var ThreadId : TThreadID) : TThreadID;
  26. begin
  27. {todo:implement}
  28. end;
  29. procedure WasiEndThread(ExitCode : DWord);
  30. begin
  31. {todo:implement}
  32. end;
  33. function WasiSuspendThread(threadHandle : TThreadID) : dword;
  34. begin
  35. {todo:implement}
  36. end;
  37. function WasiResumeThread(threadHandle : TThreadID) : dword;
  38. begin
  39. {todo:implement}
  40. end;
  41. function WasiKillThread(threadHandle : TThreadID) : dword;
  42. begin
  43. {todo:implement}
  44. end;
  45. function WasiCloseThread(threadHandle : TThreadID) : dword;
  46. begin
  47. {todo:implement}
  48. end;
  49. procedure WasiThreadSwitch;
  50. begin
  51. {todo:implement}
  52. end;
  53. function WasiWaitForThreadTerminate(threadHandle : TThreadID; TimeoutMs : longint) : dword;
  54. begin
  55. {todo:implement}
  56. end;
  57. function WasiThreadSetPriority(threadHandle : TThreadID; Prio: longint): boolean;
  58. begin
  59. {todo:implement}
  60. end;
  61. function WasiThreadGetPriority(threadHandle : TThreadID): longint;
  62. begin
  63. {todo:implement}
  64. end;
  65. function WasiGetCurrentThreadId : TThreadID;
  66. begin
  67. {todo:implement}
  68. end;
  69. procedure WasiThreadSetThreadDebugNameA(threadHandle: TThreadID; const ThreadName: AnsiString);
  70. begin
  71. {todo:implement}
  72. end;
  73. {$ifdef FPC_HAS_FEATURE_UNICODESTRINGS}
  74. procedure WasiThreadSetThreadDebugNameU(threadHandle: TThreadID; const ThreadName: UnicodeString);
  75. begin
  76. {todo:implement}
  77. end;
  78. {$endif FPC_HAS_FEATURE_UNICODESTRINGS}
  79. procedure WasiInitCriticalSection(var cs);
  80. begin
  81. {todo:implement}
  82. end;
  83. procedure WasiDoneCriticalSection(var cs);
  84. begin
  85. {todo:implement}
  86. end;
  87. procedure WasiEnterCriticalSection(var cs);
  88. begin
  89. {todo:implement}
  90. end;
  91. function WasiCriticalSectionTryEnter(var cs):longint;
  92. begin
  93. {todo:implement}
  94. end;
  95. procedure WasiLeaveCriticalSection(var cs);
  96. begin
  97. {todo:implement}
  98. end;
  99. procedure WasiInitThreadVar(var offset : dword;size : dword);
  100. begin
  101. {todo:implement}
  102. end;
  103. function WasiRelocateThreadVar(offset : dword) : pointer;
  104. begin
  105. {todo:implement}
  106. end;
  107. procedure WasiAllocateThreadVars;
  108. begin
  109. {todo:implement}
  110. end;
  111. procedure WasiReleaseThreadVars;
  112. begin
  113. {todo:implement}
  114. end;
  115. function WasiBasicEventCreate(EventAttributes :Pointer; AManualReset,InitialState : Boolean;const Name:ansistring):pEventState;
  116. begin
  117. {todo:implement}
  118. end;
  119. procedure WasiBasicEventDestroy(state:peventstate);
  120. begin
  121. {todo:implement}
  122. end;
  123. procedure WasiBasicEventResetEvent(state:peventstate);
  124. begin
  125. {todo:implement}
  126. end;
  127. procedure WasiBasicEventSetEvent(state:peventstate);
  128. begin
  129. {todo:implement}
  130. end;
  131. function WasiBasicEventWaitFor(timeout:cardinal;state:peventstate;FUseComWait : Boolean=False):longint;
  132. begin
  133. {todo:implement}
  134. end;
  135. function WasiRTLCreateEvent:PRTLEvent;
  136. begin
  137. {todo:implement}
  138. end;
  139. procedure WasiRTLEventDestroy(AEvent:PRTLEvent);
  140. begin
  141. {todo:implement}
  142. end;
  143. procedure WasiRTLEventSetEvent(AEvent:PRTLEvent);
  144. begin
  145. {todo:implement}
  146. end;
  147. procedure WasiRTLEventResetEvent(AEvent:PRTLEvent);
  148. begin
  149. {todo:implement}
  150. end;
  151. procedure WasiRTLEventWaitFor(AEvent:PRTLEvent);
  152. begin
  153. {todo:implement}
  154. end;
  155. procedure WasiRTLEventWaitForTimeout(AEvent:PRTLEvent;timeout : longint);
  156. begin
  157. {todo:implement}
  158. end;
  159. procedure InitSystemThreads;public name '_FPC_InitSystemThreads';
  160. begin
  161. with WasiThreadManager do
  162. begin
  163. InitManager := @WasiInitManager;
  164. DoneManager := @WasiDoneManager;
  165. BeginThread := @WasiBeginThread;
  166. EndThread := @WasiEndThread;
  167. SuspendThread := @WasiSuspendThread;
  168. ResumeThread := @WasiResumeThread;
  169. KillThread := @WasiKillThread;
  170. CloseThread := @WasiCloseThread;
  171. ThreadSwitch := @WasiThreadSwitch;
  172. WaitForThreadTerminate := @WasiWaitForThreadTerminate;
  173. ThreadSetPriority := @WasiThreadSetPriority;
  174. ThreadGetPriority := @WasiThreadGetPriority;
  175. GetCurrentThreadId := @WasiGetCurrentThreadId;
  176. SetThreadDebugNameA := @WasiThreadSetThreadDebugNameA;
  177. {$ifdef FPC_HAS_FEATURE_UNICODESTRINGS}
  178. SetThreadDebugNameU := @WasiThreadSetThreadDebugNameU;
  179. {$endif FPC_HAS_FEATURE_UNICODESTRINGS}
  180. InitCriticalSection := @WasiInitCriticalSection;
  181. DoneCriticalSection := @WasiDoneCriticalSection;
  182. EnterCriticalSection := @WasiEnterCriticalSection;
  183. TryEnterCriticalSection:= @WasiCriticalSectionTryEnter;
  184. LeaveCriticalSection := @WasiLeaveCriticalSection;
  185. InitThreadVar := @WasiInitThreadVar;
  186. RelocateThreadVar := @WasiRelocateThreadVar;
  187. AllocateThreadVars := @WasiAllocateThreadVars;
  188. ReleaseThreadVars := @WasiReleaseThreadVars;
  189. BasicEventCreate := @WasiBasicEventCreate;
  190. BasicEventDestroy := @WasiBasicEventDestroy;
  191. BasicEventResetEvent := @WasiBasicEventResetEvent;
  192. BasicEventSetEvent := @WasiBasicEventSetEvent;
  193. BasiceventWaitFOr := @WasiBasicEventWaitFor;
  194. RTLEventCreate := @WasiRTLCreateEvent;
  195. RTLEventDestroy := @WasiRTLEventDestroy;
  196. RTLEventSetEvent := @WasiRTLEventSetEvent;
  197. RTLEventResetEvent := @WasiRTLEventResetEvent;
  198. RTLEventWaitFor := @WasiRTLEventWaitFor;
  199. RTLEventWaitForTimeout := @WasiRTLEventWaitForTimeout;
  200. end;
  201. SetThreadManager(WasiThreadManager);
  202. end;