diff options
| author | David Carlier <devnexen@gmail.com> | 2024-11-23 09:53:45 +0000 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2024-11-24 15:36:59 +0100 |
| commit | 1deb8f9ec1b8a08b76c5bf4ca8b63dd1702e644b (patch) | |
| tree | 8b9661486188b955d3b2770d5e5feee02909cebc | |
| parent | a221d506bcc2df6002c5536145c4c813fb471061 (diff) | |
| download | rust-1deb8f9ec1b8a08b76c5bf4ca8b63dd1702e644b.tar.gz rust-1deb8f9ec1b8a08b76c5bf4ca8b63dd1702e644b.zip | |
sysconf: add _SC_OPEN_MAX
| -rw-r--r-- | src/tools/miri/src/shims/unix/foreign_items.rs | 5 | ||||
| -rw-r--r-- | src/tools/miri/tests/pass-dep/libc/libc-sysconf.rs | 2 |
2 files changed, 7 insertions, 0 deletions
diff --git a/src/tools/miri/src/shims/unix/foreign_items.rs b/src/tools/miri/src/shims/unix/foreign_items.rs index 5594bd4e790..88ec32808b1 100644 --- a/src/tools/miri/src/shims/unix/foreign_items.rs +++ b/src/tools/miri/src/shims/unix/foreign_items.rs @@ -58,6 +58,11 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> { // 512 seems to be a reasonable default. The value is not critical, in // the sense that getpwuid_r takes and checks the buffer length. ("_SC_GETPW_R_SIZE_MAX", |this| Scalar::from_int(512, this.pointer_size())), + // Miri doesn't have a fixed limit on FDs, but we may be limited in terms of how + // many *host* FDs we can open. Just use some arbitrary, pretty big value; + // this can be adjusted if it causes problems. + // The spec imposes a minimum of `_POSIX_OPEN_MAX` (20). + ("_SC_OPEN_MAX", |this| Scalar::from_int(2_i32.pow(16), this.pointer_size())), ]; for &(sysconf_name, value) in sysconfs { let sysconf_name = this.eval_libc_i32(sysconf_name); diff --git a/src/tools/miri/tests/pass-dep/libc/libc-sysconf.rs b/src/tools/miri/tests/pass-dep/libc/libc-sysconf.rs index 34d5b1e38a6..b832b3033b7 100644 --- a/src/tools/miri/tests/pass-dep/libc/libc-sysconf.rs +++ b/src/tools/miri/tests/pass-dep/libc/libc-sysconf.rs @@ -9,6 +9,8 @@ fn test_sysconfbasic() { // note that in reality it can return -1 (no hard limit) on some platforms. let gwmax = libc::sysconf(libc::_SC_GETPW_R_SIZE_MAX); assert!(gwmax >= 512); + let omax = libc::sysconf(libc::_SC_OPEN_MAX); + assert_eq!(omax, 65536); } } |
