Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion capstone-rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ travis-ci = { repository = "capstone-rust/capstone-rs" }

[dependencies]
capstone-sys = { path = "../capstone-sys", version = "0.17.0", default-features = false }
libc = { version = "0.2", default-features = false }
static_assertions = "1.1.0"

[dev-dependencies]
Expand Down
4 changes: 2 additions & 2 deletions capstone-rs/src/arch/arm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

use core::convert::{From, TryInto};
use core::{cmp, fmt, slice};
use core::ffi::c_uint;

use capstone_sys::{
arm_op_mem, arm_op_type, arm_shifter, cs_ac_type, cs_arm, cs_arm_op, cs_arm_op__bindgen_ty_2};
use libc::c_uint;

pub use crate::arch::arch_builder::arm::*;
use crate::arch::DetailsArchInsn;
Expand Down Expand Up @@ -301,7 +301,7 @@ mod test {
fn test_armshift() {
use super::arm_shifter::*;
use super::ArmShift::*;
use libc::c_uint;
use core::ffi::c_uint;

fn t(shift_type_value: (arm_shifter, c_uint), arm_shift: ArmShift) {
let (shift_type, value) = shift_type_value;
Expand Down
5 changes: 2 additions & 3 deletions capstone-rs/src/arch/arm64.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
//! Contains arm64-specific types

use libc::c_uint;

pub use crate::arch::arch_builder::arm64::*;
use crate::arch::DetailsArchInsn;
use crate::instruction::{AccessType, RegId, RegIdInt};
use capstone_sys::{arm64_op_mem, arm64_op_sme_index, arm64_op_type, cs_ac_type, cs_arm64, cs_arm64_op};
use core::convert::{From, TryInto};
use core::{cmp, fmt, mem, slice};
use core::ffi::c_uint;

// Re-exports
pub use capstone_sys::arm64_barrier_op as ArmBarrierOp;
Expand Down Expand Up @@ -306,7 +305,7 @@ mod test {
fn test_arm64shift() {
use super::arm64_shifter::*;
use super::Arm64Shift::*;
use libc::c_uint;
use core::ffi::c_uint;

fn t(shift_type_value: (arm64_shifter, c_uint), arm64_shift: Arm64Shift) {
let (shift_type, value) = shift_type_value;
Expand Down
4 changes: 2 additions & 2 deletions capstone-rs/src/arch/tms320c64x.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

use core::convert::From;
use core::{cmp, fmt, slice};
use core::ffi::c_int;

use libc::c_int;
use capstone_sys::{
cs_tms320c64x, cs_tms320c64x_op, tms320c64x_funit, tms320c64x_mem_dir, tms320c64x_mem_disp,
tms320c64x_mem_mod, tms320c64x_op_mem, tms320c64x_op_type,
Expand Down Expand Up @@ -256,7 +256,7 @@ def_arch_details_struct!(
mod test {
use super::*;
use capstone_sys::*;
use libc::{c_int, c_uint};
use core::ffi::{c_int, c_uint};

const OP_MEM_ZERO: tms320c64x_op_mem = tms320c64x_op_mem {
base: 0,
Expand Down
6 changes: 2 additions & 4 deletions capstone-rs/src/capstone.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
use alloc::boxed::Box;
use alloc::string::String;
use core::convert::From;
use core::ffi::CStr;
use core::ffi::{c_int, c_uint, c_void, CStr};
use core::marker::PhantomData;
use core::mem::MaybeUninit;
#[cfg(feature = "std")]
use std::ffi::CString;

use libc::{c_int, c_void};

use capstone_sys::cs_opt_value::*;
use capstone_sys::*;

Expand All @@ -17,7 +15,7 @@ use crate::constants::{Arch, Endian, ExtraMode, Mode, OptValue, Syntax};
use crate::instruction::{Insn, InsnDetail, InsnGroupId, InsnId, Instructions, RegId};
use crate::{error::*, PartialInitRegsAccess};

use {crate::ffi::str_from_cstr_ptr, alloc::string::ToString, libc::c_uint};
use {crate::ffi::str_from_cstr_ptr, alloc::string::ToString};

/// Length of `cs_regs`
pub(crate) const REGS_ACCESS_BUF_LEN: usize = 64;
Expand Down
9 changes: 4 additions & 5 deletions capstone-rs/src/ffi.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Functions useful for FFI

use core::{slice, str};
use libc::{self, c_char};
use core::ffi::c_char;
use core::ffi::CStr;

// This function will go unused in Diet mode
#[allow(unused)]
Expand All @@ -17,11 +17,10 @@ pub(crate) unsafe fn str_from_cstr_ptr<'a>(ptr: *const c_char) -> Option<&'a str
if ptr.is_null() {
return None;
}
let len = libc::strlen(ptr);
/* ASSUMPTION: capstone returns NUL terminated string */
let view: &[u8] = slice::from_raw_parts(ptr as *const u8, len as usize);
let cstr = CStr::from_ptr(ptr);
/* ASSUMPTION: capstone returns a valid UTF-8 string */
Some(str::from_utf8_unchecked(view))
Some(core::str::from_utf8_unchecked(cstr.to_bytes()))
}

#[cfg(test)]
Expand Down
2 changes: 1 addition & 1 deletion capstone-rs/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
clippy::upper_case_acronyms
)]

use core::ffi::c_uint;
use core::{convert::TryInto, fmt::Debug, mem::MaybeUninit};

use alloc::vec::Vec;
#[cfg(feature = "full")]
use {alloc::string::String, std::collections::HashSet};

use capstone_sys::cs_group_type;
use libc::c_uint;
use pretty_assertions::assert_eq;

use super::arch::*;
Expand Down
4 changes: 0 additions & 4 deletions capstone-sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,6 @@ exclude = [
[badges]
travis-ci = { repository = "capstone-rust/capstone-sys" }


[dependencies]
libc = { version = "0.2.59", default-features = false }

[build-dependencies]
bindgen = { optional = true, version = "0.69.0" }
regex = { optional = true, version = "1.10.4" }
Expand Down
2 changes: 1 addition & 1 deletion capstone-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ fn write_bindgen_bindings(
.rust_target(bindgen::RustTarget::Stable_1_28)
.size_t_is_usize(true)
.use_core()
.ctypes_prefix("libc")
.ctypes_prefix("::core::ffi")
.header(
find_capstone_header(header_search_paths, "capstone.h")
.expect("Could not find header")
Expand Down
Loading
Loading