Skip to content

Commit 8fbd292

Browse files
committed
Auto merge of #29752 - tamird:fix-compiletest-stage1, r=alexcrichton
Fixes #29751.
2 parents b53020a + f5e9a4a commit 8fbd292

File tree

1 file changed

+5
-22
lines changed

1 file changed

+5
-22
lines changed

src/compiletest/raise_fd_limit.rs

+5-22
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,8 @@ pub unsafe fn raise_fd_limit() {
2323
use std::mem::size_of_val;
2424
use std::ptr::null_mut;
2525

26-
type rlim_t = libc::uint64_t;
27-
28-
#[repr(C)]
29-
struct rlimit {
30-
rlim_cur: rlim_t,
31-
rlim_max: rlim_t
32-
}
33-
extern {
34-
// name probably doesn't need to be mut, but the C function doesn't
35-
// specify const
36-
fn sysctl(name: *mut libc::c_int, namelen: libc::c_uint,
37-
oldp: *mut libc::c_void, oldlenp: *mut libc::size_t,
38-
newp: *mut libc::c_void, newlen: libc::size_t) -> libc::c_int;
39-
fn getrlimit(resource: libc::c_int, rlp: *mut rlimit) -> libc::c_int;
40-
fn setrlimit(resource: libc::c_int, rlp: *const rlimit) -> libc::c_int;
41-
}
4226
static CTL_KERN: libc::c_int = 1;
4327
static KERN_MAXFILESPERPROC: libc::c_int = 29;
44-
static RLIMIT_NOFILE: libc::c_int = 8;
4528

4629
// The strategy here is to fetch the current resource limits, read the
4730
// kern.maxfilesperproc sysctl value, and bump the soft resource limit for
@@ -51,25 +34,25 @@ pub unsafe fn raise_fd_limit() {
5134
let mut mib: [libc::c_int; 2] = [CTL_KERN, KERN_MAXFILESPERPROC];
5235
let mut maxfiles: libc::c_int = 0;
5336
let mut size: libc::size_t = size_of_val(&maxfiles) as libc::size_t;
54-
if sysctl(&mut mib[0], 2, &mut maxfiles as *mut _ as *mut _, &mut size,
37+
if libc::sysctl(&mut mib[0], 2, &mut maxfiles as *mut _ as *mut _, &mut size,
5538
null_mut(), 0) != 0 {
5639
let err = io::Error::last_os_error();
5740
panic!("raise_fd_limit: error calling sysctl: {}", err);
5841
}
5942

6043
// Fetch the current resource limits
61-
let mut rlim = rlimit{rlim_cur: 0, rlim_max: 0};
62-
if getrlimit(RLIMIT_NOFILE, &mut rlim) != 0 {
44+
let mut rlim = libc::rlimit{rlim_cur: 0, rlim_max: 0};
45+
if libc::getrlimit(libc::RLIMIT_NOFILE, &mut rlim) != 0 {
6346
let err = io::Error::last_os_error();
6447
panic!("raise_fd_limit: error calling getrlimit: {}", err);
6548
}
6649

6750
// Bump the soft limit to the smaller of kern.maxfilesperproc and the hard
6851
// limit
69-
rlim.rlim_cur = cmp::min(maxfiles as rlim_t, rlim.rlim_max);
52+
rlim.rlim_cur = cmp::min(maxfiles as libc::rlim_t, rlim.rlim_max);
7053

7154
// Set our newly-increased resource limit
72-
if setrlimit(RLIMIT_NOFILE, &rlim) != 0 {
55+
if libc::setrlimit(libc::RLIMIT_NOFILE, &rlim) != 0 {
7356
let err = io::Error::last_os_error();
7457
panic!("raise_fd_limit: error calling setrlimit: {}", err);
7558
}

0 commit comments

Comments
 (0)