|
9 | 9 | #include <emscripten/emscripten.h> |
10 | 10 | #elif defined(TARGET_WASI) |
11 | 11 | #include <stdlib.h> |
| 12 | +#include <stdint.h> |
12 | 13 | #include <errno.h> |
| 14 | +#include <stdio.h> |
13 | 15 | #include "pal/wasi/pal_wasi_missing.h" |
14 | 16 | #endif |
15 | 17 |
|
@@ -166,6 +168,130 @@ DWORD CONTEXTGetExceptionCodeForSignal(const siginfo_t *siginfo, |
166 | 168 | return 0; |
167 | 169 | } |
168 | 170 |
|
| 171 | +// RaiseException is the WIN32-style SEH entry — normally provided by |
| 172 | +// seh-unwind.cpp, which we exclude on WASI. The managed exception path on the |
| 173 | +// WASI interpreter throws PAL_SEHException via C++ throw instead, so this |
| 174 | +// surface is never reached. Stub kept only to satisfy linker references in |
| 175 | +// SString / NamespaceUtil / CLRConfig. |
| 176 | +extern "C" VOID PALAPI |
| 177 | +RaiseException( |
| 178 | + IN DWORD dwExceptionCode, |
| 179 | + IN DWORD dwExceptionFlags, |
| 180 | + IN DWORD nNumberOfArguments, |
| 181 | + IN CONST ULONG_PTR *lpArguments) |
| 182 | +{ |
| 183 | + (void)dwExceptionFlags; (void)nNumberOfArguments; (void)lpArguments; |
| 184 | + _ASSERT(!"RaiseException not implemented on wasi"); |
| 185 | + abort(); |
| 186 | +} |
| 187 | + |
| 188 | +// WIN32 debug-output APIs. WASI build excludes pal/src/debug/debug.cpp; route |
| 189 | +// to the same internal channels stderr would on a real platform. |
| 190 | +extern "C" VOID PALAPI |
| 191 | +DebugBreak() |
| 192 | +{ |
| 193 | + _ASSERT(!"DebugBreak not implemented on wasi"); |
| 194 | + __builtin_debugtrap(); |
| 195 | + abort(); |
| 196 | +} |
| 197 | + |
| 198 | +extern "C" VOID PALAPI |
| 199 | +OutputDebugStringA(IN LPCSTR lpOutputString) |
| 200 | +{ |
| 201 | + if (lpOutputString) fputs(lpOutputString, stderr); |
| 202 | +} |
| 203 | + |
| 204 | +extern "C" VOID PALAPI |
| 205 | +OutputDebugStringW(IN LPCWSTR lpOutputString) |
| 206 | +{ |
| 207 | + (void)lpOutputString; // wchar_t* — not converted here; stub only |
| 208 | +} |
| 209 | + |
| 210 | +// PAL exception-record allocation. Normally provided by seh-unwind.cpp, which |
| 211 | +// we exclude on WASI. The WASI interpreter doesn't dispatch through the |
| 212 | +// EXCEPTION_RECORD/CONTEXT machinery (it throws PAL_SEHException directly), |
| 213 | +// so these are only here to satisfy linker references in dispatch helpers |
| 214 | +// that never run. |
| 215 | +extern "C" PALIMPORT VOID PALAPI |
| 216 | +PAL_FreeExceptionRecords(IN EXCEPTION_RECORD *exceptionRecord, IN CONTEXT *contextRecord) |
| 217 | +{ |
| 218 | + (void)exceptionRecord; |
| 219 | + free(contextRecord); |
| 220 | +} |
| 221 | + |
| 222 | +extern "C" VOID |
| 223 | +AllocateExceptionRecords(EXCEPTION_RECORD** exceptionRecord, CONTEXT** contextRecord) |
| 224 | +{ |
| 225 | + *exceptionRecord = (EXCEPTION_RECORD*)calloc(1, sizeof(EXCEPTION_RECORD)); |
| 226 | + *contextRecord = (CONTEXT*)calloc(1, sizeof(CONTEXT)); |
| 227 | +} |
| 228 | + |
| 229 | +extern "C" PALIMPORT BOOL PALAPI |
| 230 | +PAL_VirtualUnwind(CONTEXT *context) |
| 231 | +{ |
| 232 | + (void)context; |
| 233 | + _ASSERT(!"PAL_VirtualUnwind not implemented on wasi"); |
| 234 | + return FALSE; |
| 235 | +} |
| 236 | + |
| 237 | +// Signal-handling surface — pal/src/exception/signal.cpp is excluded on WASI. |
| 238 | +// Stubs return success/no-op so the PAL init/shutdown paths continue. |
| 239 | +// These are C++ symbols (declared without extern "C" in pal/src/include/pal/signal.hpp). |
| 240 | +BOOL SEHInitializeSignals(CorUnix::CPalThread* pthrCurrent, DWORD flags) |
| 241 | +{ |
| 242 | + (void)pthrCurrent; (void)flags; |
| 243 | + return TRUE; |
| 244 | +} |
| 245 | + |
| 246 | +void SEHCleanupSignals(bool isChildProcess) |
| 247 | +{ |
| 248 | + (void)isChildProcess; |
| 249 | +} |
| 250 | + |
| 251 | +void UnmaskActivationSignal() |
| 252 | +{ |
| 253 | +} |
| 254 | + |
| 255 | +extern "C" VOID PALAPI |
| 256 | +PAL_EnableCrashReportBeforeSignalChaining(void) |
| 257 | +{ |
| 258 | + // No-op: WASI has no signal delivery. |
| 259 | +} |
| 260 | + |
| 261 | +// Per-thread context retrieval. Normally implemented via ptrace on Unix. |
| 262 | +// WASI single-process has no other thread to inspect. |
| 263 | +extern "C" PALIMPORT BOOL PALAPI |
| 264 | +GetThreadContext(IN HANDLE hThread, IN OUT LPCONTEXT lpContext) |
| 265 | +{ |
| 266 | + (void)hThread; (void)lpContext; |
| 267 | + _ASSERT(!"GetThreadContext not implemented on wasi"); |
| 268 | + return FALSE; |
| 269 | +} |
| 270 | + |
| 271 | +// FlushInstructionCache: no-op on WASI. wasm has no separate I-cache to flush. |
| 272 | +extern "C" PALIMPORT BOOL PALAPI |
| 273 | +FlushInstructionCache(IN HANDLE hProcess, IN LPCVOID lpBaseAddress, IN SIZE_T dwSize) |
| 274 | +{ |
| 275 | + (void)hProcess; (void)lpBaseAddress; (void)dwSize; |
| 276 | + return TRUE; |
| 277 | +} |
| 278 | + |
| 279 | +// SystemJS_GetLocaleInfo is the browser ICU shim entrypoint |
| 280 | +// (src/native/libs/System.Native.Browser/native/globalization-locale.ts). |
| 281 | +// On WASI we don't have a JS host; return null. The managed Globalization |
| 282 | +// layer must already gracefully handle this for the browser-not-loaded case. |
| 283 | +extern "C" uint16_t* SystemJS_GetLocaleInfo( |
| 284 | + const uint16_t* locale, int32_t localeLength, |
| 285 | + const uint16_t* culture, int32_t cultureLength, |
| 286 | + const uint16_t* result, int32_t resultMaxLength, |
| 287 | + int* resultLength) |
| 288 | +{ |
| 289 | + (void)locale; (void)localeLength; (void)culture; (void)cultureLength; |
| 290 | + (void)result; (void)resultMaxLength; |
| 291 | + if (resultLength) *resultLength = 0; |
| 292 | + return nullptr; |
| 293 | +} |
| 294 | + |
169 | 295 | // PAL also indirectly references getpwuid_r through PAL_GetUserName-style |
170 | 296 | // paths (init/pal.cpp transitively includes <pwd.h>). Provide a stub so |
171 | 297 | // transitive references resolve. |
|
0 commit comments