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:
committed by
Dan Gohman
parent
474809f5f3
commit
f5ebdb8e6a
@@ -13,8 +13,10 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#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)
|
#elif defined(USE_APPLE_MACH_PORTS)
|
||||||
# include <mach/exc.h>
|
# include <mach/exc.h>
|
||||||
# include <mach/mach.h>
|
# include <mach/mach.h>
|
||||||
|
|||||||
@@ -28,8 +28,6 @@ extern crate lazy_static;
|
|||||||
extern crate memoffset;
|
extern crate memoffset;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate failure_derive;
|
extern crate failure_derive;
|
||||||
#[cfg(target_os = "windows")]
|
|
||||||
extern crate winapi;
|
|
||||||
|
|
||||||
mod export;
|
mod export;
|
||||||
mod imports;
|
mod imports;
|
||||||
|
|||||||
@@ -187,9 +187,9 @@ impl Mmap {
|
|||||||
/// `self`'s reserved memory.
|
/// `self`'s reserved memory.
|
||||||
#[cfg(target_os = "windows")]
|
#[cfg(target_os = "windows")]
|
||||||
pub fn make_accessible(&mut self, start: usize, len: usize) -> Result<(), String> {
|
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::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();
|
let page_size = region::page::size();
|
||||||
assert_eq!(start & (page_size - 1), 0);
|
assert_eq!(start & (page_size - 1), 0);
|
||||||
assert_eq!(len & (page_size - 1), 0);
|
assert_eq!(len & (page_size - 1), 0);
|
||||||
@@ -197,7 +197,16 @@ impl Mmap {
|
|||||||
assert!(start < self.len - len);
|
assert!(start < self.len - len);
|
||||||
|
|
||||||
// Commit the accessible size.
|
// 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());
|
return Err(errno::errno().to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user