mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-28 08:01:33 +00:00
Allow using wasmer as a library.
This commit is contained in:
@ -1,19 +1,5 @@
|
||||
#[macro_use]
|
||||
extern crate error_chain;
|
||||
extern crate cranelift_codegen;
|
||||
extern crate cranelift_entity;
|
||||
extern crate cranelift_native;
|
||||
extern crate cranelift_wasm;
|
||||
extern crate libc;
|
||||
extern crate memmap;
|
||||
extern crate region;
|
||||
extern crate structopt;
|
||||
extern crate wabt;
|
||||
extern crate wasmparser;
|
||||
#[macro_use]
|
||||
extern crate target_lexicon;
|
||||
extern crate nix;
|
||||
extern crate rayon;
|
||||
extern crate wasmer;
|
||||
|
||||
use std::fs::File;
|
||||
use std::io;
|
||||
@ -23,16 +9,7 @@ use std::process::exit;
|
||||
|
||||
use structopt::StructOpt;
|
||||
|
||||
#[macro_use]
|
||||
mod macros;
|
||||
#[macro_use]
|
||||
mod recovery;
|
||||
pub mod apis;
|
||||
pub mod common;
|
||||
pub mod sighandler;
|
||||
#[cfg(test)]
|
||||
mod spectests;
|
||||
pub mod webassembly;
|
||||
use wasmer::*;
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[structopt(name = "wasmer", about = "WASM execution runtime.")]
|
27
src/lib.rs
Normal file
27
src/lib.rs
Normal file
@ -0,0 +1,27 @@
|
||||
#[macro_use]
|
||||
extern crate error_chain;
|
||||
extern crate cranelift_codegen;
|
||||
extern crate cranelift_entity;
|
||||
extern crate cranelift_native;
|
||||
extern crate cranelift_wasm;
|
||||
extern crate libc;
|
||||
extern crate memmap;
|
||||
extern crate region;
|
||||
extern crate structopt;
|
||||
extern crate wabt;
|
||||
extern crate wasmparser;
|
||||
#[macro_use]
|
||||
extern crate target_lexicon;
|
||||
pub extern crate nix; // re-exported for usage in macros
|
||||
extern crate rayon;
|
||||
|
||||
#[macro_use]
|
||||
mod macros;
|
||||
#[macro_use]
|
||||
pub mod recovery;
|
||||
pub mod apis;
|
||||
pub mod common;
|
||||
pub mod sighandler;
|
||||
#[cfg(test)]
|
||||
mod spectests;
|
||||
pub mod webassembly;
|
@ -4,10 +4,10 @@
|
||||
//! are very special, the async signal unsafety of Rust's TLS implementation generally does not affect the correctness here
|
||||
//! unless you have memory unsafety elsewhere in your code.
|
||||
|
||||
use std::cell::UnsafeCell;
|
||||
use nix::sys::signal::{Signal, SIGFPE, SIGILL, SIGSEGV, SIGBUS};
|
||||
use super::webassembly::ErrorKind;
|
||||
use super::sighandler::install_sighandler;
|
||||
use super::webassembly::ErrorKind;
|
||||
use nix::sys::signal::{Signal, SIGBUS, SIGFPE, SIGILL, SIGSEGV};
|
||||
use std::cell::UnsafeCell;
|
||||
|
||||
extern "C" {
|
||||
pub fn setjmp(env: *mut ::nix::libc::c_void) -> ::nix::libc::c_int;
|
||||
@ -29,12 +29,13 @@ thread_local! {
|
||||
/// the behavior of call_protected is undefined.
|
||||
#[macro_export]
|
||||
macro_rules! call_protected {
|
||||
($x:expr) => {unsafe {
|
||||
use crate::webassembly::ErrorKind;
|
||||
use crate::recovery::{SETJMP_BUFFER, setjmp};
|
||||
($x:expr) => {
|
||||
unsafe {
|
||||
use crate::recovery::{setjmp, SETJMP_BUFFER};
|
||||
use crate::sighandler::install_sighandler;
|
||||
use crate::webassembly::ErrorKind;
|
||||
|
||||
use nix::sys::signal::{Signal, SIGFPE, SIGILL, SIGSEGV, SIGBUS};
|
||||
use crate::nix::sys::signal::{Signal, SIGBUS, SIGFPE, SIGILL, SIGSEGV};
|
||||
|
||||
let jmp_buf = SETJMP_BUFFER.with(|buf| buf.get());
|
||||
let prev_jmp_buf = *jmp_buf;
|
||||
@ -58,10 +59,10 @@ macro_rules! call_protected {
|
||||
*jmp_buf = prev_jmp_buf;
|
||||
Ok(ret)
|
||||
}
|
||||
}}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/// Unwinds to last protected_call.
|
||||
pub unsafe fn do_unwind(signum: i32) -> ! {
|
||||
// Since do_unwind is only expected to get called from WebAssembly code which doesn't hold any host resources (locks etc.)
|
||||
|
Reference in New Issue
Block a user