Tidy up trap-handling code.

This commit is contained in:
Dan Gohman
2018-12-19 15:12:56 -08:00
parent 4d4ecfd812
commit c4e10227de
13 changed files with 60 additions and 21 deletions

View File

@@ -23,6 +23,9 @@ cast = { version = "0.2.2", default-features = false }
failure = { version = "0.1.3", default-features = false }
failure_derive = { version = "0.1.3", default-features = false }
[target.'cfg(target_os = "windows")'.dependencies]
winapi = { version = "0.3.6", features = ["winbase", "memoryapi"] }
[build-dependencies]
cmake = "0.1.35"
bindgen = "0.44.0"

View File

@@ -453,7 +453,9 @@ WasmTrapHandler(LPEXCEPTION_POINTERS exception)
EXCEPTION_RECORD* record = exception->ExceptionRecord;
if (record->ExceptionCode != EXCEPTION_ACCESS_VIOLATION &&
record->ExceptionCode != EXCEPTION_ILLEGAL_INSTRUCTION)
record->ExceptionCode != EXCEPTION_ILLEGAL_INSTRUCTION &&
record->ExceptionCode != EXCEPTION_STACK_OVERFLOW &&
record->ExceptionCode != EXCEPTION_INT_DIVIDE_BY_ZERO)
{
return EXCEPTION_CONTINUE_SEARCH;
}

View File

@@ -42,6 +42,8 @@ extern crate cast;
extern crate failure;
#[macro_use]
extern crate failure_derive;
#[cfg(target_os = "windows")]
extern crate winapi;
mod export;
mod imports;

View File

@@ -130,7 +130,7 @@ impl Drop for Mmap {
if !self.ptr.is_null() {
use winapi::um::memoryapi::VirtualFree;
use winapi::um::winnt::MEM_RELEASE;
let r = unsafe { VirtualFree(self.ptr, self.len, MEM_RELEASE) };
let r = unsafe { VirtualFree(self.ptr as *mut libc::c_void, self.len, MEM_RELEASE) };
assert_eq!(r, 0);
}
}