From f5ebdb8e6ad72f29e14c362e1eb79f1b10fa5e2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 3 Apr 2019 15:50:38 +0200 Subject: [PATCH] Get wasmtime building on Windows. (#92) * Get wasmtime building on Windows. Requires LLVM binaries from http://releases.llvm.org/download.html at build time (bindgen). --- .../signalhandlers/SignalHandlers.cpp | 6 ++++-- wasmtime-runtime/src/lib.rs | 2 -- wasmtime-runtime/src/mmap.rs | 15 ++++++++++++--- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/wasmtime-runtime/signalhandlers/SignalHandlers.cpp b/wasmtime-runtime/signalhandlers/SignalHandlers.cpp index c39c6f42c86d..588ac8e3412d 100644 --- a/wasmtime-runtime/signalhandlers/SignalHandlers.cpp +++ b/wasmtime-runtime/signalhandlers/SignalHandlers.cpp @@ -13,8 +13,10 @@ #include #if defined(_WIN32) -# include // must include before util/Windows.h's `#undef`s -# include "util/Windows.h" + +# include +# include + #elif defined(USE_APPLE_MACH_PORTS) # include # include diff --git a/wasmtime-runtime/src/lib.rs b/wasmtime-runtime/src/lib.rs index 43b6bd89caba..8365d854231a 100644 --- a/wasmtime-runtime/src/lib.rs +++ b/wasmtime-runtime/src/lib.rs @@ -28,8 +28,6 @@ extern crate lazy_static; extern crate memoffset; #[macro_use] extern crate failure_derive; -#[cfg(target_os = "windows")] -extern crate winapi; mod export; mod imports; diff --git a/wasmtime-runtime/src/mmap.rs b/wasmtime-runtime/src/mmap.rs index ec646330dd67..a82a0f515c53 100644 --- a/wasmtime-runtime/src/mmap.rs +++ b/wasmtime-runtime/src/mmap.rs @@ -187,9 +187,9 @@ impl Mmap { /// `self`'s reserved memory. #[cfg(target_os = "windows")] pub fn make_accessible(&mut self, start: usize, len: usize) -> Result<(), String> { + use core::ffi::c_void; use winapi::um::memoryapi::VirtualAlloc; - use winapi::um::winnt::{MEM_COMMIT, MEM_RESERVE, PAGE_NOACCESS, PAGE_READWRITE}; - + use winapi::um::winnt::{MEM_COMMIT, PAGE_READWRITE}; let page_size = region::page::size(); assert_eq!(start & (page_size - 1), 0); assert_eq!(len & (page_size - 1), 0); @@ -197,7 +197,16 @@ impl Mmap { assert!(start < self.len - len); // Commit the accessible size. - if unsafe { VirtualAlloc(self.ptr.add(start), len, MEM_COMMIT, PAGE_READWRITE) }.is_null() { + if unsafe { + VirtualAlloc( + self.ptr.add(start) as *mut c_void, + len, + MEM_COMMIT, + PAGE_READWRITE, + ) + } + .is_null() + { return Err(errno::errno().to_string()); }