From e673b5fa15b3adc1f18a89d3582ec73269ed4ba5 Mon Sep 17 00:00:00 2001 From: Steven Massey Date: Thu, 5 Mar 2020 20:15:21 -0800 Subject: [PATCH] cpp test fix --- platforms/cpp/main.cpp | 4 ++-- source/m3_bind.c | 10 +++++++++- source/m3_parse.c | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/platforms/cpp/main.cpp b/platforms/cpp/main.cpp index 5edb863..c5afaf3 100644 --- a/platforms/cpp/main.cpp +++ b/platforms/cpp/main.cpp @@ -7,9 +7,9 @@ int sum(int a, int b) return a + b; } -void ext_memcpy(void* dst, const void* arg, int64_t size) +void * ext_memcpy (void* dst, const void* arg, int32_t size) { - memcpy(dst, arg, (size_t) size); + return memcpy(dst, arg, (size_t) size); } int main(void) diff --git a/source/m3_bind.c b/source/m3_bind.c index f114227..593fd95 100644 --- a/source/m3_bind.c +++ b/source/m3_bind.c @@ -8,6 +8,7 @@ #include "m3_exec.h" #include "m3_env.h" #include "m3_exception.h" +#include "m3_info.h" u8 ConvertTypeCharToTypeId (char i_code) @@ -81,7 +82,9 @@ _ (AllocFuncType (& funcType, (u32) maxNumArgs)); // M3FuncType doesn't speak 'void' if (type == c_m3Type_void) type = c_m3Type_none; - + if (type == c_m3Type_ptr) + type = c_m3Type_i32; + funcType->returnType = type; } else @@ -121,7 +124,12 @@ M3Result ValidateSignature (IM3Function i_function, ccstr_t i_linkingSignature _ (SignatureToFuncType (& ftype, i_linkingSignature)); if (not AreFuncTypesEqual (ftype, i_function->funcType)) + { + m3log (module, "expected: %s", SPrintFuncTypeSignature (ftype)); + m3log (module, " found: %s", SPrintFuncTypeSignature (i_function->funcType)); + _throw ("function signature mismatch"); + } _catch: diff --git a/source/m3_parse.c b/source/m3_parse.c index bf31d73..c6093f3 100644 --- a/source/m3_parse.c +++ b/source/m3_parse.c @@ -82,7 +82,7 @@ _ (ReadLEB_u7 /* u1 in spec */ (& returnCount, & i_bytes, i_end)); i8 returnType; _ (ReadLEB_i7 (& returnType, & i_bytes, i_end)); _ (NormalizeType (& ftype->returnType, returnType)); - } m3log (parse, " type %2d: %s", i, SPrintFuncTypeSignature (& ftype)); + } m3log (parse, " type %2d: %s", i, SPrintFuncTypeSignature (ftype)); Environment_AddFuncType (io_module->environment, & ftype); io_module->funcTypes [i] = ftype;