Skip to content

Commit

Permalink
Merge pull request rust-lang#30 from alexcrichton/dladdr
Browse files Browse the repository at this point in the history
Add dladdr bindings
  • Loading branch information
alexcrichton committed Nov 3, 2015
2 parents 193baf9 + 88d23e7 commit 10dff9a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ fn main() {
// Just pass all these through, no need for a "struct" prefix
"FILE" |
"fd_set" |
"Dl_info" |
"DIR" => ty.to_string(),

// Fixup a few types on windows that don't actually exist.
Expand Down Expand Up @@ -229,6 +230,7 @@ fn main() {
"gettimeofday" if linux || android || freebsd => true,

"dlerror" if android => true, // const-ness is added
"dladdr" if musl => true, // const-ness only added recently

_ => false,
}
Expand Down
8 changes: 8 additions & 0 deletions src/unix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ s! {
#[cfg(not(target_os = "android"))]
pub ipv6mr_interface: ::c_uint,
}

pub struct Dl_info {
pub dli_fname: *const ::c_char,
pub dli_fbase: *mut ::c_void,
pub dli_sname: *const ::c_char,
pub dli_saddr: *mut ::c_void,
}
}

pub const WNOHANG: ::c_int = 1;
Expand Down Expand Up @@ -432,6 +439,7 @@ extern {
pub fn dlsym(handle: *mut ::c_void,
symbol: *const ::c_char) -> *mut ::c_void;
pub fn dlclose(handle: *mut ::c_void) -> ::c_int;
pub fn dladdr(addr: *const ::c_void, info: *mut Dl_info) -> ::c_int;
}

// TODO: get rid of this #[cfg(not(...))]
Expand Down

0 comments on commit 10dff9a

Please sign in to comment.