From 8c387c58de04815652d9e991438fb0856ad6c573 Mon Sep 17 00:00:00 2001 From: Nahor Date: Tue, 7 Oct 2025 10:51:49 -0700 Subject: [PATCH] Fix build for MSYS2 (missing ulimits) Part of #11907 --- src/builtins/ulimit.rs | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) diff --git a/src/builtins/ulimit.rs b/src/builtins/ulimit.rs index fec376343..c1a9b4b46 100644 --- a/src/builtins/ulimit.rs +++ b/src/builtins/ulimit.rs @@ -19,11 +19,23 @@ pub mod common { pub const CORE: libc::c_int = libc::RLIMIT_CORE as _; pub const DATA: libc::c_int = libc::RLIMIT_DATA as _; pub const FSIZE: libc::c_int = libc::RLIMIT_FSIZE as _; - pub const MEMLOCK: libc::c_int = libc::RLIMIT_MEMLOCK as _; + cfg_if!( + if #[cfg(cygwin)] { + pub const MEMLOCK: libc::c_int = -1; + } else { + pub const MEMLOCK: libc::c_int = libc::RLIMIT_MEMLOCK as _; + } + ); pub const NOFILE: libc::c_int = libc::RLIMIT_NOFILE as _; pub const STACK: libc::c_int = libc::RLIMIT_STACK as _; pub const CPU: libc::c_int = libc::RLIMIT_CPU as _; - pub const NPROC: libc::c_int = libc::RLIMIT_NPROC as _; + cfg_if!( + if #[cfg(cygwin)] { + pub const NPROC: libc::c_int = -1; + } else { + pub const NPROC: libc::c_int = libc::RLIMIT_NPROC as _; + } + ); cfg_if!( if #[cfg(target_os = "openbsd")] { pub const AS: libc::c_int = -1; @@ -113,6 +125,26 @@ pub mod bsd { } #[cfg(bsd)] pub use self::bsd::*; + + #[cfg(cygwin)] + pub mod cygwin { + use libc; + + pub const SIGPENDING: libc::c_int = -1; + pub const MSGQUEUE: libc::c_int = -1; + pub const RTPRIO: libc::c_int = -1; + pub const RTTIME: libc::c_int = -1; + pub const RSS: libc::c_int = -1; + + pub const SBSIZE: libc::c_int = -1; + pub const NICE: libc::c_int = -1; + pub const SWAP: libc::c_int = -1; + pub const KQUEUES: libc::c_int = -1; + pub const NPTS: libc::c_int = -1; + pub const NTHR: libc::c_int = -1; + } + #[cfg(cygwin)] + pub use self::cygwin::*; } /// Calls getrlimit.