Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 1deb8f9

Browse files
devnexenRalfJung
authored andcommitted
sysconf: add _SC_OPEN_MAX
1 parent a221d50 commit 1deb8f9

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/tools/miri/src/shims/unix/foreign_items.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
5858
// 512 seems to be a reasonable default. The value is not critical, in
5959
// the sense that getpwuid_r takes and checks the buffer length.
6060
("_SC_GETPW_R_SIZE_MAX", |this| Scalar::from_int(512, this.pointer_size())),
61+
// Miri doesn't have a fixed limit on FDs, but we may be limited in terms of how
62+
// many *host* FDs we can open. Just use some arbitrary, pretty big value;
63+
// this can be adjusted if it causes problems.
64+
// The spec imposes a minimum of `_POSIX_OPEN_MAX` (20).
65+
("_SC_OPEN_MAX", |this| Scalar::from_int(2_i32.pow(16), this.pointer_size())),
6166
];
6267
for &(sysconf_name, value) in sysconfs {
6368
let sysconf_name = this.eval_libc_i32(sysconf_name);

src/tools/miri/tests/pass-dep/libc/libc-sysconf.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ fn test_sysconfbasic() {
99
// note that in reality it can return -1 (no hard limit) on some platforms.
1010
let gwmax = libc::sysconf(libc::_SC_GETPW_R_SIZE_MAX);
1111
assert!(gwmax >= 512);
12+
let omax = libc::sysconf(libc::_SC_OPEN_MAX);
13+
assert_eq!(omax, 65536);
1214
}
1315
}
1416

0 commit comments

Comments
 (0)