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).
This commit is contained in:
Henrik Rydgård
2019-04-03 15:50:38 +02:00
committed by Dan Gohman
parent 474809f5f3
commit f5ebdb8e6a
3 changed files with 16 additions and 7 deletions

View File

@@ -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>

View File

@@ -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;

View File

@@ -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());
}