Skip to content

Commit

Permalink
Get wasmtime building on Windows. (#92)
Browse files Browse the repository at this point in the history
* Get wasmtime building on Windows.

Requires LLVM binaries from http://releases.llvm.org/download.html at
build time (bindgen).
  • Loading branch information
hrydgard authored and sunfishcode committed Apr 3, 2019
1 parent 474809f commit f5ebdb8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
6 changes: 4 additions & 2 deletions wasmtime-runtime/signalhandlers/SignalHandlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@
#include <stdio.h>

#if defined(_WIN32)
# include <winternl.h> // must include before util/Windows.h's `#undef`s
# include "util/Windows.h"

# include <windows.h>
# include <winternl.h>

#elif defined(USE_APPLE_MACH_PORTS)
# include <mach/exc.h>
# include <mach/mach.h>
Expand Down
2 changes: 0 additions & 2 deletions wasmtime-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
15 changes: 12 additions & 3 deletions wasmtime-runtime/src/mmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,17 +187,26 @@ 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);
assert!(len < self.len);
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());
}

Expand Down

0 comments on commit f5ebdb8

Please sign in to comment.