Skip to content

Commit

Permalink
Use libc::setdomainname where possible
Browse files Browse the repository at this point in the history
Use weak `setdomainname` only for android; remove this special case
once [libc#4212] is merged.

[libc#4212]: rust-lang/libc#4212
  • Loading branch information
yuki0iq committed Dec 18, 2024
1 parent 3d49429 commit 01ad8ac
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/backend/libc/system/syscalls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,25 @@ pub(crate) fn sethostname(name: &[u8]) -> io::Result<()> {
}

#[cfg(not(any(
target_os = "android",
target_os = "emscripten",
target_os = "espidf",
target_os = "haiku",
target_os = "redox",
target_os = "vita",
target_os = "wasi"
)))]
pub(crate) fn setdomainname(name: &[u8]) -> io::Result<()> {
unsafe {
ret(c::setdomainname(
name.as_ptr().cast(),
name.len().try_into().map_err(|_| io::Errno::INVAL)?,
))
}
}

// https://github.com/rust-lang/libc/pull/4212
#[cfg(target_os = "android")]
pub(crate) fn setdomainname(name: &[u8]) -> io::Result<()> {
syscall! {
fn setdomainname(
Expand Down

0 comments on commit 01ad8ac

Please sign in to comment.