mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 07:14:28 +00:00
Use libc::accept4 on Android instead of raw syscall.
This commit is contained in:
parent
6b56603e35
commit
3ac62cafa3
@ -195,6 +195,7 @@ impl Socket {
|
||||
// glibc 2.10 and musl 0.9.5.
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "dragonfly",
|
||||
target_os = "freebsd",
|
||||
target_os = "illumos",
|
||||
@ -206,13 +207,6 @@ impl Socket {
|
||||
libc::accept4(self.0.raw(), storage, len, libc::SOCK_CLOEXEC)
|
||||
})?;
|
||||
Ok(Socket(FileDesc::new(fd)))
|
||||
// While the Android kernel supports the syscall,
|
||||
// it is not included in all versions of Android's libc.
|
||||
} else if #[cfg(target_os = "android")] {
|
||||
let fd = cvt_r(|| unsafe {
|
||||
libc::syscall(libc::SYS_accept4, self.0.raw(), storage, len, libc::SOCK_CLOEXEC)
|
||||
})?;
|
||||
Ok(Socket(FileDesc::new(fd as c_int)))
|
||||
} else {
|
||||
let fd = cvt_r(|| unsafe { libc::accept(self.0.raw(), storage, len) })?;
|
||||
let fd = FileDesc::new(fd);
|
||||
|
Loading…
Reference in New Issue
Block a user