Skip to content

Add res_init #585

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
May 3, 2017
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
11 changes: 11 additions & 0 deletions libc-test/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ fn main() {
cfg.header("netinet/in.h");
cfg.header("netinet/ip.h");
cfg.header("netinet/tcp.h");
cfg.header("resolv.h");
cfg.header("pthread.h");
cfg.header("dlfcn.h");
cfg.header("signal.h");
Expand Down Expand Up @@ -468,6 +469,16 @@ fn main() {
// it's in a header file?
"endpwent" if android => true,

// Apparently res_init exists on Android, but isn't defined in a header:
// https://mail.gnome.org/archives/commits-list/2013-May/msg01329.html
"res_init" if android => true,

// On macOS and iOS, res_init is available, but requires linking with libresolv:
// http://blog.achernya.com/2013/03/os-x-has-silly-libsystem.html
// See discussion for skipping here:
// https://github.com/rust-lang/libc/pull/585#discussion_r114561460
"res_init" if apple => true,

_ => 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 @@ -694,6 +694,14 @@ extern {
res: *mut *mut addrinfo) -> ::c_int;
pub fn freeaddrinfo(res: *mut addrinfo);
pub fn gai_strerror(errcode: ::c_int) -> *const ::c_char;
#[cfg_attr(any(
all(target_os = "linux", not(target_env = "musl")),
target_os = "freebsd",
target_os = "dragonfly"),
link_name = "__res_init")]
#[cfg_attr(any(target_os = "macos", target_os = "ios"),
link_name = "res_9_init")]
pub fn res_init() -> ::c_int;

#[cfg_attr(target_os = "netbsd", link_name = "__gmtime_r50")]
pub fn gmtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm;
Expand Down