Skip to content

Commit b664e4b

Browse files
authored
Rollup merge of #82473 - de-vri-es:android-x86-accept4, r=m-ou-se
Use libc::accept4 on Android instead of raw syscall. This PR replaces the use of a raw `accept4` syscall with `libc::accept4`. This was originally added (by me) because `std` couldn't update to the latest `libc` with `accept4` support for android. By now, libc is already on 0.2.85, so the workaround can be removed. `@rustbot` label +O-android +T-libs-impl
2 parents 5c7b383 + f291131 commit b664e4b

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

library/std/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ cfg-if = { version = "0.1.8", features = ['rustc-dep-of-std'] }
1616
panic_unwind = { path = "../panic_unwind", optional = true }
1717
panic_abort = { path = "../panic_abort" }
1818
core = { path = "../core" }
19-
libc = { version = "0.2.79", default-features = false, features = ['rustc-dep-of-std'] }
19+
libc = { version = "0.2.85", default-features = false, features = ['rustc-dep-of-std'] }
2020
compiler_builtins = { version = "0.1.39" }
2121
profiler_builtins = { path = "../profiler_builtins", optional = true }
2222
unwind = { path = "../unwind" }

library/std/src/sys/unix/net.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ impl Socket {
195195
// glibc 2.10 and musl 0.9.5.
196196
cfg_if::cfg_if! {
197197
if #[cfg(any(
198+
target_os = "android",
198199
target_os = "dragonfly",
199200
target_os = "freebsd",
200201
target_os = "illumos",
@@ -206,13 +207,6 @@ impl Socket {
206207
libc::accept4(self.0.raw(), storage, len, libc::SOCK_CLOEXEC)
207208
})?;
208209
Ok(Socket(FileDesc::new(fd)))
209-
// While the Android kernel supports the syscall,
210-
// it is not included in all versions of Android's libc.
211-
} else if #[cfg(target_os = "android")] {
212-
let fd = cvt_r(|| unsafe {
213-
libc::syscall(libc::SYS_accept4, self.0.raw(), storage, len, libc::SOCK_CLOEXEC)
214-
})?;
215-
Ok(Socket(FileDesc::new(fd as c_int)))
216210
} else {
217211
let fd = cvt_r(|| unsafe { libc::accept(self.0.raw(), storage, len) })?;
218212
let fd = FileDesc::new(fd);

0 commit comments

Comments
 (0)