From 7d3fc17e815073e24d1f1506305e6ae0c4753be7 Mon Sep 17 00:00:00 2001 From: Jay Krell Date: Wed, 16 Oct 2019 01:12:41 -0700 Subject: [PATCH] Fix C++ WebAssembly build. (#17302) --- mono/metadata/marshal.h | 3 --- mono/utils/dlmalloc.h | 16 ++++++++++++++++ mono/utils/mono-mmap-wasm.c | 2 +- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/mono/metadata/marshal.h b/mono/metadata/marshal.h index f19be3994d6..b65786cb5d3 100644 --- a/mono/metadata/marshal.h +++ b/mono/metadata/marshal.h @@ -550,9 +550,6 @@ mono_marshal_set_last_error_windows (int error); void mono_struct_delete_old (MonoClass *klass, char *ptr); -MonoObject* -mono_object_isinst_icall (MonoObject *obj, MonoClass *klass); - int mono_emit_marshal (EmitMarshalContext *m, int argnum, MonoType *t, MonoMarshalSpec *spec, int conv_arg, diff --git a/mono/utils/dlmalloc.h b/mono/utils/dlmalloc.h index db2614fa6cd..56192152e78 100644 --- a/mono/utils/dlmalloc.h +++ b/mono/utils/dlmalloc.h @@ -28,6 +28,22 @@ #include /* for size_t */ #include +// Returning an undefined struct by value from extern "C" +// is sometimes an error. Mono does not use the code (dlmallinfo).. +// +// Other fixes: +// - define the struct +// - #if __cplusplus +// - #if HOST_WASM +// - #ifndef HAVE_USR_INCLUDE_MALLOC_H +// - Make it not extern "C". +// - Return the struct through an out parameter. +// - remove extern "C" entirely in dlmalloc. +// +// Mono does not use the function (dlmallinfo). +// +#define NO_MALLINFO 1 /* mono */ + #ifdef __cplusplus extern "C" { #endif diff --git a/mono/utils/mono-mmap-wasm.c b/mono/utils/mono-mmap-wasm.c index 344efa21924..10485f720dc 100644 --- a/mono/utils/mono-mmap-wasm.c +++ b/mono/utils/mono-mmap-wasm.c @@ -155,7 +155,7 @@ mono_valloc_aligned (size_t size, size_t alignment, int flags, MonoMemAccountTyp int mono_vfree (void *addr, size_t length, MonoMemAccountType type) { - VallocInfo *info = valloc_hash ? g_hash_table_lookup (valloc_hash, addr) : NULL; + VallocInfo *info = (VallocInfo*)(valloc_hash ? g_hash_table_lookup (valloc_hash, addr) : NULL); int res; if (info) { -- 2.11.4.GIT