add windows exception handling in C (#175)

This commit is contained in:
Mackenzie Clark
2019-02-14 09:58:33 -08:00
committed by GitHub
parent 0d7b5c8af6
commit 6a1fdb7f91
21 changed files with 630 additions and 32 deletions

View File

@ -150,7 +150,8 @@ impl Drop for Memory {
fn drop(&mut self) {
if !self.ptr.is_null() {
let success = unsafe { VirtualFree(self.ptr as _, self.size, MEM_DECOMMIT) };
assert_eq!(success, 0, "failed to unmap memory: {}", errno::errno());
// If the function succeeds, the return value is nonzero.
assert_eq!(success, 1, "failed to unmap memory: {}", errno::errno());
}
}
}

View File

@ -169,6 +169,7 @@ enum InnerFunc {}
/// Used to provide type safety (ish) for passing around function pointers.
/// The typesystem ensures this cannot be dereferenced since an
/// empty enum cannot actually exist.
#[repr(C)]
pub struct Func(InnerFunc);
/// An imported function, which contains the vmctx that owns this function.