Skip to content

Re-export mmap libc constants through host_env - #8214

Merged
youknowone merged 2 commits into
RustPython:mainfrom
youknowone:hostenv-mmap
Jul 6, 2026
Merged

Re-export mmap libc constants through host_env#8214
youknowone merged 2 commits into
RustPython:mainfrom
youknowone:hostenv-mmap

Conversation

@youknowone

@youknowone youknowone commented Jul 6, 2026

Copy link
Copy Markdown
Member

part of #7932

Summary by CodeRabbit

  • Bug Fixes
    • Improved memory-mapping support across Unix-like platforms, including better handling of platform-specific flags and advisory options.
    • Updated error handling for Windows named mappings to more reliably report overflow-related failures.
    • Made mmap parameter handling more consistent across platforms, helping reduce compatibility issues.

Move direct libc MADV_*, MAP_*, PROT_*, EOVERFLOW references in
stdlib::mmap to host_env::mmap re-exports. Replace libc::c_int with
core::ffi::c_int.
@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: 0dae6055-3399-478b-8971-e85bb5f70509

📥 Commits

Reviewing files that changed from the base of the PR and between 3f9d80b and f97c1b4.

📒 Files selected for processing (2)
  • crates/host_env/src/mmap.rs
  • crates/stdlib/src/mmap.rs

📝 Walkthrough

Walkthrough

The host_env crate now re-exports platform-gated libc mmap/madvise constants. The stdlib mmap module is updated to source these constants and use core::ffi::c_int instead of libc::c_int across struct fields, method signatures, and constant references throughout the Unix and Windows mmap implementation.

Changes

Mmap Constant Re-export Migration

Layer / File(s) Summary
Platform-gated constant re-exports
crates/host_env/src/mmap.rs
Adds pub use libc::{...} declarations gated by #[cfg(...)] to expose mmap/madvise constants and EOVERFLOW for Unix, macOS, Linux, BSD, and Windows targets.
Switch stdlib imports to host_env
crates/stdlib/src/mmap.rs
Base, macOS, Linux, and other platform-specific MADV_*/MAP_* constant imports are switched from libc to host_mmap.
Update struct/method types to core::ffi::c_int
crates/stdlib/src/mmap.rs
MmapNewArgs, AdviseOptions, py_new, Windows error handling, and seek's whence parameter switch from libc::c_int/constants to core::ffi::c_int/host_mmap constants.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: ShaharNaveh

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: exposing mmap libc constants via host_env re-exports.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Its only consumer is the cfg(windows) named-mapping overflow check in
stdlib::mmap; the re-export was gated cfg(unix), so it was configured
out on Windows and the reference failed to resolve.

Assisted-by: Claude
@youknowone
youknowone marked this pull request as ready for review July 6, 2026 14:52
@youknowone
youknowone merged commit 7044fdc into RustPython:main Jul 6, 2026
49 of 50 checks passed
@youknowone
youknowone deleted the hostenv-mmap branch July 6, 2026 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants