Skip to content

Commit 10dff9a

Browse files
committed
Merge pull request rust-lang#30 from alexcrichton/dladdr
Add dladdr bindings
2 parents 193baf9 + 88d23e7 commit 10dff9a

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

libc-test/build.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ fn main() {
117117
// Just pass all these through, no need for a "struct" prefix
118118
"FILE" |
119119
"fd_set" |
120+
"Dl_info" |
120121
"DIR" => ty.to_string(),
121122

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

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

233235
_ => false,
234236
}

src/unix/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,13 @@ s! {
7676
#[cfg(not(target_os = "android"))]
7777
pub ipv6mr_interface: ::c_uint,
7878
}
79+
80+
pub struct Dl_info {
81+
pub dli_fname: *const ::c_char,
82+
pub dli_fbase: *mut ::c_void,
83+
pub dli_sname: *const ::c_char,
84+
pub dli_saddr: *mut ::c_void,
85+
}
7986
}
8087

8188
pub const WNOHANG: ::c_int = 1;
@@ -432,6 +439,7 @@ extern {
432439
pub fn dlsym(handle: *mut ::c_void,
433440
symbol: *const ::c_char) -> *mut ::c_void;
434441
pub fn dlclose(handle: *mut ::c_void) -> ::c_int;
442+
pub fn dladdr(addr: *const ::c_void, info: *mut Dl_info) -> ::c_int;
435443
}
436444

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

0 commit comments

Comments
 (0)