From 1f8d4bc8b536e7dfe78d7ebcd77c277d39f2a0df Mon Sep 17 00:00:00 2001 From: vargaz Date: Mon, 8 Jun 2020 17:35:48 +0000 Subject: [PATCH] [wasm] Throw PlatformNotSupportedException instead of NotSupportedException when starting threads/waiting on monitors. --- src/mono/mono/metadata/monitor.c | 2 +- src/mono/mono/metadata/threads.c | 4 ++-- src/mono/mono/utils/mono-error-internals.h | 5 +++++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/mono/mono/metadata/monitor.c b/src/mono/mono/metadata/monitor.c index 72e51bd56c50f6..86a25e9d0cdaad 100644 --- a/src/mono/mono/metadata/monitor.c +++ b/src/mono/mono/metadata/monitor.c @@ -1412,7 +1412,7 @@ mono_monitor_wait (MonoObjectHandle obj_handle, guint32 ms, MonoBoolean allow_in #ifdef DISABLE_THREADS if (ms == MONO_INFINITE_WAIT) { - mono_error_set_synchronization_lock (error, "Cannot wait on monitors on this runtime."); + mono_error_set_platform_not_supported (error, "Cannot wait on monitors on this runtime."); return FALSE; } #endif diff --git a/src/mono/mono/metadata/threads.c b/src/mono/mono/metadata/threads.c index 53fba02f33df06..d5e003ff1b8b56 100644 --- a/src/mono/mono/metadata/threads.c +++ b/src/mono/mono/metadata/threads.c @@ -1710,7 +1710,7 @@ ves_icall_System_Threading_Thread_Thread_internal (MonoThreadObjectHandle thread MonoObject *start = MONO_HANDLE_RAW (start_handle); #ifdef DISABLE_THREADS - mono_error_set_not_supported (error, "Cannot start threads on this runtime."); + mono_error_set_platform_not_supported (error, "Cannot start threads on this runtime."); return FALSE; #endif @@ -6744,7 +6744,7 @@ ves_icall_System_Threading_Thread_StartInternal (MonoThreadObjectHandle thread_h gboolean res; #ifdef DISABLE_THREADS - mono_error_set_not_supported (error, "Cannot start threads on this runtime."); + mono_error_set_platform_not_supported (error, "Cannot start threads on this runtime."); return; #endif diff --git a/src/mono/mono/utils/mono-error-internals.h b/src/mono/mono/utils/mono-error-internals.h index 5373f28b91eafc..cb77708cf77556 100644 --- a/src/mono/mono/utils/mono-error-internals.h +++ b/src/mono/mono/utils/mono-error-internals.h @@ -278,6 +278,11 @@ mono_error_set_cannot_unload_appdomain (MonoError *error, const char *message) mono_error_set_generic_error (error, "System", "CannotUnloadAppDomainException", "%s", message); } +static inline void +mono_error_set_platform_not_supported (MonoError *error, const char *message) +{ + mono_error_set_generic_error (error, "System", "PlatformNotSupportedException", "%s", message); +} MonoException* mono_error_prepare_exception (MonoError *error, MonoError *error_out);