diff --git a/.github/workflows/spec-tests.yml b/.github/workflows/spec-tests.yml index c13646e..b9bce1b 100644 --- a/.github/workflows/spec-tests.yml +++ b/.github/workflows/spec-tests.yml @@ -25,3 +25,27 @@ jobs: run: | cd test ./run-spec-test.py + + build-win: + runs-on: windows-latest + + strategy: + fail-fast: false + matrix: + toolset: [ClangCL, v142] + + steps: + - uses: actions/checkout@v1 + - name: configure + run: | + mkdir build + cd build + cmake -T ${{ matrix.toolset }} .. + - name: make + run: | + cmake --build build --config Release + cp ./build/Release/wasm3.exe ./build/ + - name: test + run: | + cd test + python run-spec-test.py diff --git a/CMakeLists.txt b/CMakeLists.txt index a3fe79b..f9c9ddf 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -90,6 +90,7 @@ elseif(WIN32) set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /Oxs /Oy /GS- /Qvec -Clang -O3") endif() else() + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Dd_m3HasWASI") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wstrict-aliasing -Wno-unused-function -Wno-unused-variable -Wno-unused-parameter -Wno-missing-field-initializers") set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -ggdb -O0") diff --git a/platforms/app/main.c b/platforms/app/main.c index 34a7a20..18744eb 100644 --- a/platforms/app/main.c +++ b/platforms/app/main.c @@ -182,8 +182,8 @@ int main (int i_argc, const char* i_argv[]) while (argRepl) { - char cmd_buff[128] = {}; - const char* argv[32] = {}; + char cmd_buff[128] = { 0, }; + const char* argv[32] = { 0, }; fprintf(stdout, "wasm3> "); fflush(stdout); if (!fgets(cmd_buff, sizeof(cmd_buff), stdin)) { diff --git a/source/m3_api_libc.c b/source/m3_api_libc.c index 07ddd11..22356d4 100644 --- a/source/m3_api_libc.c +++ b/source/m3_api_libc.c @@ -13,11 +13,27 @@ #include "m3_exception.h" #include -#include #include #include +#if defined(WIN32) + +#include + +int clock_gettime(int clk_id, struct timespec *spec) +{ + __int64 wintime; + GetSystemTimeAsFileTime((FILETIME*)&wintime); + wintime -=116444736000000000i64; //1jan1601 to 1jan1970 + spec->tv_sec =wintime / 10000000i64; //seconds + spec->tv_nsec =wintime % 10000000i64 *100; //nano-seconds + return 0; +} + +#endif + + // TODO: return trap void m3_libc_abort() { diff --git a/source/m3_api_wasi.c b/source/m3_api_wasi.c index 93d55e0..ebd45fe 100644 --- a/source/m3_api_wasi.c +++ b/source/m3_api_wasi.c @@ -12,6 +12,8 @@ #include "m3_module.h" #include "m3_exception.h" +#if defined(d_m3HasWASI) + #include "extra/wasi_core.h" #include @@ -377,7 +379,6 @@ M3Result SuppressLookupFailure(M3Result i_result) return i_result; } - M3Result m3_LinkWASI (IM3Module module) { M3Result result = c_m3Err_none; @@ -410,4 +411,12 @@ _catch: return result; } +#else // d_m3HasWASI + +M3Result m3_LinkWASI (IM3Module module) +{ + return c_m3Err_none; +} + +#endif // d_m3HasWASI diff --git a/source/m3_env.h b/source/m3_env.h index 069893c..19626c2 100644 --- a/source/m3_env.h +++ b/source/m3_env.h @@ -187,6 +187,7 @@ IM3Function Module_GetFunction (IM3Module i_module, u32 //--------------------------------------------------------------------------------------------------------------------------------- typedef struct M3Environment { + int dummmy; // u32 numFuncTypes; // M3FuncType * funcTypes; }