Skip to content

Commit 0afebe6

Browse files
committed
Replace deprecated getdtablesize() with sysconf(_SC_OPEN_MAX) for android aarch64
1 parent 0ef56da commit 0afebe6

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

src/libstd/sys/unix/process.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ impl Process {
6969
K: BytesContainer + Eq + Hash, V: BytesContainer
7070
{
7171
use libc::funcs::posix88::unistd::{fork, dup2, close, chdir, execvp};
72-
use libc::funcs::bsd44::getdtablesize;
7372

7473
mod rustrt {
7574
extern {
@@ -82,6 +81,15 @@ impl Process {
8281
assert_eq!(ret, 0);
8382
}
8483

84+
#[cfg(all(target_os = "android", target_arch = "aarch64"))]
85+
unsafe fn getdtablesize() -> c_int {
86+
libc::sysconf(libc::consts::os::sysconf::_SC_OPEN_MAX) as c_int
87+
}
88+
#[cfg(not(all(target_os = "android", target_arch = "aarch64")))]
89+
unsafe fn getdtablesize() -> c_int {
90+
libc::funcs::bsd44::getdtablesize()
91+
}
92+
8593
let dirp = cfg.cwd().map(|c| c.as_ptr()).unwrap_or(ptr::null());
8694

8795
// temporary until unboxed closures land

src/libstd/sys/unix/process2.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ impl Process {
141141
-> io::Result<Process>
142142
{
143143
use libc::funcs::posix88::unistd::{fork, dup2, close, chdir, execvp};
144-
use libc::funcs::bsd44::getdtablesize;
145144

146145
mod rustrt {
147146
extern {
@@ -154,6 +153,16 @@ impl Process {
154153
assert_eq!(ret, 0);
155154
}
156155

156+
#[cfg(all(target_os = "android", target_arch = "aarch64"))]
157+
unsafe fn getdtablesize() -> c_int {
158+
libc::sysconf(libc::consts::os::sysconf::_SC_OPEN_MAX) as c_int
159+
}
160+
161+
#[cfg(not(all(target_os = "android", target_arch = "aarch64")))]
162+
unsafe fn getdtablesize() -> c_int {
163+
libc::funcs::bsd44::getdtablesize()
164+
}
165+
157166
let dirp = cfg.cwd.as_ref().map(|c| c.as_ptr()).unwrap_or(ptr::null());
158167

159168
with_envp(cfg.env.as_ref(), |envp: *const c_void| {

0 commit comments

Comments
 (0)