#![warn(missing_docs)]
#![allow(clippy::literal_string_with_formatting_args)]
#![deny(clippy::arithmetic_side_effects)]
#![deny(clippy::ptr_as_ptr)]
extern crate byteorder;
extern crate combine;
extern crate hash32;
extern crate log;
extern crate rand;
extern crate thiserror;
pub mod aligned_memory;
mod asm_parser;
pub mod assembler;
#[cfg(feature = "debugger")]
pub mod debugger;
pub mod disassembler;
pub mod ebpf;
pub mod elf;
pub mod elf_parser;
pub mod error;
pub mod insn_builder;
pub mod interpreter;
#[cfg(all(feature = "jit", not(target_os = "windows"), target_arch = "x86_64"))]
pub mod jit;
#[cfg(all(feature = "jit", not(target_os = "windows"), target_arch = "x86_64"))]
mod memory_management;
pub mod memory_region;
pub mod program;
pub mod static_analysis;
pub mod verifier;
pub mod vm;
#[cfg(all(feature = "jit", not(target_os = "windows"), target_arch = "x86_64"))]
mod x86;
trait ErrCheckedArithmetic: Sized {
fn err_checked_add(self, other: Self) -> Result<Self, ArithmeticOverflow>;
fn err_checked_sub(self, other: Self) -> Result<Self, ArithmeticOverflow>;
fn err_checked_mul(self, other: Self) -> Result<Self, ArithmeticOverflow>;
#[allow(dead_code)]
fn err_checked_div(self, other: Self) -> Result<Self, ArithmeticOverflow>;
}
struct ArithmeticOverflow;
macro_rules! impl_err_checked_arithmetic {
($($ty:ty),*) => {
$(
impl ErrCheckedArithmetic for $ty {
fn err_checked_add(self, other: $ty) -> Result<Self, ArithmeticOverflow> {
self.checked_add(other).ok_or(ArithmeticOverflow)
}
fn err_checked_sub(self, other: $ty) -> Result<Self, ArithmeticOverflow> {
self.checked_sub(other).ok_or(ArithmeticOverflow)
}
fn err_checked_mul(self, other: $ty) -> Result<Self, ArithmeticOverflow> {
self.checked_mul(other).ok_or(ArithmeticOverflow)
}
fn err_checked_div(self, other: $ty) -> Result<Self, ArithmeticOverflow> {
self.checked_div(other).ok_or(ArithmeticOverflow)
}
}
)*
}
}
impl_err_checked_arithmetic!(i8, i16, i32, i64, i128, isize, u8, u16, u32, u64, u128, usize);