浏览代码

Skip JITting on Windows

Jan-Erik Rediger 7 年之前
父节点
当前提交
435c6152d6
共有 3 个文件被更改,包括 24 次插入0 次删除
  1. 13 0
      src/lib.rs
  2. 10 0
      tests/misc.rs
  3. 1 0
      tests/ubpf_jit_x86_64.rs

+ 13 - 0
src/lib.rs

@@ -31,6 +31,7 @@ pub mod ebpf;
 pub mod helpers;
 pub mod insn_builder;
 mod asm_parser;
+#[cfg(not(windows))]
 mod jit;
 mod verifier;
 
@@ -553,6 +554,7 @@ impl<'a> EbpfVmMbuff<'a> {
     ///
     /// vm.jit_compile();
     /// ```
+    #[cfg(not(windows))]
     pub fn jit_compile(&mut self) {
         self.jit = jit::compile(self.prog, &self.helpers, true, false);
     }
@@ -603,9 +605,11 @@ impl<'a> EbpfVmMbuff<'a> {
     /// // Instantiate a VM.
     /// let mut vm = rbpf::EbpfVmMbuff::new(prog);
     ///
+    /// # #[cfg(not(windows))]
     /// vm.jit_compile();
     ///
     /// // Provide both a reference to the packet data, and to the metadata buffer.
+    /// # #[cfg(not(windows))]
     /// unsafe {
     ///     let res = vm.prog_exec_jit(mem, &mut mbuff);
     ///     assert_eq!(res, 0x2211);
@@ -910,6 +914,7 @@ impl<'a> EbpfVmFixedMbuff<'a> {
     ///
     /// vm.jit_compile();
     /// ```
+    #[cfg(not(windows))]
     pub fn jit_compile(&mut self) {
         self.parent.jit = jit::compile(self.parent.prog, &self.parent.helpers, true, true);
     }
@@ -954,9 +959,11 @@ impl<'a> EbpfVmFixedMbuff<'a> {
     /// // Instantiate a VM. Note that we provide the start and end offsets for mem pointers.
     /// let mut vm = rbpf::EbpfVmFixedMbuff::new(prog, 0x40, 0x50);
     ///
+    /// # #[cfg(not(windows))]
     /// vm.jit_compile();
     ///
     /// // Provide only a reference to the packet data. We do not manage the metadata buffer.
+    /// # #[cfg(not(windows))]
     /// unsafe {
     ///     let res = vm.prog_exec_jit(mem);
     ///     assert_eq!(res, 0xdd);
@@ -1162,6 +1169,7 @@ impl<'a> EbpfVmRaw<'a> {
     ///
     /// vm.jit_compile();
     /// ```
+    #[cfg(not(windows))]
     pub fn jit_compile(&mut self) {
         self.parent.jit = jit::compile(self.parent.prog, &self.parent.helpers, false, false);
     }
@@ -1198,8 +1206,10 @@ impl<'a> EbpfVmRaw<'a> {
     ///
     /// let mut vm = rbpf::EbpfVmRaw::new(prog);
     ///
+    /// # #[cfg(not(windows))]
     /// vm.jit_compile();
     ///
+    /// # #[cfg(not(windows))]
     /// unsafe {
     ///     let res = vm.prog_exec_jit(mem);
     ///     assert_eq!(res, 0x22cc);
@@ -1373,6 +1383,7 @@ impl<'a> EbpfVmNoData<'a> {
     ///
     /// vm.jit_compile();
     /// ```
+    #[cfg(not(windows))]
     pub fn jit_compile(&mut self) {
         self.parent.jit_compile();
     }
@@ -1431,8 +1442,10 @@ impl<'a> EbpfVmNoData<'a> {
     ///
     /// let mut vm = rbpf::EbpfVmNoData::new(prog);
     ///
+    /// # #[cfg(not(windows))]
     /// vm.jit_compile();
     ///
+    /// # #[cfg(not(windows))]
     /// unsafe {
     ///     let res = vm.prog_exec_jit();
     ///     assert_eq!(res, 0x1122);

+ 10 - 0
tests/misc.rs

@@ -170,6 +170,7 @@ fn test_vm_block_port() {
     assert_eq!(res, 0xffffffff);
 }
 
+#[cfg(not(windows))]
 #[test]
 fn test_jit_block_port() {
     // To load the bytecode from an object file instead of using the hardcoded instructions,
@@ -308,6 +309,7 @@ fn test_vm_mbuff_with_rust_api() {
 }
 
 // Program and memory come from uBPF test ldxh.
+#[cfg(not(windows))]
 #[test]
 fn test_jit_mbuff() {
     let prog = &[
@@ -336,6 +338,7 @@ fn test_jit_mbuff() {
     }
 }
 
+#[cfg(not(windows))]
 #[test]
 fn test_vm_jit_ldabsb() {
     let prog = &[
@@ -355,6 +358,7 @@ fn test_vm_jit_ldabsb() {
     };
 }
 
+#[cfg(not(windows))]
 #[test]
 fn test_vm_jit_ldabsh() {
     let prog = &[
@@ -374,6 +378,7 @@ fn test_vm_jit_ldabsh() {
     };
 }
 
+#[cfg(not(windows))]
 #[test]
 fn test_vm_jit_ldabsw() {
     let prog = &[
@@ -393,6 +398,7 @@ fn test_vm_jit_ldabsw() {
     };
 }
 
+#[cfg(not(windows))]
 #[test]
 fn test_vm_jit_ldabsdw() {
     let prog = &[
@@ -442,6 +448,7 @@ fn test_vm_err_ldabsb_nomem() {
     // Memory check not implemented for JIT yet.
 }
 
+#[cfg(not(windows))]
 #[test]
 fn test_vm_jit_ldindb() {
     let prog = &[
@@ -462,6 +469,7 @@ fn test_vm_jit_ldindb() {
     };
 }
 
+#[cfg(not(windows))]
 #[test]
 fn test_vm_jit_ldindh() {
     let prog = &[
@@ -482,6 +490,7 @@ fn test_vm_jit_ldindh() {
     };
 }
 
+#[cfg(not(windows))]
 #[test]
 fn test_vm_jit_ldindw() {
     let prog = &[
@@ -502,6 +511,7 @@ fn test_vm_jit_ldindw() {
     };
 }
 
+#[cfg(not(windows))]
 #[test]
 fn test_vm_jit_ldinddw() {
     let prog = &[

+ 1 - 0
tests/ubpf_jit_x86_64.rs

@@ -21,6 +21,7 @@
 // These are unit tests for the eBPF JIT compiler.
 
 #![cfg_attr(feature = "cargo-clippy", allow(unreadable_literal))]
+#![cfg(not(windows))]
 
 extern crate rbpf;
 mod common;