Skip to content

Commit 990afbb

Browse files
committed
Auto merge of #2102 - de-vri-es:linux-arm32-accept4, r=JohnTitor
Re-add accept4 for Android on 32 bit ARM. `accept4` was accidentally removed from 32 bit Android targets except for x86 in #2079. This PR adds it back using the same definition as other non-x86 platforms.
2 parents 3a7135f + b98d529 commit 990afbb

File tree

1 file changed

+16
-0
lines changed
  • src/unix/linux_like/android/b32

1 file changed

+16
-0
lines changed

src/unix/linux_like/android/b32/arm.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,3 +521,19 @@ pub const REG_R14: ::c_int = 14;
521521
pub const REG_R15: ::c_int = 15;
522522

523523
pub const NGREG: ::c_int = 18;
524+
525+
f! {
526+
// Sadly, Android before 5.0 (API level 21), the accept4 syscall is not
527+
// exposed by the libc. As work-around, we implement it through `syscall`
528+
// directly. This workaround can be removed if the minimum version of
529+
// Android is bumped. When the workaround is removed, `accept4` can be
530+
// moved back to `linux_like/mod.rs`
531+
pub fn accept4(
532+
fd: ::c_int,
533+
addr: *mut ::sockaddr,
534+
len: *mut ::socklen_t,
535+
flg: ::c_int
536+
) -> ::c_int {
537+
::syscall(SYS_accept4, fd, addr, len, flg) as ::c_int
538+
}
539+
}

0 commit comments

Comments
 (0)