Sfoglia il codice sorgente

Use core::ffi::c_void instead of libc::c_void

Gary Guo 3 anni fa
parent
commit
54cbb9f8fc
5 ha cambiato i file con 16 aggiunte e 6 eliminazioni
  1. 2 1
      src/abi.rs
  2. 5 3
      src/find_fde/phdr.rs
  3. 1 1
      src/find_fde/registry.rs
  4. 1 1
      src/frame.rs
  5. 7 0
      src/util.rs

+ 2 - 1
src/abi.rs

@@ -1,11 +1,12 @@
+use core::ffi::c_void;
 use core::ops;
 use core::ptr;
 use gimli::Register;
-use libc::{c_int, c_void};
 
 use crate::arch::*;
 use crate::find_fde::{self, FDEFinder};
 use crate::frame::Frame;
+use crate::util::*;
 
 #[repr(transparent)]
 #[derive(Clone, Copy, Debug, PartialEq, Eq)]

+ 5 - 3
src/find_fde/phdr.rs

@@ -1,9 +1,11 @@
-use super::FDESearchResult;
-use crate::util::{deref_pointer, get_unlimited_slice};
+use crate::find_fde::FDESearchResult;
+use crate::util::*;
+
+use core::ffi::c_void;
 use core::mem;
 use core::slice;
 use gimli::{BaseAddresses, EhFrame, EhFrameHdr, NativeEndian, UnwindSection};
-use libc::{c_int, c_void, dl_iterate_phdr, dl_phdr_info, PT_DYNAMIC, PT_GNU_EH_FRAME, PT_LOAD};
+use libc::{dl_iterate_phdr, dl_phdr_info, PT_DYNAMIC, PT_GNU_EH_FRAME, PT_LOAD};
 
 struct CallbackData {
     pc: usize,

+ 1 - 1
src/find_fde/registry.rs

@@ -1,9 +1,9 @@
 use super::FDESearchResult;
 use crate::util::get_unlimited_slice;
+use core::ffi::c_void;
 use core::mem::MaybeUninit;
 use core::ptr;
 use gimli::{BaseAddresses, EhFrame, NativeEndian, UnwindSection};
-use libc::c_void;
 use once_cell::sync::Lazy;
 use std::sync::Mutex;
 

+ 1 - 1
src/frame.rs

@@ -3,10 +3,10 @@ use gimli::{
     UninitializedUnwindContext, UnwindTableRow, Value,
 };
 
+use crate::abi::PersonalityRoutine;
 use crate::arch::*;
 use crate::find_fde::{self, FDEFinder, FDESearchResult};
 use crate::util::*;
-use crate::abi::PersonalityRoutine;
 
 #[derive(Debug)]
 pub struct Frame {

+ 7 - 0
src/util.rs

@@ -16,3 +16,10 @@ pub unsafe fn deref_pointer(ptr: Pointer) -> usize {
         Pointer::Indirect(x) => unsafe { *(x as *const _) },
     }
 }
+
+#[cfg(feature = "libc")]
+pub use libc::c_int;
+
+#[cfg(not(feature = "libc"))]
+#[allow(non_camel_case_types)]
+pub type c_int = i32;