diff --git a/src/core/ffi.c b/src/core/ffi.c index f48d1ba5..0e5de3de 100644 --- a/src/core/ffi.c +++ b/src/core/ffi.c @@ -1178,7 +1178,13 @@ static Janet janet_ffi_win64(JanetFFISignature *signature, void *function_pointe /* hack to get proper stack placement and avoid clobbering from logic above - shift stack down, otherwise we have issues. * Technically, this writes into 16 bytes of unallocated stack memory */ +#ifdef JANET_MINGW +#pragma GCC diagnostic ignored "-Wstringop-overflow" +#endif if (stack_size) memmove(stack - stack_shift, stack, stack_size); +#ifdef JANET_MINGW +#pragma GCC diagnostic pop +#endif switch (signature->variant) { default: diff --git a/src/core/os.c b/src/core/os.c index 4d5c8772..9ed397c0 100644 --- a/src/core/os.c +++ b/src/core/os.c @@ -118,6 +118,7 @@ JANET_CORE_FN(os_which, "(os/which)", "Check the current operating system. Returns one of:\n\n" "* :windows\n\n" + "* :mingw\n\n" "* :macos\n\n" "* :web - Web assembly (emscripten)\n\n" "* :linux\n\n" @@ -130,6 +131,8 @@ JANET_CORE_FN(os_which, (void) argv; #if defined(JANET_OS_NAME) return janet_ckeywordv(janet_stringify(JANET_OS_NAME)); +#elif defined(JANET_MINGW) + return janet_ckeywordv("mingw"); #elif defined(JANET_WINDOWS) return janet_ckeywordv("windows"); #elif defined(JANET_APPLE) @@ -445,7 +448,9 @@ typedef struct { static JanetEVGenericMessage janet_proc_wait_subr(JanetEVGenericMessage args) { JanetProc *proc = (JanetProc *) args.argp; WaitForSingleObject(proc->pHandle, INFINITE); - GetExitCodeProcess(proc->pHandle, (LPDWORD) &args.tag); + DWORD exitcode = 0; + GetExitCodeProcess(proc->pHandle, &exitcode); + args.tag = (int32_t) exitcode; return args; } diff --git a/src/include/janet.h b/src/include/janet.h index 0eaa2178..8815fe31 100644 --- a/src/include/janet.h +++ b/src/include/janet.h @@ -97,6 +97,11 @@ extern "C" { #define JANET_MSVC #endif +/* Check Mingw 32-bit and 64-bit */ +#ifdef __MINGW32__ +#define JANET_MINGW +#endif + /* Check 64-bit vs 32-bit */ #if ((defined(__x86_64__) || defined(_M_X64)) \ && (defined(JANET_POSIX) || defined(JANET_WINDOWS))) \ diff --git a/test/suite0010.janet b/test/suite0010.janet index 98e0ad4d..e3db6818 100644 --- a/test/suite0010.janet +++ b/test/suite0010.janet @@ -144,7 +144,7 @@ (assert (< 1000 1e23) "greater than immediate 2") # os/execute with environment variables -(assert (= 0 (os/execute [(dyn :executable) "-e" "(+ 1 2 3)"] :pe {"HELLO" "WORLD"})) "os/execute with env") +(assert (= 0 (os/execute [(dyn :executable) "-e" "(+ 1 2 3)"] :pe (merge (os/environ) {"HELLO" "WORLD"}))) "os/execute with env") # Regression #638 (compwhen