mono-dl-windows.c \
mono-dl-darwin.c \
mono-dl-posix.c \
+ mono-dl-wasm.c \
mono-dl.h \
mono-dl-windows-internals.h \
mono-log-windows.c \
mono-threads-openbsd.c \
mono-threads-android.c \
mono-threads-haiku.c \
+ mono-threads-wasm.c \
mono-threads.h \
mono-threads-debug.h \
mono-threads-api.h \
arch_sources += mono-hwcap-s390x.c
endif
+if HOST_WASM
+arch_sources += mono-hwcap-wasm.c
+endif
+
else
arch_sources += mono-hwcap-cross.c
--- /dev/null
+#include <config.h>
+
+#if defined (HOST_WASM)
+
+#include "mono/utils/mono-dl.h"
+#include "mono/utils/mono-embed.h"
+#include "mono/utils/mono-path.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <string.h>
+#include <glib.h>
+
+const char *
+mono_dl_get_so_prefix (void)
+{
+ return "";
+}
+const char **
+mono_dl_get_so_suffixes (void)
+{
+ static const char *suffixes[] = {
+ ".wasm",
+ "",
+ };
+ return suffixes;
+}
+
+int
+mono_dl_get_executable_path (char *buf, int buflen)
+{
+ strncpy (buf, "/managed", buflen);
+ return 0;
+}
+
+const char*
+mono_dl_get_system_dir (void)
+{
+ return NULL;
+}
+
+
+void*
+mono_dl_lookup_symbol (MonoDl *module, const char *name)
+{
+ return NULL;
+}
+
+char*
+mono_dl_current_error_string (void)
+{
+ return g_strdup ("");
+}
+
+
+int
+mono_dl_convert_flags (int flags)
+{
+ return flags;
+}
+
+void *
+mono_dl_open_file (const char *file, int flags)
+{
+ return NULL;
+}
+
+void
+mono_dl_close_handle (MonoDl *module)
+{
+ //nothing to do
+}
+
+#endif
--- /dev/null
+/**
+ * \file
+ * wasm feature detection
+ *
+ * Authors:
+ * Rodrigo Kumpera (kumpera@gmail.com)
+ * Licensed under the MIT license. See LICENSE file in the project root for full license information.
+ */
+
+#include "mono/utils/mono-hwcap.h"
+
+void
+mono_hwcap_arch_init (void)
+{
+}
extern int tkill (pid_t tid, int signal);
#endif
-#if defined(_POSIX_VERSION)
+#if defined(_POSIX_VERSION) && !defined (TARGET_WASM)
#include <pthread.h>
--- /dev/null
+#include "config.h"
+
+#include <mono/utils/mono-threads.h>
+#include <mono/utils/mono-mmap.h>
+
+#if defined (USE_WASM_BACKEND)
+
+#define round_down(addr, val) ((void*)((addr) & ~((val) - 1)))
+
+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
+}
+
+void
+mono_threads_suspend_init_signals (void)
+{
+}
+
+void
+mono_threads_suspend_init (void)
+{
+}
+
+void
+mono_threads_suspend_register (MonoThreadInfo *info)
+{
+}
+
+gboolean
+mono_threads_suspend_begin_async_resume (MonoThreadInfo *info)
+{
+ return TRUE;
+}
+
+void
+mono_threads_suspend_free (MonoThreadInfo *info)
+{
+}
+
+gboolean
+mono_threads_suspend_begin_async_suspend (MonoThreadInfo *info, gboolean interrupt_kernel)
+{
+ return TRUE;
+}
+
+gboolean
+mono_threads_suspend_check_suspend_result (MonoThreadInfo *info)
+{
+ return TRUE;
+}
+
+void
+mono_threads_suspend_abort_syscall (MonoThreadInfo *info)
+{
+}
+
+#endif
/* If this is defined, use the signals backed on Mach. Debug only as signals can't be made usable on OSX. */
// #define USE_SIGNALS_ON_MACH
-#if defined (_POSIX_VERSION)
+#ifdef HOST_WASM
+#define USE_WASM_BACKEND
+#elif defined (_POSIX_VERSION)
#if defined (__MACH__) && !defined (USE_SIGNALS_ON_MACH)
#define USE_MACH_BACKEND
#else