Skip to content

Commit

Permalink
Merge pull request #46 from akhilles/2018-edition
Browse files Browse the repository at this point in the history
2018 edition, upgrade dependencies, remove `nightly` feature
  • Loading branch information
fitzgen authored Oct 31, 2019
2 parents 0b23d00 + 62e0476 commit 2a0665a
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 40 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ rust:
- nightly
- beta
- stable
- 1.31.0
cache: cargo

addons:
sources:
Expand All @@ -27,6 +29,8 @@ addons:
before_install:
- source ./ci/before_install.sh

matrix:
fast_finish: true
env:
matrix:
- PROFILE="--release"
Expand Down
12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ authors = ["Nick Fitzgerald <[email protected]>"]
description = "Find the set of shared libraries loaded in the current process with a cross platform API"
documentation = "https://docs.rs/findshlibs"
keywords = ["dyld", "dylib", "shared", "library", "dl_iterate_phdr"]
license = "Apache-2.0/MIT"
license = "MIT OR Apache-2.0"
name = "findshlibs"
readme = "./README.md"
repository = "https://github.com/gimli-rs/findshlibs"
version = "0.5.0"
version = "0.6.0"
edition = "2018"

[badges.coveralls]
repository = "gimli-rs/findshlibs"
Expand All @@ -16,8 +17,7 @@ repository = "gimli-rs/findshlibs"
repository = "gimli-rs/findshlibs"

[dependencies]
lazy_static = "1.0.0"
libc = "0.2.55"
libc = "0.2.65"

[features]
nightly = []
[target.'cfg(target_os = "macos")'.dependencies]
lazy_static = "1.4"
15 changes: 4 additions & 11 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,6 @@
//! [LUL]: http://searchfox.org/mozilla-central/rev/13148faaa91a1c823a7d68563d9995480e714979/tools/profiler/lul/LulMain.h#17-51
#![deny(missing_docs)]

#[cfg(target_os = "macos")]
#[macro_use]
extern crate lazy_static;

#[cfg(any(target_os = "linux", target_os = "macos"))]
extern crate libc;

#[cfg(target_os = "macos")]
pub mod macos;

Expand All @@ -97,10 +90,10 @@ use std::usize;
pub mod unsupported;

#[cfg(target_os = "linux")]
use linux as native_mod;
use crate::linux as native_mod;

#[cfg(target_os = "macos")]
use macos as native_mod;
use crate::macos as native_mod;

#[cfg(not(any(target_os = "macos", target_os = "linux")))]
use unsupported as native_mod;
Expand Down Expand Up @@ -264,9 +257,9 @@ impl fmt::Display for SharedLibraryId {
};
for (idx, byte) in bytes.iter().enumerate() {
if is_uuid && (idx == 4 || idx == 6 || idx == 8 || idx == 10) {
try!(write!(f, "-"));
write!(f, "-")?;
}
try!(write!(f, "{:02x}", byte));
write!(f, "{:02x}", byte)?;
}
Ok(())
}
Expand Down
22 changes: 11 additions & 11 deletions src/linux/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
//! Linux-specific implementation of the `SharedLibrary` trait.
use super::Segment as SegmentTrait;
use super::SharedLibrary as SharedLibraryTrait;
use super::{Bias, IterationControl, SharedLibraryId, Svma};
use libc;

use crate::Segment as SegmentTrait;
use crate::SharedLibrary as SharedLibraryTrait;
use crate::{Bias, IterationControl, SharedLibraryId, Svma};

use std::any::Any;
use std::borrow::Cow;
Expand All @@ -18,8 +20,6 @@ use std::os::unix::ffi::OsStringExt;
use std::panic;
use std::slice;

use libc;

#[cfg(target_pointer_width = "32")]
type Phdr = libc::Elf32_Phdr;

Expand All @@ -38,7 +38,7 @@ struct Nhdr32 {
#[derive(Debug)]
pub struct Segment<'a> {
phdr: *const Phdr,
shlib: PhantomData<&'a ::linux::SharedLibrary<'a>>,
shlib: PhantomData<&'a SharedLibrary<'a>>,
}

