[wasm] Disable posix threading backend and fix wasm's.
[mono.git] / mono / utils / mono-threads-wasm.c
index 6ef8a9c5e843d7b84415ffdb13d71121930dc3ba..60816ed8d578d1cfbf9fc4d37c8688521f297833 100644 (file)
@@ -7,13 +7,13 @@
 
 #define round_down(addr, val) ((void*)((addr) & ~((val) - 1)))
 
-void
-mono_threads_platform_get_stack_bounds (guint8 **staddr, size_t *stsize)
+int
+mono_threads_get_max_stack_size (void)
 {
-       *staddr = round_down ((size_t)&staddr, 65536); //WASM pagesize is 64k
-       *stsize = 65536 * 4; //we say it's 4 pages, there isn't much that uses this beyond the GC
+       return 65536 * 8; //totally arbitrary, this value is actually useless until WASM supports multiple threads.
 }
 
+
 void
 mono_threads_suspend_init_signals (void)
 {
@@ -57,4 +57,79 @@ mono_threads_suspend_abort_syscall (MonoThreadInfo *info)
 {
 }
 
+//----
+
+gboolean
+mono_native_thread_id_equals (MonoNativeThreadId id1, MonoNativeThreadId id2)
+{
+       return id1 == id2;
+}
+
+
+MonoNativeThreadId
+mono_native_thread_id_get (void)
+{
+       return (MonoNativeThreadId)1;
+}
+
+MONO_API gboolean
+mono_native_thread_create (MonoNativeThreadId *tid, gpointer func, gpointer arg)
+{
+       g_error ("WASM doesn't support threading");
+}
+
+static const char *thread_name;
+
+void
+mono_native_thread_set_name (MonoNativeThreadId tid, const char *name)
+{
+       thread_name = g_strdup (name);
+}
+
+gboolean
+mono_native_thread_join (MonoNativeThreadId tid)
+{
+       g_error ("WASM doesn't support threading");
+       return FALSE;
+}
+
+//----
+
+gboolean
+mono_threads_platform_yield (void)
+{
+       return TRUE;
+}
+
+void
+mono_threads_platform_get_stack_bounds (guint8 **staddr, size_t *stsize)
+{
+       *staddr = round_down ((size_t)&staddr, 65536); //WASM pagesize is 64k
+       *stsize = 65536 * 4; //we say it's 4 pages, there isn't much that uses this beyond the GC
+}
+
+
+gboolean
+mono_thread_platform_create_thread (MonoThreadStart thread_fn, gpointer thread_data, gsize* const stack_size, MonoNativeThreadId *tid)
+{
+       g_error ("WASM doesn't support threading");
+       return FALSE;
+}
+
+void mono_threads_platform_init (void)
+{
+}
+
+void
+mono_threads_platform_exit (gsize exit_code)
+{
+       g_error ("WASM doesn't support threading");
+}
+
+gboolean
+mono_threads_platform_in_critical_region (MonoNativeThreadId tid)
+{
+       return FALSE;
+}
+
 #endif