impl<'a> Segment<'a> {
Expand All @@ -54,7 +54,7 @@ impl<'a> Segment<'a> {
}

impl<'a> SegmentTrait for Segment<'a> {
type SharedLibrary = ::linux::SharedLibrary<'a>;
type SharedLibrary = SharedLibrary<'a>;

fn name(&self) -> &str {
unsafe {
Expand Down Expand Up @@ -102,7 +102,7 @@ impl<'a> SegmentTrait for Segment<'a> {

/// An iterator of mapped segments in a shared library.
pub struct SegmentIter<'a> {
inner: ::std::slice::Iter<'a, Phdr>,
inner: std::slice::Iter<'a, Phdr>,
}

impl<'a> Iterator for SegmentIter<'a> {
Expand Down Expand Up @@ -137,7 +137,7 @@ pub struct SharedLibrary<'a> {

struct IterState<F> {
f: F,
panic: Option<Box<Any + Send>>,
panic: Option<Box<dyn Any + Send>>,
idx: usize,
}

Expand Down Expand Up @@ -360,8 +360,8 @@ impl<'a> fmt::Debug for DebugPhdr<'a> {

#[cfg(test)]
mod tests {
use super::super::{IterationControl, Segment, SharedLibrary};
use linux;
use crate::{IterationControl, Segment, SharedLibrary};
use crate::linux;

#[test]
fn have_libc() {
Expand Down
17 changes: 9 additions & 8 deletions src/macos/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
//! trait](../trait.SharedLibrary.html).
#![allow(clippy::cast_ptr_alignment)]

use super::Segment as SegmentTrait;
use super::SharedLibrary as SharedLibraryTrait;
use super::{Bias, IterationControl, SharedLibraryId, Svma};
use libc;
use lazy_static::lazy_static;

use crate::Segment as SegmentTrait;
use crate::SharedLibrary as SharedLibraryTrait;
use crate::{Bias, IterationControl, SharedLibraryId, Svma};

use std::ffi::{CStr, OsStr};
use std::fmt;
Expand All @@ -13,8 +16,6 @@ use std::os::unix::ffi::OsStrExt;
use std::sync::Mutex;
use std::usize;

use libc;

const LC_UUID: u32 = 27;

#[repr(C)]
Expand Down Expand Up @@ -53,7 +54,7 @@ impl<'a> fmt::Debug for Segment<'a> {
}

impl<'a> SegmentTrait for Segment<'a> {
type SharedLibrary = ::macos::SharedLibrary<'a>;
type SharedLibrary = SharedLibrary<'a>;

#[inline]
fn name(&self) -> &str {
Expand Down Expand Up @@ -308,8 +309,8 @@ impl<'a> SharedLibraryTrait for SharedLibrary<'a> {

#[cfg(test)]
mod tests {
use super::super::{IterationControl, Segment, SharedLibrary};
use macos;
use crate::{IterationControl, Segment, SharedLibrary};
use crate::macos;

#[test]
fn have_libdyld() {
Expand Down
8 changes: 4 additions & 4 deletions src/unsupported.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
//! The fallback implementation of the [SharedLibrary
//! trait](../trait.SharedLibrary.html) that does nothing.
use super::Segment as SegmentTrait;
use super::SharedLibrary as SharedLibraryTrait;
use super::{Bias, IterationControl, SharedLibraryId, Svma};
use crate::Segment as SegmentTrait;
use crate::SharedLibrary as SharedLibraryTrait;
use crate::{Bias, IterationControl, SharedLibraryId, Svma};

use std::ffi::OsStr;
use std::marker::PhantomData;
Expand All @@ -16,7 +16,7 @@ pub struct Segment<'a> {
}

impl<'a> SegmentTrait for Segment<'a> {
type SharedLibrary = ::unsupported::SharedLibrary<'a>;
type SharedLibrary = SharedLibrary<'a>;

#[inline]
fn name(&self) -> &str {
Expand Down

0 comments on commit 2a0665a

Please sign in to comment.